3 Replies Latest reply on Sep 18, 2006 3:35 PM by vakuthota

    How to configure JMS Distributed Topic & Destinations in JBo

    vakuthota Newbie

      Can anybody help me in configuring the JMS Topic and connection factory for distributed transactions (XA).

      I have to implement the requirement, in which Oracle db, MySql db and JMS topic are the three hetrogeneous resources/datasources, involving in the transactions. I configured oracle-xa-ds.xml and mysql-xa-ds.xml, but i am not sure how to make my JMS topic XA compliant ??

      Appreciate your help...


        • 1. Re: How to configure JMS Distributed Topic & Destinations in
          Kevin Conner Master

          Hiya Venu.

          How are you currently configuring JMS? If you are using JBossMQ, and accessing via JNDI, then the enlist should be handled for you by the app server.


          • 2. Re: How to configure JMS Distributed Topic & Destinations in
            vakuthota Newbie

            Hi Kevin,

            Thanks for the quick response....

            Yes i am using JBossMQ only.

            I have configured the Topic as below in venu-destinations-service.xml:

            <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager
            <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager

            And using the JMS Provider loader configured in jms-ds.xml as the connection factory :

            i.e., in jms-ds.xml

            <!-- The JMS provider loader -->



            <!-- The combined connection factory -->
            <!-- The queue connection factory -->
            <!-- The topic factory -->
            <!-- Uncomment to use HAJNDI to access JMS



            And here is my code to get connection factory and topic :

            //Create the connection factory and topic session for publisher
            try {
            ctx = new InitialContext();
            topicConnectionFactory = (TopicConnectionFactory) ctx.lookup("java:/XAConnectionFactory");
            topicConnection = topicConnectionFactory.createTopicConnection();
            publisherSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
            }catch(NamingException e) {
            return "Could not set up JMS clients";
            }catch(JMSException e) {
            return "Could not set up JMS clients";

            //Create the topic
            try {
            topic = (Topic) ctx.lookup("topic/venuDurableTopic");
            } catch (NamingException e) {
            try {
            topic = publisherSession.createTopic(TOPIC_NAME);
            ctx.bind(TOPIC_NAME, topic);
            }catch(JMSException jmsExp) {
            return "Could not set up JMS topic";
            }catch(NamingException ne) {
            }finally {
            try {
            if (ctx!=null) {
            }catch(Exception e) {
            return "Could not set up JMS topic";

            //If topic is not found return the error.
            if (topic == null) {
            return "Could not set up JMS topic";

            //Create the topic publisher
            try {
            topicPublisher = publisherSession.createPublisher(topic);
            } catch(JMSException e) {
            return "Could not set up JMS topic publisher";

            subscriberSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
            topicSubscriber = subscriberSession.createDurableSubscriber(topic, "subscriber-1");
            topicSubscriber.setMessageListener(new MyMessageListener());

            topicSubscriber = subscriberSession.createDurableSubscriber(topic, "subscriber-2");
            topicSubscriber.setMessageListener(new MyMessageListener());

            // publisher created;
            // all subscribers created;
            // now start connection
            try {
            catch(Exception e) {
            return "Could not start JMS connection";

            With the above code, I am able to send messages and receive asynchronously, but now my requirement is to have this
            JMS messages in Distributed transactions. Please clarify me on the following :

            1) If i use the same code as above, will this JMS participate in XA transactions ??

            2) But if i see jms-ds.xml, there is a XA resource adapter defined as below ...when should i use this ?

            <!-- JMS XA Resource adapter, use this to get transacted JMS in beans -->
            <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Topic</config-property>
            <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:/DefaultJMSProvider</config-property>

            3) Appreciate if you can provide sample code with configuration to have JMS Topic in Distributed transactions.


            • 3. Re: How to configure JMS Distributed Topic & Destinations in
              vakuthota Newbie

              Sorry In my previous posting...mbean instance in not printed...so sending again


              <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager
              <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager