You are on page 1of 10

How to configure JBoss with MQ

Introduction
This document describes the integration with Web Sphere MQ Series from any J2EE 1.4 compliant application server without custom integration code with the help of JCA 1.5 compliant resource adapter provided by IBM.
Web Sphere MQ implements the industry standard java Message Service (JMS) interface.

Assumptions
This document describes many concepts and prerequisite knowledge of the following is considered essential:
l

jBoss Application Server 4 or later

IBM Web Sphere MQ Server 7

Java Standard Edition

Java Enterprise Edition


l

JCA

MDB

J2EE application servers

JMS

jBoss Application Server setup usually comes as jboss-VERSION. packages which can be easily extracted to any desired location.

Configurations to Use WebSphere MQ Server as JMS Resource Provider


Step 1: Installing and Configuring WebSphere MQ Server
Install WebSphere MQ Server 7 using custom option. During the product selection phase we need to make sure Java Extended Transaction
option under Java and Web Services section is also selected to install XA-Transaction support for MQ Server which will be required later.
Upon successful installation of MQ Server we will see

icon in our system tray which indicates that MQ Server up and running.

Step 2: Creating Queue Manager


As a first step of our configuration we need to create a Queue Manager. Open a command prompt and navigate to the bin directory which can
be found under WebSphere_MQ_Install_Dir. We can create queue manager by executing following command;

Description: Above command will create a queue manager called T24QM.


Step 3: Starting Queue manager
To start the queue manager issue the following command;

Step 4: Creating Queues

Quick Guide to Jboss with MQ- Release R13.00 -Page 2 of 10 - (c) Temenos Systems 2013 05/07/2013

Once the queue manager is up and running User needs to create some local queue (physical destinations) where messages will get stored. To
create queues issue the following command;

Description: First we have to enter into MQSC shell (where we can manipulate our queue manager settings) then we create our queues. Above
two define statement will create t24OFSQueue and t24OFSReplyQueue destinations into queue manager T24QM. While defining queues if
the queen names are not given inside quotes () then it will be created in Uppercase.
To exit from MQSC shell just type end and hit return.
Step 5: Starting MQ Listener
Finally we need to start a MQ listener for the queue manager to communicate with outside world, MQ listener can be started by executing following command;

Description: Above command will start MQ listener for queue manager (-m) T24QM, on port (-p) 1415 and transport protocol will be used (t) TCP.
After creating Queue manager, Queues and starting listener, following components need to be deployed in jboss Application server.
1) wmq.jmsra.rar
2) tocfT24ra-ra.rar
3) tocfOFSmessage-ejb.jar
4) mq-ds.xml
5) t24-ds.xml
6) ibmmq-destinations-service.xml
7) BrowserWeb.War
8) netty-3.2.4.jar

Configuration of Jboss Application server


Step 1: Deploying WebSphere MQ JCA Adaptor
To configure jBoss Application Server to communicate with the WebSphere MQ Server deploy a WebSphere MQ JMS Adaptor called
wmq.jmsra.rar from WebSphere_MQ_HOME/java/lib/jca directory to [JbossInstallDirectory]\server\default\deploy]directory.

Quick Guide to Jboss with MQ- Release R13.00 -Page 3 of 10 - (c) Temenos Systems 2013 05/07/2013

Step 2: Deploying WebSphere MQ Connection Factory


Jboss application server will use the WMQ connection factory to connect to WebSphere MQ Server so we need to copy following file into
[JbossInstallDirectory]\server\default\deploy]directory;
mq-ds.xml

?xml version="1.0" encoding="utf-8"?>


<connection-factories>
<tx-connection-factory>
<jndi-name>wmq/myFC</jndi-name>
<xa-transaction>true</xa-transaction>
<rar-name>wmq.jmsra.rar</rar-name>
<connection-definition>javax.jms.ConnectionFactory</connection-definition>
<config-property name="hostName" type="java.lang.String">127.0.0.1</config-property>
<config-property name="port" type="java.lang.String">1415</config-property>
<config-property name="queueManager" type="java.lang.String">T24QM</config-property>
<max-pool-size>20</max-pool-size>
</tx-connection-factory>

</connection-factories>

Step 3: Deploying ibmmq-destinations-service.xml


As soon as we have deployed the above connection factory successfully, we can now reference WebSphere MQ Server local queues for our application.
Copy ibmmq-destinations-service.xml file into [JbossInstallDirectory]\server\default\deploy]directory which should look similar to the one
below;

Ibmmq-destinations-service.xml

<server>
<mbean code="org.jboss.resource.deployment.AdminObject"
service=WASDestination,name=t24OFSQueue">

name="jboss.jca:-

<depends optional-attribute-name="RARName">
jboss.jca:service=RARDeployment,name='wmq.jmsra.rar'</depends>
<attribute name="JNDIName">queue/t24OFSQueue</attribute>
<attribute name="Type">javax.jms.Queue</attribute>
<attribute name="Properties">
baseQueueManagerName=T24QM
baseQueueName=t24OFSQueue
</attribute>
</mbean>
< mbean code="org.jboss.resource.deployment.AdminObject"
service=WASDestination,name=t24OFSReplyQueue">
<depends

