Sep 1st, 2011, 05:26 AM
Websphere MQ publisher with Spring subscriber
One of our clients are publishing messages on a Websphere MQ server to a certain topic.
I need to subscribe to these messages using Spring/JMS.
I've successfully published messages to a queue in Websphere MQ using Spring, then consuming these from Spring again, but when it comes to creating a subscriber I am struggling.
I've changed my connection factory from a com.ibm.mq.jms.MQTopicConnectionFactory to a com.ibm.mq.jms.MQQueueConnectionFactory, then set pubSubDomain=true on both the SingleConnectionFactory as well as the JmsTemplate.
In Websphere MQ Explorer I see the subscriber listed while the client is running, but even though I specify the topic name as destination for the jmsTemplate.send method it does not seem to know which topic to subscribe to.
Can anyone point me in the right direction with this?
Oct 18th, 2011, 09:35 PM
did u get a solution for this . my application is spring based . we use the spring ws stack .
i want to use spring integration to basically subscribe to a pub sub IBM MQ via a q manager and listen to it. I should read of the queue as messages come in it ,transactionally . i.e . I have to do a two phase commit , with some persistence to an oracle db involved . the code to carry out the db persistence is already available .
so once i read the message of the q ,i need to turn around and call a method of another class and pass this message as xml to it . the payload will be in xml by itself.
Is there any sample SI or Spring Project that I could use as reference.
ps. my application is deployed on an IBM Websphere application server and I have the topicconnectionfactories and topic defined in it already .
any help or guidance is much appreciated.
Oct 19th, 2011, 01:58 AM
I did get a solution that worked fine with topics and pub-sub. Have a look at:
This example is for queues, not topics. To make it work for topics you need to use a com.ibm.mq.jms.MQTopicConnectionFactory as opposed to com.ibm.mq.jms.MQQueueConnectionFactory. Also, set the "pubSubDomain" property of your connection factory to "true".
In order to test this, start Websphere MQ, expand the treeview for the queue manager you are using, right-click on "Topics" and select "Test Publication".
You will need to play around with the settings to get your subscribers to be durable and your topic to persist, else when your subscriber resubscribes after a period of inactivity you will not get the messages published while the subsciber was inactive.
As for your transactional requirement, I'm sure you can use Spring transaction support.
Hope this helps.
Oct 19th, 2011, 10:37 PM
Tags for this Thread