问题
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 -
- Do I need to have an MQ Series installed on the same machine where I
am running my Spring Application.
- 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