пятница, 25 июля 2014 г.

Standalone Spring 3 JMS client to WebSphere MQ 7.0

There are a lot of blogs about creating JMS clients, but I couldn't find one simple article about connecting to WebSphere MQ 7.0 from java client.

Let's start:

1)  download the following jars from WebSphere MQ 7 installation into your project classpath:
12.08.2010  17:06            13 143 CL3Export.jar
12.08.2010  17:06            33 166 CL3Nonexport.jar
12.08.2010  17:09           356 856 com.ibm.mq.headers.jar
12.08.2010  17:09           440 087 com.ibm.mq.jar
12.08.2010  17:09         1 932 269 com.ibm.mq.jmqi.jar
12.08.2010  17:09           104 492 com.ibm.mq.pcf.jar
12.08.2010  17:09         3 266 359 com.ibm.mqjms.jar
12.08.2010  17:07            17 978 connector.jar
12.08.2010  17:06         2 011 813 dhbcore.jar
12.08.2010  17:08            22 769 fscontext.jar
12.08.2010  17:08            77 116 providerutil.jar
12.08.2010  17:06           893 748 rmm.jar

2) in your application context configure the client:

<!-- WebSphere MQ Connection Factory -->
    <bean id="mqConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
        <property name="hostName">
            <value>host</value>
        </property>
        <property name="port">
            <value>port</value>
        </property>
        <property name="queueManager">
            <value>value</value>
        </property>
        <property name="transportType">
            <value>1</value>
        </property>
    </bean>

    <bean id="jmsQueueConnectionFactory"
        class="org.springframework.jms.connection.SingleConnectionFactory">
        <property name="targetConnectionFactory">
            <ref bean="mqConnectionFactory" />
        </property>
    </bean>
   
    <bean id="jmsContainer"
        class="org.springframework.jms.listener.DefaultMessageListenerContainer">
        <property name="connectionFactory" ref="jmsQueueConnectionFactory" />
        <property name="destinationName" value="queue_name" />
        <property name="messageListener" ref="inMessageListener" />
    </bean>

<bean id="inMessageListener" class="ru.mq.MyMessageListener" />

Now, you can receive JMS messages in a standalone application from WebSphere MQ.

Комментариев нет:

Отправить комментарий