JMS Transactions - Websphere

This is a discussion on JMS Transactions - Websphere ; I'm trying to get WebSphere MQ 7.0.0.0 (90-day evaluation copy) to work transactionally. The commit() and rollback() methods work, but only if you call them. If you fail the JVM or just exit the app ungracefully, any uncommitted messages are ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: JMS Transactions

  1. JMS Transactions

    I'm trying to get WebSphere MQ 7.0.0.0 (90-day evaluation copy) to work transactionally.

    The commit() and rollback() methods work, but only if you call them. If you fail the JVM or just exit the app ungracefully, any uncommitted messages are committed - they should be rolled back.

    What am I doing wrong?

    Test code follows:

    public static void main(String[] args)
    {
    try{
    // Fiddled non-JNDI provided factory.
    MQQueueConnectionFactory factory = new MQQueueConnectionFactory();
    factory.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_T CPIP);
    factory.setHostName("MQ_SERVER");
    factory.setPort(1415);

    // Standard JMS API classes.
    QueueConnection connection = factory.createQueueConnection("", "");
    QueueSession session = connection.createQueueSession(true, Session.SESSION_TRANSACTED);
    Queue queue = session.createQueue("queue://TEST_Q_MAN/TEST_Q");
    QueueSender sender = session.createSender(queue);
    TextMessage message = session.createTextMessage();
    message.setText("Hello World");
    sender.send(message);
    //session.rollback();
    //sender.close();
    //session.close();
    //connection.close();
    }catch(Exception e){
    e.printStackTrace();
    }
    }

  2. Re: JMS Transactions

    Why are you taking the responsibility of instantiating the MQ and Connections ?

    What i mean to ask is : why are you not using any Server to do this for you ??

  3. Re: JMS Transactions

    I don't have a JNDI server to hand.

    If WebSphere MQ can do this, then I don't know how to set it up.

    It was one less step to go wrong with a simple test app.

    Please understand, I am new to MQ, but understand JMS.

  4. Re: JMS Transactions

    The MQ doesn't provide this feature from the producer side (Application).

    Is is possible to use the Support of Exceptions or Transactions ??

  5. Re: JMS Transactions

    Is is possible to use the Support of Exceptions or Transactions ??

    I could rollback() on any exception and commit() if I get to the end, but the problem is if I get a core dump or out-of-memory exception, which stops the rollback actually being called - MQ just commits it anyway, without knowing that the series of operations that need to be applied atomically have been completed.

  6. Re: JMS Transactions

    You misunderstood me , From the producer side how can a MQ know when to commit or rollback .This should be the responsibility of the Application only know .

+ Reply to Thread