Trying to execute commit, but can't get out of Global Transaction - Websphere

This is a discussion on Trying to execute commit, but can't get out of Global Transaction - Websphere ; WSAD 5.1.1, WAS 5.1 test environment I have a requirement from our architect to parse a large text file and put the chunks into a queue. I have two sample beans. An mdb that listens on the queue, and pulls ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Trying to execute commit, but can't get out of Global Transaction

  1. Trying to execute commit, but can't get out of Global Transaction

    WSAD 5.1.1, WAS 5.1 test environment

    I have a requirement from our architect to parse a large text file and
    put the chunks into a queue. I have two sample beans. An mdb that
    listens on the queue, and pulls messages off successfully when I use the
    sample 'put' bean, through the UniversalTestClient and send a message.

    This works because the QueueConnection, QueueSession and QueueSender all
    get initialized and cleaned up within the simple put method.

    In my method I know I am trying to do too much but I do not know how
    much wiggle room I have with the architect. I trying to send a large
    number of messages, parsed from a 90Meg data file, through the queue.
    Without adding a session.commit(), it fails after about 6k messages. So
    I am guessing that there is some transactional management at the
    bean/container level, and since I am not commiting, the messages don't
    get committed to the queue, and the receiver cannot being pulling
    messages off the queue.

    When I try to do a session.commit I get:
    javax.jms.IllegalStateException: Method not permitted in global transaction

    If I tear down the session and the sender after I send one message, and
    it works for quite a while before apparently running out of resources with:
    javax.jms.ResourceAllocationException: MQJMS2008: failed to open MQ queue

    I have tried disabling XA in the WAS Admin Console, but I still wind up
    in a global transaction.

    Clearly I am having some problems grasping what is exactly going on.
    Can someone suggest a possible solution, or some links to resources that
    can explain what I am running into?

    Here are relevant parts from the code:

    ejbCreate:
    initialContext = new InitialContext();
    qCFactory = (QueueConnectionFactory)
    initialContext.lookup("java:comp/env/QM");
    outDummyQueue =(Queue)initialContext.lookup("java:comp/env/QUEUE");


    my method:
    qConnection = qCFactory.createQueueConnection();
    qConnection.start();
    qSession = qConnection.createQueueSession(true,
    QueueSession.CLIENT_ACKNOWLEDGE);
    dataQueueSender = qSession.createSender(outDummyQueue);

    while((line = in.readLine())!= null){
    TextMessage tMsg = qSession.createTextMessage();
    tMsg.setStringProperty("Test1","T");
    tMsg.setStringProperty("Test2","F");

    //actually does something with the data
    //and puts it into a string
    String message = "something";

    tMsg.setText(message);
    dataQueueSender.send(tMsg);
    //qSession.commit();
    }

    in the finally:
    if (dataQueueSender != null)
    dataQueueSender.close();
    dataQueueSender = null;
    if (qSession != null)
    qSession.close();
    qSession = null;
    if (qConnection != null)
    qConnection.close();

  2. Re: Trying to execute commit, but can't get out of Global Transaction

    Ok I resolved this issue.

    In WSAD:
    Open EJB Deployment Descriptor
    Select the bean you want to modify.
    Transaction Type: Bean

    Under WebSphere Extensions:
    Boundary: Bean
    Resolver: Application
    Unresolver action: Rollback

    Craig Moynes wrote:
    > WSAD 5.1.1, WAS 5.1 test environment
    >
    > I have a requirement from our architect to parse a large text file and
    > put the chunks into a queue. I have two sample beans. An mdb that
    > listens on the queue, and pulls messages off successfully when I use the
    > sample 'put' bean, through the UniversalTestClient and send a message.
    >
    > This works because the QueueConnection, QueueSession and QueueSender all
    > get initialized and cleaned up within the simple put method.
    >
    > In my method I know I am trying to do too much but I do not know how
    > much wiggle room I have with the architect. I trying to send a large
    > number of messages, parsed from a 90Meg data file, through the queue.
    > Without adding a session.commit(), it fails after about 6k messages. So
    > I am guessing that there is some transactional management at the
    > bean/container level, and since I am not commiting, the messages don't
    > get committed to the queue, and the receiver cannot being pulling
    > messages off the queue.
    >
    > When I try to do a session.commit I get:
    > javax.jms.IllegalStateException: Method not permitted in global transaction
    >
    > If I tear down the session and the sender after I send one message, and
    > it works for quite a while before apparently running out of resources with:
    > javax.jms.ResourceAllocationException: MQJMS2008: failed to open MQ queue
    >
    > I have tried disabling XA in the WAS Admin Console, but I still wind up
    > in a global transaction.
    >
    > Clearly I am having some problems grasping what is exactly going on. Can
    > someone suggest a possible solution, or some links to resources that can
    > explain what I am running into?
    >
    > Here are relevant parts from the code:
    >
    > ejbCreate:
    > initialContext = new InitialContext();
    > qCFactory = (QueueConnectionFactory)
    > initialContext.lookup("java:comp/env/QM");
    > outDummyQueue =(Queue)initialContext.lookup("java:comp/env/QUEUE");
    >
    >
    > my method:
    > qConnection = qCFactory.createQueueConnection();
    > qConnection.start();
    > qSession = qConnection.createQueueSession(true,
    > QueueSession.CLIENT_ACKNOWLEDGE);
    > dataQueueSender = qSession.createSender(outDummyQueue);
    >
    > while((line = in.readLine())!= null){
    > TextMessage tMsg = qSession.createTextMessage();
    > tMsg.setStringProperty("Test1","T");
    > tMsg.setStringProperty("Test2","F");
    >
    > //actually does something with the data
    > //and puts it into a string
    > String message = "something";
    >
    > tMsg.setText(message);
    > dataQueueSender.send(tMsg);
    > //qSession.commit();
    > }
    >
    > in the finally:
    > if (dataQueueSender != null)
    > dataQueueSender.close();
    > dataQueueSender = null;
    > if (qSession != null)
    > qSession.close();
    > qSession = null;
    > if (qConnection != null)
    > qConnection.close();


+ Reply to Thread