WebSphereMQ Integration using Mule ESB Community Edition - codecentric AG Blog

:

Mule ESB is an open source implementation of an enterprise service bus. In contrast to the free Community Edition, Mule’s commercial Enterprise Edition provides integration of WebSphereMQ servers out of the box. This article explains how to integrate a WebSphereMQ server as a JMS provider by means of the Community Edition.

First, add the following JARs holding the WebSphereMQ client API to Mule’s classpath:

  • com.ibm.mq.jar
  • com.ibm.mqjms.jar
  • dbhcore.jar

These JARs are provided with the installation of your WebSphereMQ server. Alternatively, they can be taken from the free WebSphereMQ client distribution. Note that the client distribution does not support XA transactions. Copy these JARs to

To configure the connection to your WebSphereMQ system, you need to to know the following parameters:

– IP/ host name
– TCP port number
– Name of the Queue manager
– Name of the MQ channel
– User / Password

The Mule JMS connector is set up like this:

<jms:connector
   name="WebsphereMQConnector"
   connectionFactory-ref="MQConnectionFactory"
   specification="1.0.2b"
   username="mquser"
   password="password"
   numberOfConsumers="1"/>
<spring:bean
   id="MQConnectionFactory"
   class="com.ibm.mq.jms.MQQueueConnectionFactory">
   <spring:property name="transportType" value="1"/>
   <spring:property name="hostName" value="localhost"/>
   <spring:property name="port" value="1414"/>
   <spring:property name="channel" value="MY.CHANNEL"/>
   <spring:property name="queueManager" value="MY.QM"/>
</spring:bean>

<jms:connector name="WebsphereMQConnector" connectionFactory-ref="MQConnectionFactory" specification="1.0.2b" username="mquser" password="password" numberOfConsumers="1"/> <spring:bean id="MQConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory"> <spring:property name="transportType" value="1"/> <spring:property name="hostName" value="localhost"/> <spring:property name="port" value="1414"/> <spring:property name="channel" value="MY.CHANNEL"/> <spring:property name="queueManager" value="MY.QM"/> </spring:bean>

To use the namespaces “jms” and “spring” you have to declare them in the root element of your mule-config.xml. Assuming you are using Mule 3.0, it may look like this:

<mule xmlns="http://www.mulesoft.org/schema/mule/core"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:spring="http://www.springframework.org/schema/beans"
       xmlns:jms="http://www.mulesoft.org/schema/mule/jms"
    xsi:schemaLocation="
 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
 http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.0/mule.xsd
 http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/3.0/mule-jms.xsd">

<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:jms="http://www.mulesoft.org/schema/mule/jms" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/3.0/mule.xsd http://www.mulesoft.org/schema/mule/jms http://www.mulesoft.org/schema/mule/jms/3.0/mule-jms.xsd">

Having done this, the WebSphereMQConnector can be used to define JMS endpoints, e.g.

<endpoint 
   name="MyInQueue"   
   address="jms://queue:MY.QUEUE.IN"
   connector-ref="WebsphereMQConnector"/>
...
<flow id="MyFlow">
   <inbound-endpoint ref="MyInQueue" />
   ...
</flow>

<endpoint name="MyInQueue" address="jms://queue:MY.QUEUE.IN" connector-ref="WebsphereMQConnector"/> ... <flow id="MyFlow"> <inbound-endpoint ref="MyInQueue" /> ... </flow>

JMS consumers need at least the GET, INQ and BROWSER privileges for queues they want to read from. A detailed explanation is given here. JMS producers need the PUT privilege.

Conclusion: as long as your queues do not partcipate in XA transactions, the free Community Edition of Mule ESB is sufficient to integrate a WebSphereMQ server as an external JMS provider.