1 Reply Latest reply on Jun 10, 2005 12:41 PM by Krisha Verumuri

    UserTransaction Started, but JMS Session is sending messages

    Krisha Verumuri Newbie

      Jboss Version: 4.0.2

      I have this code in my servlet.

      InitialContext ctx = new InitialContext() ;
      UserTransaction utxn = (javax.transaction.UserTransaction)ctx.lookup("java:comp/UserTransaction");
      utxn.begin();

      -- Some DB related Code here --

      XAQueueConnectionFactory jobsQCF = (XAQueueConnectionFactory)ctx.lookup("XAConnectionFactory") ;
      XAQueueConnection conn = jobsQCF.createXAQueueConnection();
      Queue que = (Queue)ctx.lookup(JOBQ) ;
      XAQueueSession session = conn.createXAQueueSession();
      MessageProducer producer = session.createProducer(que);
      int i = 0 ;
      while (i < 5) {
      String sampleMessage = "Message(" + i + ") sent by " + this.getClass().getName() + " @"
      + new java.util.Date() ;
      TextMessage msg = session.createTextMessage(sampleMessage) ;
      producer.send(msg);
      Thread.sleep(2000) ;
      i++ ;
      }

      utxn.commit();

      The MDB is receiving the messages before my commit.

      I have tried with ConnectionFactory/Connection/Session before I changed to XA interfaces?



      What am I missing?