Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Integration with IBM MQ Series

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.

like image 819
Eswar Goud Avatar asked Oct 19 '22 03:10

Eswar Goud


1 Answers

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>
like image 164
Oleksandr Loushkin Avatar answered Oct 21 '22 22:10

Oleksandr Loushkin