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

  1. 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:
  2.    > connect  
       > create queue queue/A  
       > create queue queue/B 
       > create queue queue/DLQ 
       > create factory XAQueueConnectionFactory xaqueue 
       > create factory XATopicConnectionFactory xatopic 
    
  3. Make a backup copy of the configuration files that will be changed:
  4.    %JBOSS_DEPLOY%\jms-service.xml  
       %JBOSS_CONF%\jboss-service.xml 
       %JBOSS_CONF%\jndi.properties  
       %JBOSS_CONF%\standardjboss.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.

  5. Add TIBCO Enterprise Message Service and the TIBCO Enterprise Message Service adapter class for JBoss to the CLASSPATH of the JBoss server by modifying the file described below. The value of the jar file paths should be modified for your installation.
Add the following line under the <server> element in jms-service.xml:
   <!-- TIBCO Enterprise Message Service classpath --> 
   <classpath codebase="file://C:\TIBCO\EMS\clients\java" 
              archives="tibjms.jar, tibjmsapps.jar" />  
  1. Remove the configuration that causes the JMSProviderLoader mbean to load JBoss MQ.
In the file jms-service.xml, remove the following lines:
<!-- The JMS provider loader -->  
<mbean code="org.jboss.jms.jndi.JMSProviderLoader"  
name="jboss.mq:service=JMSProviderLoader,name=JBossMQProvider">  
   <attribute name="ProviderName">DefaultJMSProvider</attribute>  
   <attribute name="ProviderAdapterClass">  
      org.jboss.jms.jndi.JBossMQProvider  
      </attribute>  
   <attribute name="QueueFactoryRef">java:/XAConnectionFactory</attribute>  
   <attribute name="TopicFactoryRef">java:/XAConnectionFactory</attribute>  
</mbean>  
 

Replace the removed lines with the following lines to cause JMSProviderLoader mbean to load TIBCO Enterprise Message Service:

In the file jms-service.xml add the following lines:
<!-- The JMS provider loader -->  
<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">XAQueueConnectionFactory</attribute>  
   <attribute name="TopicFactoryRef">XATopicConnectionFactory</attribute> 
</mbean>  
  1. When the sample MDB looks up the QueueConnectionFactory (in order to create a QueueSender to send a message back to the initiator), it looks it up as java:comp/env/jms/QCF. Because we want the QueueConnectionFactory object that is returned from the lookup to be a TIBCO Enterprise Message Service XAQueueConnectionFactory, we must store a JNDI LinkRef under that name in the JBoss JNDI implementation that points to the XAQueueConnectionFactory in the TIBCO Enterprise Message Service implementation. Adding the following lines in jms-service.xml accomplishes this.
  2. <!-- Redirect QueueConnectionFactory to TIBCO Enterprise Message Service -->  
    <mbean code="org.jboss.naming.NamingAlias" 
       name="DefaultDomain:service=NamingAlias,fromName=QueueConnectionFactory">  
       <attribute name="ToName">tibjmsnaming://localhost/XAQueueConnectionFactory  
          </attribute>  
       <attribute name="FromName">QueueConnectionFactory</attribute>  
    </mbean>  
    
  3. In jboss-service.xml, change the dependency of the EJB Deployer from JBossMQProvider to TibjmsProvider.
Change:
<depends>jboss.mq:service=JMSProviderLoader,name=JBossMQProvider</depends> 
To:
<depends>jboss.mq:service=JMSProviderLoader,name=TibjmsProvider</depends> 
  1. 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.n
aming  
  1. In the %JBOSS_CONF%\standardjboss.xml file, modify the following line. This sets "TIBCOJMSProvider" as the JMS Provider Adapter JNDI name:
Change:
   <JMSProviderAdapterJNDI>DefaultJMSProvider  
   </JMSProviderAdapterJNDI>  
To:
<JMSProviderAdapterJNDI>TIBCOJMSProvider  
   </JMSProviderAdapterJNDI>  
  1. In the %JBOSS_CONF%\standardjboss.xml file, modify the following line. This specifies the TIBCO Enterprise Message Service JNDI name for the MDB Dead Letter Queue (DLQ) queue/DLQ:
Change:
<DestinationQueue>queue/DLQ</DestinationQueue> 
To:
<DestinationQueue> 
   tibjmsnaming://localhost/queue/DLQ 
</DestinationQueue> 
  1. 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:
  2.    %JBOSS_DEPLOY%\jbossmq-service.xml 
       %JBOSS_DEPLOY%\jbossmq-destinations-service.xml 
    
  3. Stop and restart the JBoss server by entering:
  4.    run   
    
  5. 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:
  6. java.naming.factory.initial=com.tibco.tibjms.naming.TibjmsInitialContextFactory  
    
  7. Add C:\TIBCO\EMS\clients\java\tibjms.jar to the CLASSPATH of the client program.
  8. Run the client program as you did in the previous section. You should see the same output.

TIBCO Enterprise Message Service™ Application Integration Guide
Software Release 4.3, February 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com