activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Meeraj Kunnumpurath" <M.Kunnumpur...@voca.com>
Subject ActiveMQ and JTA
Date Fri, 31 Mar 2006 16:05:20 GMT
Hi,

I am using ActiveMQ 4.0 M4 standalone with the message consumers and
producers running from a separate Weblogic instance. I have got the
following code to send a message using JTA transaction demarcation,

Context ctx = null;
Connection con = null;
Session sess = null;

try {
        context = new InitialContext();
        UserTransaction utx =
(UserTransaction)ctx.lookup("javax.transaction.UserTransaction");
        utx.begin();
               
        ConnectionFactory cf = new
ActiveMQConnectionFactory("tcp://localhost:61616");
        Destination dst = new ActiveMQQueue("submission.queue");
        Connection con = cf.createConnection();
        Session sess = con.createSession(false,
Session.AUTO_ACKNOWLEDGE);

        MessageProducer prod = sess.createProducer(dst);
        prod.send(sess.createTextMessage("Test"));
               
        con.stop();
        utx.rollback();

} catch(Exception ex) {
        throw new RuntimeException(ex);
} finally {
        closeResources(ctx, con, sess);
} 

The message is still being published, despite the transaction being
rolled back. Do I need to do anything else so that the ActiveMQ session
get enlisted with the transaction manager.

Any pointers would be highly appreciated.

Kind Regards

Meeraj



*****************************************************

    You can find us at www.voca.com

*****************************************************
This communication is confidential and intended for 
the exclusive use of the addressee only. You should 
not disclose its contents to any other person.
If you are not the intended recipient please notify 
the sender named above immediately.

Registered in England, No 1023742,
Registered Office: Voca Limited
Drake House, Three Rivers Court,
Homestead Road, Rickmansworth,
Hertfordshire, WD3 1FX


This message has been checked for all email viruses by MessageLabs.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message