JBoss Community

JBossEAP5IntegrationwithTibcoEMS

modified by mattik in JBoss Messaging Development - View the full document

This article highlights some of the basic steps required to integrate JBoss EAP 5 with TibcoEMS. This article should also work with JBoss EAP 4.x, however, I have not tested tested this at this time.

 

Introduction

This article differs from:

IntegrationWithTibcoEMS

 

and the TibcoEMS administration documents in the following:

 

  • Does not replace and remove JBoss messaging from the JBoss Installation (JBoss messaging can still be removed, but this is optional since the DefaultJMSProvider has not been replaced)
  • Defines a TIBCOJMSProvider
  • Provides a DLQ configuration without changing standardjboss.xml and replacing the DefaultJMSProvider with TIBCOJMSProvider
  • Has been tested on JBoss EAP 5
  • Uses authentication with Tibco EMS

 

Credits

The content in this page is based on TibcoEMS documentation for JBoss4.x. Some of the content has also been borrowed from the article:

IntegrationWithTibcoEMS

 

including the sample mdb code for testing.

 

A special thanks to Marjono Reksopuro, Susanta Mondal and Michael McKernan for their help with Tibco Administration, integration and testing for this configuration.

TibcoEMS Configuration

The steps in this section outline the steps required to create a test queue on TibcoEMS as well as the DLQ.

 

* Please note this EMS configuration assumes the following:

- Authorization enabled
- Username/Password are set to: admin/admin 
- A single instance running locally:   localhost with port of 7222.
- If you need to have FT Pairs for failover, the url should be changed from   tcp://localhost:7222, tcp://localhost:7222  to  tcp://firstmachine:firstport,tcp://secondmachine:secondport

Step1

Start the tibemsd server and the tibemsadmin console.

Queues and Connection Factories

 

Step2

Create two queues (queue/myTestQueue and queue/DLQ) and two XA connection factories (TIBXAQueueConnectionFactory and TIBXATopicConnectionFactory), by entering the following commands in tibemsadmin:      
    > connect

 

    > create queue queue/myTestQueue

 

    > create queue queue/DLQ

 

    > create factory TIBXAQueueConnectionFactory xaqueue url=tcp://localhost:7222

 

    > create factory TIBXATopicConnectionFactory xatopic url= tcp://localhost:7222

 

Tibco pairs for Failover:

 

    > create factory TIBXAQueueConnectionFactory xaqueue url=tcp://localhost:7222, tcp://localhost:7222

 

    > create factory TIBXATopicConnectionFactory xatopic url= tcp://localhost:7222, tcp://localhost:7222

 

JBoss Configuration

The steps in this section outline the steps required to configure JBoss to connect withTibcoEMS.

Step1

Add TIBCO EMS and the TIBCO EMS adapter class for JBoss to the CLASSPATH of the JBoss server. There are two options to accomplish this:

 

Option1

Add the following lines under the <server> element in the file $JBOSS_HOME/jboss-as/server/myinstance/conf/jboss-service.xml:


<!-- TIBCO Enterprise Message Service classpath -->

<classpath codebase="file:/C:\tibco\ems\5.1\lib" archives="tibjms.jar" ></classpath>

 

Option2

Copy tibjms.jar file to:

$JBOSS_HOME/jboss-as/server/myinstance/lib

 

Step2

Create a new datasource file called tibco-jms-ds.xml or whatever name you prefer, and place it in:

$JBOSS_HOME/jboss-as/server/myinstance/deploy

 

And add the following contents to the file mentioned above:


<?xml version="1.0" encoding="UTF-8"?>
<connection-factories>

<!-- The Tibco 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">TIBXAQueueConnectionFactory</attribute>
      <attribute name="TopicFactoryRef">TIBXATopicConnectionFactory</attribute>
      <attribute name="Properties">
                java.naming.security.principal=admin
                java.naming.security.credentials=admin
                java.naming.factory.initial=com.tibco.tibjms.naming.TibjmsInitialContextFactory
                java.naming.factory.url.pkgs=com.tibco.tibjms.naming
                java.naming.provider.url=tcp://localhost:7222
      </attribute>
</mbean>

<!-- JMS XA Resource adapter, use this to get transacted JMS in beans -->
<tx-connection-factory>
     <jndi-name>TibcoXA</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.Queue</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>TibcoXARealm</security-domain-and-application>
</tx-connection-factory>
</connection-factories>




Step3

Notice that a security domain reference is present in the tibco-jms-ds.xml file. Therefore, modify the file $JBOSS_HOME/jboss-as/server/myinstance/conf/login-config.xml file as follows and add the TibcoXARealm within the <properties> element:

 

<application-policy name="TibcoXARealm">
  <authentication>
      <login-module code="org.jboss.resource.security.ConfiguredIdentityLoginModule" flag="required">
        <module-option name="principal">admin</module-option>
        <module-option name="userName">admin</module-option>
        <module-option name="password">admin</module-option>
        <module-option name="managedConnectionFactoryName">jboss.jca:service=TxCM,name=TibcoXA</module-option>
      </login-module>
    </authentication>
