Spring集成JMS IBM mq配置从一个队列读取消息并将其发送到六个不同的队列

时间:2018-05-15 10:08:38

标签: spring spring-integration ibm-mq spring-jms

您好我是Spring集成的新手。我想从头开始编写代码以从一个JMS队列中读取消息并将其发送到七个不同的队列。 我需要使用IBM Mq。任何人都可以与我分享示例代码。我写了下面的xml。 我创建了一个读取器队列和七个写入器队列。并使用recipient-list-router将其从读取器队列路由到写入器队列。

有人可以确认是对还是错。

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"/>
              - &GT;
<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>

1 个答案:

答案 0 :(得分:1)