1 Reply Latest reply on Dec 28, 2002 9:05 AM by adrian.brock

    Transacted JMS

    dhiren

      Could anyone assist me as to how to configure JBoss for transacted Messaging involving database as well as messages in the same transaction spaning multiple statless session bean.

      I am having issues with transacted messaging.

      I have an ejb1(stateless session bean) in which I perform database update and then call a method on ejb2 (stateless session bean), which sends message to a message queue. As I need both, the database update and messaging, to either succeed or fail as an atomic unit, I need to start the transaction in ejb1 and span the same to ejb2.

      How do I configure JBoss to use transacted JMS. I believe I need to use jmsXA however I don't know how to configure jboss for the same.

        • 1. Re: Transacted JMS

          ejb-jar.xml
          -----------

          <ejb-jar>
          <enterprise-beans>

          <ejb-name>QueueSession</ejb-name>
          ...
          <session-type>Stateless</session-type>
          <transaction-type>Container</transaction-type>
          <resource-ref>
          <res-ref-name>jms/MyQueueConnection</res-ref-name>
          <res-type>javax.jms.QueueConnectionFactory</res-type>
          <res-auth>Container</res-auth>
          </resource-ref>
          <resource-ref>
          ...

          jboss.xml
          ---------


          <resource-managers>
          <resource-manager>
          <res-name>queuefactoryref</res-name>
          <res-jndi-name>java:/JmsXA</res-jndi-name>
          </resource-manager>
          </resource-managers>

          <enterprise-beans>

          <ejb-name>QueueSession</ejb-name>
          <resource-ref>
          <res-ref-name>jms/MyQueueConnection</res-ref-name>
          <resource-name>queuefactoryref</resource-name>
          </resource-ref>
          </enterprise-beans>

          Code
          ----
          InitialContext ctx = new InitialContext();
          QueueConnectionFactory qcf = (QueueConnectionFactory) ctx.lookup("java:comp/env/jms/MyQueueConnection");

          Regards,
          Adrian