</application-policy>

Step4

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_HOME/jboss-as/server/myinstance/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

 

 

When Using a Client

Step1

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

 

Step2

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

 

MDB configuration

The sample mdb code from can be used:

IntegrationWithTibcoEMS

 

 

Update your jboss.xml file to look as follows:

 

<?xml version="1.0"?>
<jboss>
   <resource-managers>
     <resource-manager>        

       <res-name>queuefactoryref</res-name>
       <res-jndi-name>java:/TibcoXA</res-jndi-name>
     </resource-manager>
   </resource-managers>
   <enterprise-beans>
     <message-driven>
       <ejb-name>SampleMDB</ejb-name>
       <configuration-name>Tibco Message Driven Bean</configuration-name>
       <destination-jndi-name>queue/myTestQueue</destination-jndi-name>
       <mdb-user>admin</mdb-user>
       <mdb-passwd>admin</mdb-passwd>
       <resource-ref>
         <res-ref-name>jms/QCF</res-ref-name>
         <resource-name>queuefactoryref</resource-name>
       </resource-ref>
     </message-driven>
   </enterprise-beans>

 
   <!-- container configuration for Tibco EMS -->
   <container-configurations>
     <container-configuration extends="Standard Message Driven Bean">
       <container-name>Tibco Message Driven Bean</container-name>
       <invoker-proxy-binding-name>tibco-message-driven-bean</invoker-proxy-binding-name>
     </container-configuration>
   </container-configurations>
 
   <!-- The JmsProviderAdapterJNDI must match the ProviderName in SERVER_HOME/deploy/tibco-jms-ds.xml file. -->    

   <invoker-proxy-bindings>
     <invoker-proxy-binding>
       <name>tibco-message-driven-bean</name>
       <invoker-mbean>default</invoker-mbean>
       <proxy-factory>org.jboss.ejb.plugins.jms.JMSContainerInvoker</proxy-factory>
         <proxy-factory-config>
           <JMSProviderAdapterJNDI>TIBCOJMSProvider</JMSProviderAdapterJNDI>
           <ServerSessionPoolFactoryJNDI>StdJMSPool</ServerSessionPoolFactoryJNDI>
           <MinimumSize>1</MinimumSize>
           <MaximumSize>15</MaximumSize>
           <KeepAliveMillis>30000</KeepAliveMillis>
           <MaxMessages>1</MaxMessages>
           <MDBConfig>
             <ReconnectIntervalSec>10</ReconnectIntervalSec>
             <DLQConfig>
               <DestinationQueue>queue/DLQ</DestinationQueue>
               <MaxTimesRedelivered>10</MaxTimesRedelivered>
               <TimeToLive>0</TimeToLive>
               <DLQUser>admin</DLQUser>
               <DLQPassword>admin</DLQPassword>
             </DLQConfig>
           </MDBConfig>
         </proxy-factory-config></proxy-factory>
       </invoker-proxy-binding>
     </invoker-proxy-bindings>
</jboss>

 

*Note: The above configuration uses an EJB2 configuration, for EJB3 the following annotations can be used:

@ActivationConfigProperty(propertyName="providerAdapterJNDI", propertyValue="java:/TIBCOJMSProvider"),
@ActivationConfigProperty(propertyName="DLQJNDIName", propertyValue="queue/DLQ"),
@ActivationConfigProperty(propertyName="DLQUser", propertyValue="admin"),
@ActivationConfigProperty(propertyName="DLQPassword",propertyValue="admin")

 

Upon a restart of the JBoss instance, you shold have a working configuration.

 

----------------------- Below this line added by matti.kaikkonen@teliasonera.com Sept 13, 2012 --------------------------------

MDB Configuration with Automatic Reconnection

 

If you have had a problem with your JMS clients not reconnecting after bouncing EMS or losing network connection then you want to look into this option. The problem here is that the number of times to attempt to reconnect to the JMS provider needs a new property "reconnectAttempts" and by default it is 5.  This property is available from JBoss Application 5 GA.  Prior to this version, reconnection attempts were infinite by default. In the above format it is not possible to define the reconnectAttempts. I have tested this with JBoss 5.1.0GA.

 

Update your jboss.xml file to look as follows - replace the invoker-proxy-binding block with following. Look here for documentation.

 