name="jboss.jca:-

optional-attribute-name="RARName">
jboss.jca:service=RARDeployment,name='wmq.jmsra.rar'</depends>

Quick Guide to Jboss with MQ- Release R13.00 -Page 4 of 10 - (c) Temenos Systems 2013 05/07/2013

<attribute name="JNDIName">queue/t24OFSReplyQueue</attribute>
<attribute name="Type">javax.jms.Queue</attribute>
<attribute name="Properties">
baseQueueManagerName=T24QM
baseQueueName=t24OFSReplyQueue
</attribute>
</mbean>

</server>

Step 4: Deploying TOCF (EE) [ofsmessage-ejb.jar]


As we know that TOCF (EE) is composed of four modules i.e. OFSListener, OFSMessage, OFSDelivery and TOCFPLUGIN. If we deploy
complete package it will result in many exceptions and errors on application server as each module require some specific configurations. For
this example we only require OFSMessage module. So we only extract ofsmessage-ejb.jar and tocfcommon.jar from package. Copy tocfcommon.jar and netty-4.2.3.jar file on [JbossInstallDirectory]\server\default \lib directory. Then copy ofsmessage-ejb.jar in file into [JbossInstallDirectory]\server\default\deploy directory with following contents in ejb.jar.xml and jboss.xml.
ejb-jar.xml

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


<ejb- jar id="EJBJar_ OfsMessageMDB" version="2.1" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd">
<display-name>OFSMessage</display-name>
<enterprise-beans>
<message-driven id="MessageDriven_OfsMessageMDB">
<display-name>OFSMessage Bean</display-name>
<ejb-name>OFSMessageMDB</ejb-name>
<ejb-class>com.temenos.tocf.ofsmessage.mdb.OFSMessageMDB</ejb-class>
<messaging-type>javax.jms.MessageListener</messaging-type>
<transaction-type>Bean</transaction-type>
<message-destination-type>javax.jms.Queue</message-destination-type>
<activation-config>
<activation-config-property>
<activation-config-property-name>destination</activation-config-property-name>
<activation-config-property-value>t24OFSQueue</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>destinationType</activation-config-property-name>
<activation-config-property-value>javax.jms.Queue</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>useJNDI</activation-config-property-name>
<activation-config-property-value>false</activation-config-property-value>
</activation-config-property>
<activation-config-property>

Quick Guide to Jboss with MQ- Release R13.00 -Page 5 of 10 - (c) Temenos Systems 2013 05/07/2013

<activation-config-property-name>hostName</activation-config-property-name>
<activation-config-property-value>127.0.0.1</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>port</activation-config-property-name>
<activation-config-property-value>1415</activation-config-property-value>
</activation-config-property>
<activation-config-property>
<activation-config-property-name>queueManager</activation-config-property-name>
<activation-config-property-value>T24QM</activation-config-property-value>
</activation-config-property>
</activation-config>
<resource-ref id="ResourceRef_jmsQueueConnectionFactory">
<description>T24 Queue Connection Factory</description>
<res-ref-name>jms/jmsConnectionFactory</res-ref-name>
<res-type>javax.jms.QueueConnectionFactory</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref id="ResourceRef_t24ConnectionFactory">
<description>T24 JCA Connection Factory</description>
<res-ref-name>eis/t24ConnectionFactory</res-ref-name>
<res-type>com.temenos.tocf.t24ra.T24ConnectionFactory</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<resource-ref id="ResourceRef_t24OFSReplyQueue">
<description>OFS reply queue</description>
<res-ref-name>queue/t24OFSReplyQueue</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</message-driven>
</enterprise-beans>
<container-transaction>
<method>
<ejb-name>OFSMessageMDB</ejb-name>
<method-name>*</method-name>
</method>
<!-- NotSupported|Supports|Required|RequiresNew|Mandatory|Never -->
<trans-attribute>Required</trans-attribute>
</container-transaction>

</ejb-jar>

Jboss.xml

Quick Guide to Jboss with MQ- Release R13.00 -Page 6 of 10 - (c) Temenos Systems 2013 05/07/2013

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


<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 4.0//EN"
"http://www.jboss.org/j2ee/dtd/jboss_4_0.dtd">
<jboss>
<enterprise-beans>
<message-driven>
<resource-adapter-name>wmq.jmsra.rar</resource-adapter-name>
<ejb-name>OFSMessageMDB</ejb-name>
<configuration-name>Standard Message Inflow Driven Bean</configuration-name>
<destination-jndi-name>queue/t24OFSQueue</destination-jndi-name>
<resource-ref>
<res-ref-name>jms/jmsConnectionFactory</res-ref-name>
<!--<jndi-name>java:/ConnectionFactory</jndi-name>-->
<jndi-name>java:wmq/myFC</jndi-name>
</resource-ref>
<resource-ref>
<res-ref-name>queue/t24OFSReplyQueue</res-ref-name>
<jndi-name>queue/t24OFSReplyQueue</jndi-name>
</resource-ref>
<resource-ref>
<res-ref-name>eis/t24ConnectionFactory</res-ref-name>
<jndi-name>java:jca/t24ConnectionFactory</jndi-name>
</resource-ref>
</message-driven>
</enterprise-beans>
</jboss>
Note: Above jboss.xml will map the activation specification defined in ejb-jar.xml to a jBoss Application Server. As we are using WMQ
resource adapter we need to make sure that we use correct JNDI name in jms/jmsConnectionFactory i.e. java:wmq/myFC.

