This tutorial shows how to configure a Resource Adapter on JBoss AS 7. The purpose of it, is connecting your MDB on another JMS provider (OpenMQ).
What is a Resource Adapter ? to keep it simple, imagine a resource adapter something analogous to a JDBC driver. Both provide a standard API through which an application can access a resource that is outside the JEE server. For a resource adapter, the outside resource is an EIS (Enterprise Information system) and allows a standard way for EIS vendor's software to be integrated with JEE applications; on the other hand for a JDBC driver, it is a DBMS(Database Management System).
A resource adapter is stored in a RAR (Resource Adapter Archive) file and may be deployed on any JEE server, much like the EAR file of a JEE application.
In this tutorial we will show how to configure a resource adapter for connecting with glassfish's OpenMQ messaging system. So the first step is getting the OpenMQ RA. This one can be downloaded from http://mq.java.net/downloads.html or you can get it bundled into Glassfish distribution (under the folder "GLASSFISH_HOME\mq\lib" ).
So , once you have got the file imqjmsra.rar unzip it with a common unzip tool.
As you can see, in the root folder you can find all the JARs which are used by OpenMQ and the Glassfish's naming context interfaces. In the META-INF folder there's the ra.xml file which contains all the information required to configure the Resource Adapter.
Now we need to configure the resource on JBoss AS 7: how can we do that ? JBoss AS 7 uses IronJacamar as JCA implementation.
The subsystem is contained into the AS 7 configuration file:
Now, the simplest way to create your resource adapter configuration is via the rar-info tool contained into the ironjacamar-1.x\doc\as folder. ( The official IronJacamar project page is http://www.jboss.org/ironjacamar/ where you can download the software) .
The information about the resource adapter is generated using the following command:
This will generate a report file named imqjmsra-report.txt. This is the most important part of the report:
We need applying just a little change to this XML: get rid of the resource-adapters and resource-adapter and archive root elements and replace them with the <ironjacamar> element as follows:
Deploying the Resource Adapter file (ironjacamar.xml)
The simplest way to deploy the Resource Adapter is using an exploded directory which will contain all the configuration files: create a dir named imqjmsra.rar and save the file created with rar-info under the META-INF folder of it, with the name ironjacamar.xml
Next step are Resource Adapter libraries : since you might want to deploy remote JMS clients (using OpenMQ JNDI) it's better to install them as module so also other applications can use them.
Create the path modules\com\sun\openmq\main under your installation. There add the JAR files contained into imqjmsra.rar and configure the module in module.xml:
Fine, now let's return to our exploded folder and let's add the module dependency in MANIFEST.MF
Dependencies: com.sun.openmq export
So this will be our imqjmsra.rar which will just contains three files into the META-INF folder:
So, when things go OK we should have finished with the resource adapter configuration. All we need is deploying the resource adapter into JBoss AS 7.
Unfortunately installing the RA took a lot more of headaches, since the OpenMQ RA does not seem 100% conform to ActivationSpec. But we fixed and with huge pleasure we managed to get it working!