Spring Integration with IBM MQ Series

只谈情不闲聊 提交于 2019-12-21 02:45:18

问题


Am novice when it comes to Spring integration and so had some questions around it. Am trying to integrate Spring Integration with the MQ Series and believe that all my IBM MQ(Q Connection Factory and Queue) entries should be going inside my applicationcontext.xml file. I have the applicationcontext file for ActiveMQ Implementation and just wanted to know what exactly an IBM MQ specific entries in App Contest file will look like. Questions are -

  1. Do I need to have an MQ Series installed on the same machine where I am running my Spring Application.
    1. I presume not, then what should be the entries for QueueConnectionFactory and Destination attributes in the ApplicationContext file. providing some sample poc's will help me lot.

Thanks in advance.


回答1:


You can create beans like this

jms.transportType=1
jms.queueManager=YOUR_QUEUE_MANAGER
jms.hostName=YOUR_HOSTNAME
jms.port=1321

jms.channel=YOUR_CHANNEL
jms.receiver.queue.name=YOUR_QUEUE
jms.username=
jms.alias=
jms.mq.connection.factory=jmsConnectionFactory
jms.mq.receiver.queue=receiverQueue
<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="secureJmsConnectionAdapter" class="yourpackages.SecureJMSConnectionAdapter">
    <property name="targetConnectionFactory" ref="${jms.mq.connection.factory}" />
    <property name="userName" value="${jms.username}"/>
    <property name="pwdAlias" value="${jms.alias}"/>
</bean>

<bean id="receiverQueue" 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="receiverJMSTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory" ref="secureJmsConnectionAdapter" />
    <property name="pubSubDomain" value="false"/>
    <property name="defaultDestination" ref="${jms.mq.receiver.queue}"/>
    <property name="receiveTimeout" value="30000"/>
</bean>


<bean class="org.springframework.jms.listener.SimpleMessageListenerContainer">
    <property name="connectionFactory" ref="secureJmsConnectionAdapter" />
    <property name="destinationName" value="${jms.receiver.queue.name}" />
    <property name="messageListener" ref="mQListener" />
</bean>


来源:https://stackoverflow.com/questions/32299757/spring-integration-with-ibm-mq-series

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!