2 Replies Latest reply on Apr 14, 2004 10:56 AM by sunh11373

    tibco JMS and JTA

    sunh11373

      Hi,

      Try to use tibco JMS with JTA, does anyone have experience?

      It seems that the session is not aware of the global transaction started by
      the JTA and always write to the destination queue.


      Here is a piece of code

      /**
      * @see javax.jms.MessageListener#onMessage(javax.jms.Message)
      */
      public void onMessage(Message msg) {
      try {

      TextMessage orderMsg = (TextMessage)msg;
      m_logger.info("Received Order from Queue: " + orderMsg.getText());

      QueueSender queueSender = m_queueSession.createSender(m_queue);
      TextMessage message = m_queueSession.createTextMessage();
      message.setText(orderMsg.getText() + "@" + System.currentTimeMillis());
      m_logger.info("Publishing message: " + message.getText());
      queueSender.send(message);
      queueSender.close();


      } catch (JMSException e) {
      e.printStackTrace();
      } catch (Exception ee) {
      ee.printStackTrace();
      }
      }

      /**
      * Creates the EJB object.
      *
      * @ejb:create-method
      */
      public void ejbCreate() {

      try {
      m_jndiContext = new InitialContext();
      m_queueFactory = (QueueConnectionFactory)m_jndiContext.lookup("tibjmsnaming://localhost/XAQueueConnectionFactory");
      m_queue = (Queue)m_jndiContext.lookup("tibjmsnaming://localhost/queue/EntitlementQueue");
      m_queueConnection = m_queueFactory.createQueueConnection();


      // I have tried "transactional flag = 'true' as well
      m_queueSession = m_queueConnection.createQueueSession(false,
      javax.jms.Session.AUTO_ACKNOWLEDGE);
      m_queueConnection.start();

      } catch (Exception ne) {
      throw new EJBException(ne);
      }
      }


      thanks

        • 1. Re: tibco JMS and JTA

          JTA integration is not automatic, you need to plug tibco's XAConnectionFactory
          in jboss's JMS resource adapter.

          There is an example in the FAQ topic at the top of this forum on
          how to configure a remote JBossMQ using JMSRA.
          "How do I access a remote jboss connection factory using a managed connection pool."

          What you will need to change is the way it accesses jndi.
          There are three ways to do this:

          1) Implement your own version of the ProviderAdapterClass
          org.jboss.jms.jndi.JBossMQProvider, which performs the jndi operations.
          If you look at the code you will find it is fairly trivial.
          http://cvs.sourceforge.net/viewcvs.py/jboss/jboss/src/main/org/jboss/jms/jndi/JBossMQProvider.java?rev=1.9&view=auto

          2) Bind tibco's jndi context into jboss's jndi context using the
          org.jboss.naming.ExternalContext mbean, you will see this discussed a lot
          in these forums or if you want to avoid the fumbling of a lot of posts
          it is better explained in the admin docs.
          http://cvs.sourceforge.net/viewcvs.py/jboss/jboss/src/main/org/jboss/naming/ExternalContext.java?rev=1.17&view=auto

          3) Use tibco specifc apis to bind their objects into jboss's jndi, there is an example
          of this for Oracle referenced in the FAQ topic. The same patch section on sourceforge
          contains an example for MQSeries/WebsphereMQ.

          Once you get this to work, please post back the working configuration.

          Regards,
          Adrian

          • 2. Re: tibco JMS and JTA
            sunh11373

            Hi,

            Thanks for the advise. I worked this out with your first suggestion. Will try others if I have time. Attached is the working configuration:

            ====== jms-ds.xml ===========
            .....

            <mbean code="org.jboss.jms.jndi.JMSProviderLoader"
             name="jboss.mq:service=JMSProviderLoader,name=TibjmsProvider">
            <attribute name="ProviderName">TIBCOJMSProvider</attribute>
            <attribute name="ProviderAdapterClass"> com.tibco.tibjms.appserver.jboss.JBossAdapter </attribute>
            <attribute name="QueueFactoryRef">BHXAQueueConnectionFactory</attribute>
            <attribute name="TopicFactoryRef">BHXATopicConnectionFactory</attribute>
            </mbean>
            
            <tx-connection-factory>
             <jndi-name>JmsXA</jndi-name>
             <xa-transaction/>
             <adapter-display-name>JMS Adapter</adapter-display-name>
             <config-property name="SessionDefaultType" type="java.lang.String">javax.jms.Topic</config-property>
             <config-property name="JmsProviderAdapterJNDI" type="java.lang.String">java:TIBCOJMSProvider</config-property>
             <security-domain-and-application>JmsXARealm</security-domain-and-application>
             </tx-connection-factory>
            

            .......


            ==============================

            Thanks for the support again

            hs