my dog learned polymorphism
The moose likes Spring and the fly likes IBM MQ vs JMS - Spring Implementation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "IBM MQ vs JMS - Spring Implementation" Watch "IBM MQ vs JMS - Spring Implementation" New topic

IBM MQ vs JMS - Spring Implementation

saakshi jain

Joined: Sep 26, 2011
Posts: 10
I am working on a Spring application where we have implemented code to send messages through IBM MQ.

Now we have been advised not to directly use MQ APIs directly and instead use JMS.

The steps i followed :

1) created a JNDI name to connect to the Message queue configured as:

<bean id="emailQueueDestination" class="org.springframework.jndi.JndiObjectFactoryBean" lazy-init="true">
<property name="jndiName" value="<<JNDI name of Queue" >>/>

2) I need a connecton factory object to connect to the JMS Provider and I have configured it as :

<bean id="emailQueueConnectionFactory" class="">

<property name="queueManager" value="" />
<property name="hostName" value="" />
<property name="channel" value="" />
<property name="port" value="1414" />

Further I have injected the above 2 beans in JMSTemplate class:

<bean id="emailQueueTemplate" class="org.springframework.jms.core.JmsTemplate" lazy-init="true">
<property name="connectionFactory" ref="emailQueueConnectionFactory" />
<property name="defaultDestination" ref="emailQueueDestination" />

Now since my purpose is to remove dependency on MQ APIs..Do you think the configuration above(especially for connection factory ) looks good???

Please can anyone help here???
Rishi Shehrawat
Ranch Hand

Joined: Aug 11, 2010
Posts: 218

This looks fine to me as you have moved MQ related dependecies out of your code to the Spring configuration file. Since you will be using the JmsTemplate you will be able to change the provider from MQ without any code changes.
saakshi jain

Joined: Sep 26, 2011
Posts: 10
Hey...thanks for your reply...Is there any documentation on in it would helpful in undersanding what all changs we required in case we move from MQ to any othr provider
I agree. Here's the link:
subject: IBM MQ vs JMS - Spring Implementation
It's not a secret anymore!