Nav
You are viewing an older version of this section. Click here to navigate to the latest version.

Open MQ Integration

This page describes how to integrate Mule with the Open MQ JMS broker, the community version of Sun Java System Message Queue. It includes examples for configuring a direct connection and a JNDI connection.

Direct Connection

To create a direct connection, simply specify the connection factory and JMS connector as follows in your Mule configuration file:


         
      
1
<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">    <spring:bean name="connectionFactory" class="com.sun.messaging.ConnectionFactory"/>    <jms:connector name="JMSConnector"                   connectionFactory-ref="connectionFactory"                   specification="1.1"/></mule>

JNDI Connection

To create a JNDI connection, take the following steps:

  1. Configure Open MQ using the instructions from Sun. You must use the Open MQ or Message Queue Administration Console to define the connectionFactory (Factory type topic/queue connection factory) and to configure any Open MQ JMS endpoints you will specify in your Mule configuration file.

  2. Configure the namespaces, JMS connector, Spring beans, and endpoints in your Mule configuration file as follows, ensuring that you include all the tags shown below:


         
      
1
<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">    <jms:connector name="jmsConnector" connectionFactory-ref="openMQ" specification="1.1">        <spring:property name="jmsSupport" ref="jndiJmsSupport" />    </jms:connector>    <spring:beans>        <spring:bean name="jndiJmsSupport" class="org.mule.transport.jms.Jms102bSupport">            <spring:constructor-arg ref="jmsConnector" />        </spring:bean>        <spring:bean name="context" class="javax.naming.InitialContext">            <spring:constructor-arg type="java.util.Hashtable">                <spring:props>                    <spring:prop key="java.naming.factory.initial">com.sun.jndi.fscontext.RefFSContextFactory                </spring:prop>                <spring:prop key="java.naming.provider.url">file:///C:/pawan/openMQ/mq</spring:prop>                </spring:props>            </spring:constructor-arg>        </spring:bean>        <spring:bean name="openMQ" class="org.springframework.jndi.JndiObjectFactoryBean">            <spring:property name="jndiName" value="MyTopicConnectionFactory" />            <spring:property name="jndiEnvironment">                <spring:props>                    <spring:prop key="java.naming.factory.initial">com.sun.jndi.fscontext.RefFSContextFactory                    </spring:prop>                    <spring:prop key="specifications">1.1</spring:prop>                    <spring:prop key="java.naming.provider.url">file:///C:/Temp</spring:prop>                </spring:props>            </spring:property>        </spring:bean>    </spring:beans>    <endpoint name="MyEndPoint" address="jms://topic:my_topic" connector-ref="jmsConnector"/>...</mule>
  1. You need to put imq.jar and fscontext.jar from the $OPENMQ_HOME/lib on your classpath.