> Get the Example MDB Working Using TIBCO Enterprise Message Service

> | This example MDB uses container-managed transactions. For more information, see Container-Managed Transactions (XA).

> 1. | Start the tibemsd server and the tibemsadmin console.

> Queues and Connection Factories

> 2. | Create three queues (queue/A, queue/B and queue/DLQ) and two XA connection factories (XAQueueConnectionFactory and XATopicConnectionFactory), by entering the following commands in tibemsadmin:

> > connect
> > create queue queue/A
> > create queue queue/B
> > create queue queue/DLQ
> > create factory XAQueueConnectionFactory xaqueue url=tcp://7222
> > create factory XATopicConnectionFactory xatopic url=tcp://7222

> 3. | Make a backup copy (in a separate directory) of the configuration files that will be changed:

> %JBOSS_DEPLOY%\jms\jms-ds.xml
> %JBOSS_CONF%\jboss-service.xml
> %JBOSS_CONF%\standardjboss.xml
> <mdb-output>\META-INF\jboss.xml

> | You should copy the files in the %JBOSS_DEPLOY% directory to another directory, rather than rename the files in place. JBoss attempts to deploy all files in that directory, regardless of name or file extension.

> 4. | Add TIBCO EMS and the TIBCO EMS adapter class for JBoss to the CLASSPATH of the JBoss server by modifying the file %JBOSS_CONF%\jboss-service.xml as described below. Substitute an appropriate JAR file CLASSPATH for your installation.

> Add the following lines under the <server> element in the file %JBOSS_CONF%\jboss-service.xml:
> <!-- TIBCO Enterprise Message Service classpath -->
> <classpath codebase="file:/EMS_HOME\lib"
> archives="tibjms.jar" />

> 5. | Reconfigure the JMSProviderLoader mbean to load TIBCO Enterprise Message Service instead of JBoss MQ. To do so, edit the file %JBOSS_DEPLOY%\jms\jms-ds.xml to resemble these lines:

> <!-- The JMS provider loader -->
> <mbean code="org.jboss.jms.jndi.JMSProviderLoader" name=":service=JMSProviderLoader,name=TibjmsProvider">
> <attribute name="ProviderName">TIBCOJMSProvider</attribute>
> <attribute name="ProviderAdapterClass">org.jboss.jms.jndi.JNDIProviderAdapter</attribute>
> <attribute name="QueueFactoryRef">XAQueueConnectionFactory</attribute>
> <attribute name="TopicFactoryRef">XATopicConnectionFactory</attribute>
> <attribute name="Properties">
> java.naming.security.principal=jbosslookup
> java.naming.security.credentials=jbosslookup
> java.naming.factory.initial=com.tibco.tibjms.naming.TibjmsInitialContextFactory
> java.naming.factory.url.pkgs=com.tibco.tibjms.naming
> java.naming.provider.url=tibjmsnaming://localhost:7222
> </attribute>
> </mbean>

> 6. | Add the TIBCO Enterprise Message Service as the JMS provider for the connection factory. To do so, edit the file %JBOSS_DEPLOY%\jms\jms-ds.xml to change the JmsProviderAdapterJNDI property in the JMS XA Resource adapter to TIBCOJMSProvider. It should resemble these lines:

> <!-- 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:/TIBCOJMSProvider</config-property>
> <max-pool-size>20</max-pool-size>
> <security-domain-and-application>JmsXARealm</security-domain-and-application>
> </tx-connection-factory>

> 7. | Reconfigure the MDB to use the queue connection factory reference for TIBCO Enterprise Message Service. To do so, edit the file <mdb-output>\META-INF\jboss.xml as shown:

> Change:
> <jboss>
> <enterprise-beans>
> <message-driven>
> <ejb-name>TextMDB</ejb-name>
> <destination-jndi-name>queue/B</destination-jndi-name>
> <resource-ref>
> <res-ref-name>jms/QCF</res-ref-name>
> <jndi-name>ConnectionFactory</jndi-name>
> </resource-ref>
> </message-driven>
> </enterprise-beans>
> </jboss>
> To:
> <jboss>
> <resource-managers>
> <resource-manager>
> <res-name>queuefactoryref</res-name>
> <res-jndi-name>java:/JmsXA</res-jndi-name>
> </resource-manager>
> </resource-managers>
> <enterprise-beans>
> <message-driven>
> <ejb-name>TextMDB</ejb-name>
> <destination-jndi-name>queue/B</destination-jndi-name>
> <mdb-user>MDBUser</mdb-user>
> <mdb-passwd>MDBPassword</mdb-passwd>
> <resource-ref>
> <res-ref-name>jms/QCF</res-ref-name>
> <resource-name>queuefactoryref</resource-name>
> </resource-ref>
> </message-driven>
> </enterprise-beans>
> </jboss>
> This change modifies the MDB to use the queue connection factory for EMS. MDBUser and MDBPassword are used to authenticate the MDB user when it connects to the EMS server. If authorization is disabled in the server, the MDBUser and Password lines can be omitted.

> 8. | When the JBoss server invokes JNDI and encounters the tibjmsnaming scheme, the server must be able to find the TIBCO Enterprise Message Service URLConnectionFactory. Therefore, modify the file %JBOSS_CONF%\jndi.properties as follows:

> Change:
> java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
> To
> java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces:com.tibco.tibjms.naming

> 9. | In the %JBOSS_CONF%\standardjboss.xml file, modify the following line.

> Change:
> <JMSProviderAdapterJNDI>DefaultJMSProvider
> </JMSProviderAdapterJNDI>
> To:
> <JMSProviderAdapterJNDI>TIBCOJMSProvider
> </JMSProviderAdapterJNDI>
> This change sets "TIBCOJMSProvider" as the JMS Provider Adapter JNDI name.

> 10. | Move the following files out of the %JBOSS_DEPLOY% directory. These files are not needed when using TIBCO Enterprise Message Service and therefore must not be deployed:

> %JBOSS_DEPLOY%\jms\jbossmq-service.xml
> %JBOSS_DEPLOY%\jms\jbossmq-destinations-service.xml

> 11. | Stop the JBoss server, then it restart by entering:

> run

> 12. | When the client program invokes JNDI, it should use the TIBCO Enterprise Message Service JNDI server. Modify %JBOSS_CLIENT%\jndi.properties to use TIBCO Enterprise Message Service JNDI by setting the following property:

> java.naming.factory.initial=com.tibco.tibjms.naming.TibjmsInitialContextFactory

> 13. | Add EMS_HOME\lib\tibjms.jar to the CLASSPATH of the client program.

> 14. | Run the client program as you did in the previous section. You should see the same output.

Copyright © TIBCO Software Inc. All Rights Reserved.