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

    How to configure JMS Distributed Topic & Destinations in JBo

      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...

      thanks
      Venu


        • 1. Re: How to configure JMS Distributed Topic & Destinations in
          kconner

          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.

          Kev

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

            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 -->

            DefaultJMSProvider

            org.jboss.jms.jndi.JNDIProviderAdapter

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

            java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
            java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
            java.naming.provider.url=localhost:1100

            -->



            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();
            topicConnection.setClientID("venuTopicConnection");
            publisherSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
            }catch(NamingException e) {
            e.printStackTrace();
            return "Could not set up JMS clients";
            }catch(JMSException e) {
            e.printStackTrace();
            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) {
            jmsExp.printStackTrace();
            return "Could not set up JMS topic";
            }catch(NamingException ne) {
            ne.printStackTrace();
            }
            }finally {
            try {
            if (ctx!=null) {
            ctx.close();
            }
            }catch(Exception e) {
            e.printStackTrace();
            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) {
            e.printStackTrace();
            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 {
            topicConnection.start();
            }
            catch(Exception e) {
            e.printStackTrace();
            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 -->
            <tx-connection-factory>
            <jndi-name>JmsXA</jndi-name>
            <xa-transaction/>
            <rar-name>jms-ra.rar</rar-name>
            <connection-definition>org.jboss.resource.adapter.jms.JmsConnectionFactory</connection-definition>
            <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>
            <max-pool-size>20</max-pool-size>
            <security-domain-and-application>JmsXARealm</security-domain-and-application>
            </tx-connection-factory>


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


            Thanks


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

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

              venu-destinations-service.xml:


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