[jboss-user] [JBoss Messaging] - JBoss7 integration with Tibco EMS using 'Generic JMS RA'

Yevgen Kravchenko do-not-reply at jboss.com
Fri Sep 14 12:26:21 EDT 2012


Yevgen Kravchenko [https://community.jboss.org/people/ykravchenko] modified the document:

"JBoss7 integration with Tibco EMS using 'Generic JMS RA'"

To view the document, visit: https://community.jboss.org/docs/DOC-47346

--------------------------------------------------------------
*Warning!* This solution might not be perfect, it's not fully tested so please use it on your own risk.
h3. Introduction
It turned out that old approaches to integrate Jboss with Tibco EMS (for example  https://community.jboss.org/docs/DOC-14734 this one) will not work for Jboss7. Now we need to use vendor provided Resource adapter (RA), but TibcoEMS is not providing one, what should we do? There is a number of forum threads (for example  https://community.jboss.org/message/730006#730006 here) requesting Jboss7 /Tibco EMS integration but none of them is giving a complete set of steps to follow.
In this article I'm going to share some ideas on how to configure Jboss7 to work with Tibco messaging.


h3. Generic JMS resource adapter
TibcoEMS is not providing resource adapter that we could use to integrate with Jboss7, that leaves us no choice but write our own Resource adapter. That is bright idea and will definitely work better then what will follow next, but creating custom RA is time consuming task. Instead of reinventing the wheel we could use  http://genericjmsra.java.net/ Generic JMS resource adapter.
However downloading generic resource adapter and deploying it to Jboss7 will not work, you'll most certainly fail with errors stated https://community.jboss.org/message/759055#759055?tstart=0  here. So you'll have to update generic jms ra alittle.
h4. Generic JMS RA project checkout
To checkout source code please follow this  http://java.net/projects/genericjmsra/sources link, if you don't want to update source yourself you could skip next parts of article and download updated genericra.rar from attachments.
Steps to configure ANT properties to build project are described  http://java.net/projects/genericjmsra/sources/svn/content/trunk/README.build.txt here.
h4. Fixing deployment errors
When deploying genericra.rar to Jboss7 you'll get 2 errors:
Description: An AdminObject must implement javax.resource.Referenceable and java.io.Serializable interfaces if javax.resource.spi.ResourceAdapterAssociation is implemented Code
Code: com.sun.genericra.outbound.QueueProxy

and 
Description: An AdminObject must implement javax.resource.Referenceable and java.io.Serializable interfaces if javax.resource.spi.ResourceAdapterAssociation is implemented Code
Code: com.sun.genericra.outbound.TopicProxy


The easiest fix you need to do - force 2 classes implement required interfaces. This is the example of QueueProxy that I came up with
public class QueueProxy extends DestinationAdapter implements javax.jms.Queue, Referenceable, Serializable {
 
        /* The rest of the code is skipped. This is what I've added in order for QueueProxy to be Referenceable*/ 
 
           private Reference reference;
 
          public void setReference(Reference reference) {
                    this.reference = reference;
          }
 
          public Reference getReference() throws NamingException {
                    return reference;
          }
}


Same should be done with TopicProxy as well. After this changes genericra.rar will deploy with no errors to Jboss7.
h4. Updating Generic JMS RA config
Next we need to change SupportsXA config property in ra.xml (genericra.rar/META-INF). It will cause an issue if you want to use it. In default config it's String while in Java code this property is Boolean. So we need to change from:
<config-property>
     <config-property-name>SupportsXA</config-property-name>
     <config-property-type>java.lang.String</config-property-type>
</config-property>

to:
<config-property>
     <config-property-name>SupportsXA</config-property-name>
     <config-property-type>java.lang.Boolean</config-property-type>
</config-property> 

Please note, that some other properties which cause warnings could be fixed too, but in my case I needed only SupportsXA from the list of "wrong configured by default" properties.


h3. Configure Tibco JMS client libraries in JBoss7
* Create the following folders structure *[Jboss7]\modules\com\tibco\tibjms\main*
* Copy *tibjms.jar* and *tibcrypt.jar* to *[Jboss7]\modules\com\tibco\tibjms\main*
* Create *module.xml* with the following content:
<module xmlns="urn:jboss:module:1.1" name="com.tibco.tibjms">

    <resources>
          <resource-root path="tibjms.jar"/>
          <resource-root path="tibcrypt.jar"/>
    </resources>

     <dependencies>
          <module name="javax.api"/>
          <module name="javax.jms.api"/>
    </dependencies>
</module>

* Open *[Jboss7]\modules\org\jboss\as\ee\main\module.xml* and add dependency to com.tibco.tibjms
<dependencies>

     <!-- Don't delete what was written here, just add com.tibco.tibjms at the bottom -->

     <module name="com.tibco.tibjms"/>
</dependencies>



h3. Configure Tibco EMS
In Tibco EMS create connection factory and queue that you would like to use. The following command in TibcoEMS Administrator tool will help you do that:
tcp://localhost:7222> create factory MyConnectionFactory xaqueue url=tcp://tibcohost:7222

And create queue:
tcp://localhost:7222> create queue MySampleQueue



h3. Configure Resource Adapter in Jboss7
Deploy genericra.rar - it should deploy fine without any exceptions. In the administrator console create new Resrouce Adapter providing archive name *genericra.rar*. Add following properties:

ProviderIntegrationMode=jndi
UserName=[Your Tibco EMS admin username]
Password=[Your Tibco EMS admin password]
JndiProperties=java.naming.factory.url.pkgs=com.tibco.tibjms.naming,java.naming.factory.initial=com.tibco.tibjms.naming.TibjmsInitialContextFactory,java.naming.provider.url=[Tibco host URL]:7222
SupportsXA=true
LogLevel=finest


Open standalone.xml ([Jboss7]\standalone\configuration\standalone.xml) and add the following lines in  <subsystem xmlns="urn:jboss:domain:ejb3:1.2">
<mdb>
     <resource-adapter-ref resource-adapter-name="genericra.rar"/>
     <bean-instance-pool-ref pool-name="mdb-strict-max-pool"/>
</mdb>



h3. Create Sample MDB
When creating MessageDriven beans you need to use org.jboss.ejb3.annotation.ResourceAdapter to let container know that you want to use external messaging provider. Please find below sample message driven bean that you could use to check that integration is working:

@MessageDriven(activationConfig = {
                    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
                    @ActivationConfigProperty(propertyName = "destinationJndiName", propertyValue = "MySampleQueue"),
                    @ActivationConfigProperty(propertyName = "connectionFactoryJndiName", propertyValue = "MyConnectionFactory"),
})
@ResourceAdapter("genericra.rar")
public class SampleMdb implements MessageListener {
 
 
          @Override
          public void onMessage(Message message) {
                    System.out.println("TibcoEMS integration is working!");
          }
}


To test that MDB is listening to TibcoEMS queue use this code:

@Test
public void testOnMessage() throws Exception {
     Properties properties = new Properties();
     properties.put("java.naming.factory.url.pkgs", "com.tibco.tibjms.naming");
     properties.put("java.naming.factory.initial", "com.tibco.tibjms.naming.TibjmsInitialContextFactory");
     properties.put("java.naming.provider.url", "tibcohost:7222");
 
     InitialContext context = new InitialContext(properties);
     ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("MyConnectionFactory");
     Connection connection = connectionFactory.createConnection();
     Destination destination = (Destination) context.lookup("MySampleQueue");
     Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
     MessageProducer producer = session.createProducer(destination);
     TextMessage message = session.createTextMessage();
     producer.send(message);
}



Hope this article is helpful.
Thanks,
Yevgen Kravchenko
--------------------------------------------------------------

Comment by going to Community
[https://community.jboss.org/docs/DOC-47346]

Create a new document in JBoss Messaging at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2042]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20120914/4bb5b39a/attachment-0001.html 


More information about the jboss-user mailing list