<invoker-proxy-binding>
    <name>tibco-message-driven-bean</name>
    <invoker-mbean>default</invoker-mbean>
    <proxy-factory>org.jboss.ejb.plugins.inflow.JBossJMSMessageEndpointFactory</proxy-factory>
    <proxy-factory-config>
        <activation-config>
            <activation-config-property>
                <activation-config-property-name>providerAdapterJNDI</activation-config-property-name>
                <activation-config-property-value>TIBCOJMSProvider</activation-config-property-value>
            </activation-config-property>
            <activation-config-property>
                <activation-config-property-name>minSession</activation-config-property-name>
                <activation-config-property-value>1</activation-config-property-value>
            </activation-config-property>
            <activation-config-property>
                <activation-config-property-name>maxSession</activation-config-property-name>
                <activation-config-property-value>15</activation-config-property-value>
            </activation-config-property>
            <activation-config-property>
                <activation-config-property-name>keepAlive</activation-config-property-name>
                <activation-config-property-value>30000</activation-config-property-value>
            </activation-config-property>
            <activation-config-property>
                <activation-config-property-name>maxMessages</activation-config-property-name>
                <activation-config-property-value>1</activation-config-property-value>
            </activation-config-property>
            <activation-config-property>
                <activation-config-property-name>reconnectInterval</activation-config-property-name>
                <activation-config-property-value>10</activation-config-property-value>
            </activation-config-property>
            <activation-config-property>
                <activation-config-property-name>reconnectAttempts</activation-config-property-name>
                <activation-config-property-value>1000000</activation-config-property-value>
            </activation-config-property>
            <activation-config-property>
                <activation-config-property-name>useDLQ</activation-config-property-name>
                <activation-config-property-value>true</activation-config-property-value>
            </activation-config-property>
            <activation-config-property>
                <activation-config-property-name>DLQHandler</activation-config-property-name>
                <activation-config-property-value>org.jboss.resource.adapter.jms.inflow.dlq.GenericDLQHandler</activation-config-property-value>
            </activation-config-property>
            <activation-config-property>
                <activation-config-property-name>DLQJNDIName</activation-config-property-name>
                <activation-config-property-value>queue/DLQ</activation-config-property-value>
            </activation-config-property>
            <activation-config-property>
                <activation-config-property-name>DLQUser</activation-config-property-name>
                <activation-config-property-value>admin</activation-config-property-value>
            </activation-config-property>
            <activation-config-property>
                <activation-config-property-name>DLQPassword</activation-config-property-name>
                <activation-config-property-value>admin</activation-config-property-value>
            </activation-config-property>
            <activation-config-property>
                <activation-config-property-name>DLQMaxResent</activation-config-property-name>
                <activation-config-property-value>10</activation-config-property-value>
            </activation-config-property>
        </activation-config>
        <endpoint-interceptors>
            <interceptor>org.jboss.proxy.ClientMethodInterceptor</interceptor>
            <interceptor>org.jboss.ejb.plugins.inflow.MessageEndpointInterceptor</interceptor>
            <interceptor>org.jboss.proxy.TransactionInterceptor</interceptor>
            <interceptor>org.jboss.invocation.InvokerInterceptor</interceptor>
        </endpoint-interceptors>
    </proxy-factory-config>
</invoker-proxy-binding>

 

How to make the sample mdb code fully recover from JMS connection issues?

With the above change we have taken care of the message listener part so that the onMessage works after a disconnect. But the sendReply doesn't recover without some extra code. You need to catch the JMSException when sending the reply, and first close the session and connection (look at the ejbRemove), and then reconnect again (look at setup) before retrying to send the reply message.

 

How to use a durable topic subscriber instead for the mdb?

 

To use the sample mdb code (change also reply to destination from queue to topic) you just need to change all references to queues to topics. That's not a problem. The configuration of jboss.xml and ejb-jar.xml is the trickier part. In the jboss.xml replace <resource-managers> and <enterprise-beans> blocks with following. This is tested with JBoss 5.1.0GA.

 

 

<resource-managers>
        <resource-manager>        
            <res-name>topicfactoryref</res-name>
            <res-jndi-name>java:/TibcoXA</res-jndi-name>
        </resource-manager>
</resource-managers>
<enterprise-beans>
        <message-driven>
            <ejb-name>SampleMDB</ejb-name>
            <configuration-name>Tibco Message Driven Bean</configuration-name>
            <destination-jndi-name>topic/B</destination-jndi-name>
            <mdb-user>admin</mdb-user>
            <mdb-passwd>admin</mdb-passwd>
            <mdb-subscription-id>SampleMDB</mdb-subscription-id>
            <mdb-client-id>123</mdb-client-id>
            <resource-ref>
                <res-ref-name>jms/TCF</res-ref-name>
                <resource-name>topicfactoryref</resource-name>
            </resource-ref>
        </message-driven>
</enterprise-beans>

 

 

And the following replaces the original ejb-jar.xml.

 

 

<?xml version="1.0"?>
<!DOCTYPE ejb-jar
   PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"
   "http://java.sun.com/dtd/ejb-jar_2_0.dtd">

<ejb-jar>
    <enterprise-beans>
        <message-driven>
            <ejb-name>SampleMDB</ejb-name>
            <ejb-class>com.unisys.tibcojboss.mdb.SampleMDB</ejb-class>
            <transaction-type>Container</transaction-type>
            <acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
            <message-driven-destination>
                <destination-type>javax.jms.Topic</destination-type>
                <subscription-durability>Durable</subscription-durability>
            </message-driven-destination>
            <resource-ref>
                <res-ref-name>jms/TCF</res-ref-name>
                <res-type>javax.jms.TopicConnectionFactory</res-type>
                <res-auth>Container</res-auth>
            </resource-ref>
        </message-driven>
    </enterprise-beans>
</ejb-jar>

Comment by going to Community

Create a new document in JBoss Messaging Development at Community