3 Replies Latest reply on Sep 19, 2011 6:53 AM by 546634

    JMS - UserTransaction - Commit issue

      I am moving from WebSphere to Weblogic and have counterd an UserTransaction commit issue.
      The code have not been modified, however the logic in Weblogic and Websphere behaves different.

      The messagingsystem is Websphere MQ, in Weblogic I have QCF, destinations, host and port etc. in a .bindings file, and I have configured JMS server and JMS modules with corresponding jndi names.

      I have verified that this configuration is correct throug a custom develop testtool deployed in WL, message is sent successfully to MQ.

      The problem - description
      However in my application i'm using UserTransaction and this is not working as expected.
      I have two classes that communicate with MQ (AbcDAO.java and QueueBroker.java) AbcDAO.java creates a UserTransaction and communicates with Queuebroker throug a method called "SendToAutoS" this method retrives the corrilationId (for the message sendt to MQ) from Queuebroker.
      The SendMessage method creates qcf, queueconnection, queue etc and sends the message to MQ. When i debug this steps (line:queueSender.send(theMessage) I can verify in MQ that a message count is registerted in mq on the correct queue, but it's not shown (since its not commited). However when performing finalize in Queuebroker, which close both session and connection, the messagecount is gone in MQ, and when returing to AbcDAO.java to perform ut.commit(); there is not any message on Queue.

      For me it looks like the message is rolledback when session and connection closes.

      Actions tried
      If I change this line QueueBroker , transacted to false witch i understand sends message without the need to commit:
      boolean transacted = false;
      queueSession = queueConnection.createQueueSession(transacted, QueueSession.AUTO_ACKNOWLEDGE);

      the message is sendt successfully to MQ. However now either commit or rollback on the UserTransaction is working with transacted=false.

      I need the commit and rollback to be done on the UserTransaction for my application.
      Anyone have an idea why this is not working?

      The files - content

      AbcDAO.java - that creates a usertransaction
      ut = ServiceLocator.getInstance().getUserTransaction();
      msgCorId = sendToAutoS(userVO, messageSend, transactionQeueSend, transactionQeueFactory);

      //SendToAutoS - that calls the Queuebroker method - sendMessage
      private String sendToAutoS(UserVO userVO, String message, String transactionQueue, String transactionQueueFactory) throws DaoException {
      try {
      return QueueBroker.getInstance().sendMessage(message, transactionQueue, transactionQueueFactory);
      } catch (BrokerException be) {
      log.error("BrokerException", be);

      QueueBroker.java - that sends the message to MQ
      public String sendMessage(String message, String transactionQueue, String transactionQueueFactory) throws BrokerException {
      try {
      // Get service locator
      ServiceLocator sl = ServiceLocator.getInstance();
      // Create QueueConnectionFactory with help form service locator
      queueConnectionFactory = (QueueConnectionFactory) sl.getQueueConnectionFactory(transactionQueueFactory);
      // Create QueueConnection
      queueConnection = queueConnectionFactory.createQueueConnection();
      // Create QueueSession, transacted - client has to commit !
      boolean transacted = true;
      queueSession = queueConnection.createQueueSession(transacted, QueueSession.AUTO_ACKNOWLEDGE);
      // Create queue with help from service locator
      queue = (Queue) sl.getQueue(transactionQueue);
      // Create QueueSender
      queueSender = queueSession.createSender(queue);
      // Create message and sent it
      Message theMessage = null;
      theMessage = queueSession.createTextMessage(message);
      // Log time
      long time = System.currentTimeMillis();
      // Set log time on message
      // Send
      // Return unique messageID for message just been sent
      return theMessage.getJMSMessageID();
      } catch (JMSException je) {
      BrokerException ex = new BrokerException();
      Object[] o = {"SEND", "String to Autosys = " + message};
      throw ex;
      } catch (ServiceLocatorException e) {
      BrokerException ex = new BrokerException();
      throw ex;
      } finally {
      // Clean up - close connection and session if exist
      if (queueConnection != null) {


      * Finalize queue handling
      * @throws BrokerException e
      protected void finalize() throws BrokerException {
      try {
      // Close connections
      } catch (JMSException je) {
      BrokerException ex = new BrokerException();
      Object[] o = {"FINALIZE", "Close connections" };
      throw ex;

      Edited by: reZer on 14.sep.2011 13:05

      Edited by: reZer on 14.sep.2011 13:06