3 Replies Latest reply on Jun 4, 2003 3:00 AM by artems

    JMS session not committed by Container Transaction

    artems

      Hi.
      I'm using a stateless session with container transactions and the transactional attribute is Required.

      The session's business method updates the DB and publishes a message to a topic. At the end of the business method I call close() method on the session.
      The code looks like that:

      topicSession = topicConnection.createTopicSession(true, 0);
      publisher = topicSession.createPublisher(topic);
      message = topicSession.createObjectMessage(obj);
      publisher.publish(message);
      topicSession.close();


      The problem is that the message is not delivered upon commit (after the method returns), but instead the topic session is rolled back as a result of calling close().

      Am i doing something wrong?

      Thanks in advance,
      Artem

        • 1. Re: JMS session not committed by Container Transaction

          Use the connection factory java:/jmsXA

          Regards,
          Adrian

          • 2. Re: JMS session not committed by Container Transaction
            artems

            Well, I've changed the jndi name from "ConnectionFactory" to "java:/XAConnectionFactory" (is that what you mean?) and it worked the same.
            Then I realised that to participate in XA transaction the session must be XATopicSession and not TopicSession (is that correct?).
            So i changed the code to use XA classes all the way:

            topicConnection = connFactory.createXATopicConnection();
            xaTopicSession = topicConnection.createXATopicSession();
            publisher = xaTopicSession.getTopicSession().createPublisher(topic);

            message = xaTopicSession.createObjectMessage(obj);
            publisher.publish(message);
            xaTopicSession.close();

            Now it throws JMSException("Invalid transaction id") on calling the publish() method.

            What's wrong now?

            Thank you,
            Artem

            • 3. Re: JMS session not committed by Container Transaction
              artems

              You right, everything i need is to use jndi-name java:/JmsXA in jboss.xml
              No need to use XAConnectionFactory, XATopicSession etc.
              Everything works great.

              Thanks!
              Artem