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 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:
  4.    %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.

  5. 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.
  6. Add the following lines under the <server> element in the file %JBOSS_CONF%\jboss-service.xml:

    <!-- TIBCO Enterprise Message Service classpath -->  
       <classpath codebase="file:/C:\TIBCO\EMS\clients\java"  
          archives="tibjms.jar" /> 
    
  7. 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:
  8.  
    <!-- 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> 
    
  9. 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 %JBOSS_DEPLOY%\jms\jms-ds.xml accomplishes this.
  10. <!-- 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> 
    
  11. When the SendRecvClient test program looks up the ConnectionFactory referenced in the test program, it needs to be redirected to the appropriate QueueConnectionFactory configured in EMS. Add the following lines in %JBOSS_DEPLOY%\jms\jms-ds.xml to accomplish this.
  12. <mbean code="org.jboss.naming.NamingAlias" 
        name="DefaultDomain:service=NamingAlias,fromName=ConnectionFactory"> 
         <attribute name="ToName">tibjmsnaming://localhost/QueueConnectionFactory 
         </attribute> 
         <attribute name="FromName">ConnectionFactory</attribute> 
      </mbean> 
    
  13. 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.
Change:
   <JMSProviderAdapterJNDI>DefaultJMSProvider  
   </JMSProviderAdapterJNDI>  
To:
<JMSProviderAdapterJNDI>TIBCOJMSProvider  
   </JMSProviderAdapterJNDI>  

This change sets "TIBCOJMSProvider" as the JMS Provider Adapter JNDI name.

  1. In the %JBOSS_CONF%\standardjboss.xml file, modify the following line.
Change:
<DestinationQueue>queue/DLQ</DestinationQueue> 
To:
<DestinationQueue> 
   tibjmsnaming://localhost/queue/DLQ 
</DestinationQueue> 

This change specifies the TIBCO Enterprise Message Service JNDI name for the MDB Dead Letter Queue (DLQ) queue/DLQ.

  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%\jms\jbossmq-service.xml  
       %JBOSS_DEPLOY%\jms\jbossmq-destinations-service.xml 
    
  3. Stop the JBoss server, then it restart 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