3 Replies Latest reply on Jul 12, 2004 7:28 PM by iamapony

    JBossMQ, JMS Message in transaction?

    iamapony Newbie

      I have a MDB attached to QueueA, in a SessionBean method I write a record to the database and then send a message to QueueA to do something with that database record. The onMessage in the MDB then fails because it can't find the message, showing me that the JMS message is not participating in the transaction and is being sent before the DB commit. What's the process to have JMS Send operation participate in the JTA transaction? I'm using the RMIXAConnectionFactory.



        • 1. Re: JBossMQ, JMS Message in transaction?
          Stephane Nicoll Master

          Show the code that sends the message to QueueA in your session bean.

          It should NOT use JMS transacted session (i.e. pass true when you create your JMS session). If your Session Bean is enlisted to a JTA transaction, sending of the JMS message will also be enlisted automatically.



          • 2. Re: JBossMQ, JMS Message in transaction?
            iamapony Newbie

            That's what I thought as well, but it doesn't appear to be happening.. Here's the code.

            QueueSender sender = null;
            QueueSession session = null;
            QueueConnection conn = null;
            try {
            InitialContext iniCtx = new InitialContext();
            Object tmp = iniCtx.lookup("RMIXAConnectionFactory");
            QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
            conn = qcf.createQueueConnection();
            Queue queA = (Queue) iniCtx.lookup("queue/A");
            session = conn.createQueueSession(false,
            sender = session.createSender(queA);
            ObjectMessage om = session.createObjectMessage(message);
            } catch (NamingException e) {
            } catch (Exception e) {
            } finally {
            // Ensure that the Connection always gets closed
            try {
            if (sender != null) {
            sender = null;
            if (session != null) {
            session = null;
            if (conn != null) {
            conn = null;

            } catch (JMSException je) {

            • 3. Re: JBossMQ, JMS Message in transaction?
              iamapony Newbie

              Found the answer, you have to use the java:/JmsXA JMS Provider Resource... More information and sample code in link below.