Input IBM WebSphere MQ JMS Event Adapter
The configurations of the IBM WebSphere MQ input JMS event adapter are explained below. It can be configured with XML, map, JSON, and text input mapping types.
Prerequisites
Follow the steps below to set up the prerequisites before starting the configuration.
- Start WSO2 BAM.
- Download and install WebSphere MQ pack with the latest fixes. For more information on installing, see the IBM documentation).
Configuring WebSphere MQ
Follow the instructions below to configure WebSphere MQ.
Configuring JMSAdmin.conf File
Go to the
<WebSphere_MQ_HOME>\java\bin
directory and open theJMSAdmin.config
file in a text editor.Comment out the existing INITIAL_CONTEXT_FACTORY and add a INITIAL_CONTEXT_FACTORY named com.sun.jndi.fscontext.RefFSContextFactory.
INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory
Comment out the default PROVIDER_URL and use a directory path instead. Ensure the directory is created in the file system (e.g., C:/JNDI-Directory).
If there are .bindings files of earlier versions already existing in this folder, delete them. It should typically be an empty folder.Your
JMSAdmin.config
file should now look similar to this:# appropriate one should be uncommented. # #INITIAL_CONTEXT_FACTORY=com.sun.jndi.ldap.LdapCtxFactory INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory #INITIAL_CONTEXT_FACTORY=com.ibm.ejs.ns.jndi.CNInitialContextFactory #INITIAL_CONTEXT_FACTORY=com.ibm.websphere.naming.WsnInitialContextFactory #INITIAL_CONTEXT_FACTORY=com.ibm.websphere.naming.WMQInitialContextFactory # # The following line specifies the URL of the service provider's initial # context. It currently refers to an LDAP root context. Examples of a # file system URL and WebSphere's JNDI namespace are also shown, commented # out. # #PROVIDER_URL=ldap://polaris/o=ibm,c=us PROVIDER_URL=file:/C:/JNDI-Directory #PROVIDER_URL=iiop://localhost/ #PROVIDER_URL=localhost:1414/SYSTEM.DEF.SVRCONN ......
- Restart the WebSphere MQ service.
Creating the Queue in WebSphere MQ
- Start IBM WebSphere MQ Explorer and create a new queue manager. Make sure you select make this the default queue manager check box. Leave default values on the other fields.
- Select the options to Start Queue Manager, Autostart Queue Manager, and Create server connection channel, and then click Next.
- Select the option to create a listener configuration for TCP/IP, and provide a port number ( e.g., 1415 ).
- Select the created Queue manager and expand its navigation tree. Click Queues in the tree and create a new local queue (e.g., localq).
- Keep the default configurations and click Finish.
- Click Topics in the tree view and create a new local topic (e.g., localt).
- Right-click Channels under Advanced and select New > Server-connection Channel. Provide a name for the channel (e.g., myChannel), and click Next.
- Set the transmission protocol as TCP and click Finish.
A listener is created and is running on the given port (e.g., 1415). You should be able to view it by clicking the listeners icon.
Generating the .bindings file
Go to the
<WebSphere_MQ_HOME>
/java/bin
directory and invoke the IVT app by running the following command:IVTRun.bat -nojndi -client -m mymgr -host localhost -channel mychannel
Create the default set of JNDI bindings by running the following command on the command prompt:
IVTSetup.bat
Execute the IVTRun tool as follows.
IVTRun.bat -url "file:/C:/JNDI-Directory" -icf com.sun.jndi.fscontext.RefFSContextFactory
- You have now enabled and verified JNDI support. Now go to C:/JNDI-Directory to view the .bindings file there.
- Start the JMSAdmin tool by running the jmsadmin.bat file.
Modify the JNDI bindings by executing the following commands:
For queues:ALTER QCF(ivtQCF) TRANSPORT(CLIENT) ALTER QCF(ivtQCF) QMGR(mymgr)
For topics:
ALTER TCF(ivtTCF) TRANSPORT(CLIENT) ALTER TCF(ivtTCF) QMGR(mymgr)
- In IBM WebSphere MQ Explorer, select JMS Administered Objects from the tree view on the left, and then select Add initial context. Once done, select File system and enter the JNDI directory path. This will bring up all created queues and topics.
You have now set up and configured IBM WebSphere MQ in your environment.
Configuring WSO2 BAM
Follow the instructions below to configure WSO2 BAM.
- If you set up WSO2 BAM on a different machine from WebSphere MQ, copy C
:/JNDI-Directory
to that machine. The bindings file allows you to access WebSphere queues from any machine in the network. - Copy the following JAR files from the
<WebSphere_MQ_HOME>/java/lib
directory to the<BAM_HOME>/repository/components/lib/
directory.- com.ibm.mqjms.jar
- fscontext.jar
- providerutil.jar
- com.ibm.mq.jmqi.jar
- dhbcore.jar
- If you are using WebSphere MQ version 6.0 instead of version 7.0, add the following two JAR files. You might not find
com.ibm.mq.jmqi.jar
in version 6.0.- com.ibm.mq.jar
- connector.jar
Optionally, you might have to add the following jars as well.
- jms.jar
- jndi.jar
- jta.jar
- ldap.jar
- If you are using WebSphere MQ version 7.1 or later, add the following jars to the
<
BAM_HOME>/repository/components/dropins/
directory.- com.ibm.mq_2.0.0.jar
- fscontext_1.0.0.jar
Add the following files to the
<
BAM_HOME>/repository/components/lib/
directory.- jms.jar
- jta.jar
Log in to the JMSAdmin tool and create a queue named bogusq by running the following commands in JMSAdmin shell.
DEFINE Q(bogusq) QMGR(mymgr) ALTER Q(bogusq) QUEUE(localq)
localq is the queue we created earlier. We use two queues for the queue scenario, and the queue named bogusq is defined as the default destination since we need the default queue ( ivtQ ) for our proxy service only. If we use ivtQ here, all the services deployed in WSO2 BAM (XKMS, echo, wso2carbon-sts etc.) will start listening on the same queue.
Repeat these steps for the topic scenarios. For example:
DEFINE T(bogust) ALTER T(bogust) TOPIC(localt)
localt is the topic we created earlier.
Configure the
<BAM_HOME>\repository\conf\axis2\axis2.xml
file as follows:<transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener"> <parameter name="myTopicConnectionFactory" locked="false"> <parameter name="java.naming.factory.initial" locked="false">com.sun.jndi.fscontext.RefFSContextFactory</parameter> <parameter name="java.naming.provider.url" locked="false">file:/C:/JNDI-Directory</parameter> <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">ivtQCF</parameter> <parameter name="transport.jms.ConnectionFactoryType" locked="false">topic</parameter> </parameter> <!--parameter name="SQProxyCF" locked="false"> <parameter name="java.naming.factory.initial">com.sun.jndi.fscontext.RefFSContextFactory</parameter> <parameter name="java.naming.provider.url">file:/C:/JNDI-Directory</parameter> <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">ivtQCF</parameter> <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter> </parameter--> <parameter name="default" locked="false"> <parameter name="java.naming.factory.initial" locked="false">com.sun.jndi.fscontext.RefFSContextFactory</parameter> <parameter name="java.naming.provider.url" locked="false">file:/C:/JNDI-Directory</parameter> <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">ivtQCF</parameter> <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter> </parameter> </transportReceiver>
You will comment and uncomment the non-default connection factories depending on which scenario you are running, as described in the next section.
For details on the JMS configuration parameters used in the code segments, see JMS Connection Factory Parameters.
Configuring the IBM WebSphere MQ input JMS event adapter
You can configure the IBM WebSphere MQ input JMS event adapter either using the management console or using a configuration file as explained below.
Configure using the management console
Follow the instructions below to configure IBM WebSphere MQ input JMS event adapter using the management console. This deploys the event adapter in the <PRODUCT_HOME>
/
repository/
deployment/
server/
inputeventadaptors/
directory.
Start ActiveMQ, and then start the product.
- Log in to the product's management console and click Configure.
- Click Input Event Adaptors in the Event Processor Configs menu, and then click Add Input Event Adaptor.
- Enter details as shown in the below example.
- Click Add Event Adaptor.
Configure using a configuration file
Follow the instructions below to configure ActiveMQ input JMS event adapter using a configuration file.
Create an XML file with the following ActiveMQ input JMS event adapter configurations. Input event adapter implementation must start with
<inputEventAdaptor>
as the root element.<inputEventAdaptor name="webspheremqJmsInputAdaptor" statistics="disable" trace="disable" type="jms" xmlns="http://wso2.org/carbon/eventadaptormanager"> <property name="java.naming.provider.url">file:/C:/JNDI-Directory</property> <property name="transport.jms.SubscriptionDurable">false</property> <property name="java.naming.factory.initial">com.sun.jndi.fscontext.RefFSContextFactory</property> <property name="transport.jms.ConnectionFactoryJNDIName">ivtQCF</property> <property name="transport.jms.DestinationType">queue</property> </inputEventAdaptor>
Add the XML file to
<PRODUCT_HOME>/repository/deployment/server/inputeventadaptors/
directory. Since hot deployment is enabled, you can simply add/remove files to deploy/undeploy to/from the server.
After an adapter is successfully added, it gets added to the list of adapters displayed under Event Processor Configs in the Configure menu of the product's management console. Click Edit to change its configuration and redeploy it. This opens an XML-based editor allowing you to edit the event adapter configurations from the UI. Do your modifications and click Update . You can also delete it, enable/disable statistics or enable/disable tracing on it using the provided options in the UI.