Step 5: Deploying TAFC JCA Adaptor


To configure jBoss Application Server to communicate with the T24 Application Server copy a TAFC Adaptor called tocfT24ra.rar to [JbossInstallDirectory]\server\default\deploy]directory.

Step 6: Deploying TAFC JCA Connection Factory


Jboss application server will use the TAFC JCA connection factory to connect to T24 Application Server so we need to copy following file into
[JbossInstallDirectory]\server\default\deploy]directory;
t24-ds.xml:-

<connection-factories>
<tx-connection-factory>
<jndi-name>jca/t24ConnectionFactory</jndi-name>
<rar-name>tocfT24ra-ra.rar</rar-name>
<connection- definition>com.temenos.tocf.t24ra.T24ConnectionFactory</connection- definition>
<config-property name="hosts" type="java.lang.String">127.0.0.1</config-property>

Quick Guide to Jboss with MQ- Release R13.00 -Page 7 of 10 - (c) Temenos Systems 2013 05/07/2013

<config-property name="ports" type="java.lang.String">51164</config-property>


<config-property name="allowInput" type="java.lang.Boolean">true</config-property> <config-property name="env" type="java.lang.String">OFS_SOURCE=BROWSERTC</config-property>
<config-property name="debugPort" type="java.lang.Integer">9087</config-property>
</tx-connection-factory>
</connection-factories>

Test Configurations
We can verify configurations up to this point by putting messages on our t24OFSQueue and check whether OFSMessageMDB gets activated
and pos t message to T24 and see the response in t24OFSReplyQueue. We need to open a command prompt on system where MQ server is
installed and navigate to bin directory of Websphere_MQ_Install_Dir and apply following command but Ensure that jboss is in running state
and jbase_agent listening to port number 51164.

We can verify the response by this command amqsget.exe t24OFSReplyQueue from WebSphere_MQ_Install_Dir/bin directory.
Or follow the below steps
1) Navigate to WebSphere MQ Explorer.
2) Expand IBM Web sphere option in left pane .
3) Click on Queue Manager (T24QM) under that click on Queues option.
4) In right side pane select t24OFSReplyQueue and you can see the response in that.
You can also notice output on T24 jbase_agent screen if it is running in debug mode;
For Eg:
Jbase_agent p 51164 L2

Important Note:

Quick Guide to Jboss with MQ- Release R13.00 -Page 8 of 10 - (c) Temenos Systems 2013 05/07/2013

If this test passes we can simply deploy BrowserWeb.war defined in next step. If any exceptions occurred on this stage, we need to rectify the
problem before we move onto next step.

Step 7: Deploying BrowserWeb.war


To deploy T24 Browser copy the BrowserWeb.war file into jboss\server\default \server directory including the below changes to WEBINF/jboss-web.xml.

Jboss-web.xml
<?xml version="1.0" encoding="UTF-8"?>
<jboss-web>
<resource-ref>
<res-ref-name>jca/t24ConnectionFactory</res-ref-name>
<res-type>com.temenos.tocf.t24ra.T24ConnectionFactory</res-type>
<jndi-name>java:jca/t24ConnectionFactory</jndi-name>
</resource-ref>
<resource-ref>
<res-ref-name>jms/jmsConnectionFactory</res-ref-name>
<res-type>javax.jms.ConnectionFactory</res-type>
<!--<jndi-name>java:/ConnectionFactory</jndi-name>-->
<jndi-name>java:wmq/myFC</jndi-name>
</resource-ref>
<resource-ref>
<res-ref-name>queue/t24OFSQueue</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<jndi-name>queue/t24OFSQueue</jndi-name>
</resource-ref>
<resource-ref>
<res-ref-name>queue/t24OFSReplyQueue</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<jndi-name>queue/t24OFSReplyQueue</jndi-name>
</resource-ref>
</jboss-web>

After configuring above component Start jboss (by clicking run.bat) and start jbase_ agent listening to port number specified in t24ds.xml
(jbase_agent p 51164) login to T24.

Quick Guide to Jboss with MQ- Release R13.00 -Page 9 of 10 - (c) Temenos Systems 2013 05/07/2013

Resources
Using WebSphere MQ Server with jBoss Application Server 4..
http://www.jboss.org/community/wiki/UsingWebSphereMQSeriesWithJBossASPart4

Quick Guide to Jboss with MQ- Release R13.00 -Page 10 of 10 - (c) Temenos Systems 2013 05/07/2013

You might also like