Prashant T
Prashant T

Reputation: 1

Spring integration JMS IBM mq configuration to read message from one queue and send it to six different queue

Hi I am new to Spring integration. I want to write code from scratch to read message from one JMS queue and send it to seven different queue. I need to use IBM Mq. Can anyone share the sample code with me. I have written below xml. I have created one reader queue and seven writer queue. And used recipient-list-router to route it from reader queue to writer queue.

Can somebody confirms whether its right or wrong.

jms-xml.

        This adapter reads message from one queue and duplicate it and writes it in multiple queues.

    ]]>
</description>

<bean id="jmsConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
    <property name="transportType" value="${jms.transportType}"/>
    <property name="queueManager" value="${jms.queueManager}"/>
    <property name="hostName" value="${jms.hostName}"/>
    <property name="port" value="${jms.port}" />
    <property name="channel" value="${jms.channel}"/>
</bean>


<bean id="readerQueue" class="com.ibm.mq.jms.MQQueue">
    <constructor-arg index="0" value="${jms.queueManager}"/>
    <constructor-arg index="1" value="${jms.receiver.queue.name}"/>
</bean>

<bean id="writerQueue2" class="com.ibm.mq.jms.MQQueue">
    <constructor-arg index="0" value="${jms.queueManager}"/>
    <constructor-arg index="1" value="${jms.receiver.queue.name}"/>
</bean>

<bean id="writerQueue3" class="com.ibm.mq.jms.MQQueue">
    <constructor-arg index="0" value="${jms.queueManager}"/>
    <constructor-arg index="1" value="${jms.receiver.queue.name}"/>
</bean>
<bean id="writerQueue4" class="com.ibm.mq.jms.MQQueue">
    <constructor-arg index="0" value="${jms.queueManager}"/>
    <constructor-arg index="1" value="${jms.receiver.queue.name}"/>
</bean>
<bean id="writerQueue5" class="com.ibm.mq.jms.MQQueue">
    <constructor-arg index="0" value="${jms.queueManager}"/>
    <constructor-arg index="1" value="${jms.receiver.queue.name}"/>
</bean>
<bean id="writerQueue6" class="com.ibm.mq.jms.MQQueue">
    <constructor-arg index="0" value="${jms.queueManager}"/>
    <constructor-arg index="1" value="${jms.receiver.queue.name}"/>
</bean>

<bean id="writerQueue7" class="com.ibm.mq.jms.MQQueue">
    <constructor-arg index="0" value="${jms.queueManager}"/>
    <constructor-arg index="1" value="${jms.receiver.queue.name}"/>
</bean>


<jms:channel id="readerChannel" queue-name="readerQueue" connection-factory="jmsConnectionFactory"/>
<jms:channel id="writerChannel1" queue-name="writerQueue1" connection-factory="jmsConnectionFactory"/>
<jms:channel id="writerChannel2" queue-name="writerQueue2" connection-factory="jmsConnectionFactory"/>
<jms:channel id="writerChannel3" queue-name="writerQueue" connection-factory="jmsConnectionFactory"/>
<jms:channel id="writerChannel4" queue-name="writerQueue4" connection-factory="jmsConnectionFactory"/>
<jms:channel id="writerChannel5" queue-name="writerQueue5" connection-factory="jmsConnectionFactory"/>
<jms:channel id="writerChannel6" queue-name="writerQueue6" connection-factory="jmsConnectionFactory"/>
<jms:channel id="writerChannel7" queue-name="writerQueue7" connection-factory="jmsConnectionFactory"/>
-->
<int:recipient-list-router id="customRouter" input-channel="readerChannel"
                           timeout="1234"
                           ignore-send-failures="true"
                           apply-sequence="true">
    <int:recipient channel="writerChannel1"/>
    <int:recipient channel="writerChannel2"/>
    <int:recipient channel="writerChannel3"/>
    <int:recipient channel="writerChannel4"/>
    <int:recipient channel="writerChannel5"/>
    <int:recipient channel="writerChannel6"/>
    <int:recipient channel="writerChannel7"/>
</int:recipient-list-router>



<bean id="receiverJMSTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory" ref="jmsConnectionFactory" />
    <property name="pubSubDomain" value="false"/>
    <property name="receiveTimeout" value="30000"/>
</bean>

Upvotes: 0

Views: 3530

Answers (1)

Oleg Zhurakousky
Oleg Zhurakousky

Reputation: 6126

Have you had a chance to visit SI samples repo https://github.com/spring-projects/spring-integration-samples? There are several examples for JMS https://github.com/spring-projects/spring-integration-samples/tree/master/basic/jms

Upvotes: 1

Related Questions