|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Websphere ,Spring and MQ |
« View previous topic :: View next topic » |
Author |
Message
|
saranj |
Posted: Thu Nov 22, 2007 5:52 pm Post subject: Websphere ,Spring and MQ |
|
|
Newbie
Joined: 07 Nov 2007 Posts: 7
|
Hi All,
In order to send and read message from WebSphereMQ , i have configured connection factory and sender and receiver information in Spring configuration file. this works fine.
Is it right way creating connection factories for MQ ? i am using jmsTemplate also.
Is there any other better way ? i thought of using ${property} notations for reading connection information but i am using java 1.4.
here is my spring.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="msgSender"
class="com.hermes.dataaccess.esr.jms.MessageSender" >
<property name="jmsTemplate102">
<ref bean="jmsQueueTemplate"/>
</property>
</bean>
<bean id="msgReceiver"
class="com.hermes.dataaccess.esr.jms.MessageReceiver">
</bean>
<bean id="jmsConnectionFactory" class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="queueManager">
<value>QM_HERMES</value>
</property>
<property name="hostName">
<value>localhost</value>
</property>
<property name="port">
<value>1414</value>
</property>
<property name="channel">
<value>HERMES_SER_CH</value>
</property>
<property name="transportType" value="1"/>
</bean>
<bean id="destinationQueue" class="com.ibm.mq.jms.MQQueue">
<property name="baseQueueName">
<value>DeliveryConfirmationQueue</value>
</property>
</bean>
<bean id="jmsDestinationResolver" class="com.ibm.mq.jms.MQQueue">
<constructor-arg value="DeliveryConfirmationQueue" />
</bean>
<!-- JMS Template -->
<bean id="jmsQueueTemplate" class="org.springframework.jms.core.JmsTemplate102">
<property name="connectionFactory">
<ref local="jmsConnectionFactory" />
</property>
<property name="defaultDestination">
<ref bean="jmsDestinationResolver"/>
</property>
</bean>
<bean id="listenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="concurrentConsumers" value="1"/>
<property name="connectionFactory" ref="jmsConnectionFactory"/>
<property name="destination" ref="destinationQueue" />
<property name="messageListener" ref="msgReceiver"/>
</bean>
</beans>
Please let me know if there is better way than this one.
Thanks |
|
Back to top |
|
 |
JLRowe |
Posted: Fri Nov 23, 2007 3:56 am Post subject: |
|
|
 Yatiri
Joined: 25 May 2002 Posts: 664 Location: South East London
|
Looks fine to me, a couple of small points:
You can remove the bean
Code: |
<bean id="jmsDestinationResolver" class="com.ibm.mq.jms.MQQueue">
<constructor-arg value="DeliveryConfirmationQueue" />
</bean> |
And you can just inject the destination name into the JmsTemplate with the defaultDestinationName property.
Also, you can use the JmsTemplate if you are on a JMS 1.1 provider.
You can use a properties file with Java 1.4, it depends if you want to hide the spring.xml from the code maintainer or person who will be supporting/deploying your code. Same old tradeoffs. |
|
Back to top |
|
 |
saranj |
Posted: Sun Nov 25, 2007 7:34 pm Post subject: |
|
|
Newbie
Joined: 07 Nov 2007 Posts: 7
|
Hi JLRowe,
Thanks for your reply. I have changed my code according to your suggestion. i have few more question.
My application will be running on WebSphere server with the above MQ configuration which are defined in Spring. In this case ,does WAS provide connection pooling automatically or not ? if not , what changes has to be done ?
If i want to implement transaction , can i use the same above configuration or do i need use jndi instead of using MQ api ?
Thanks |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Nov 26, 2007 3:41 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
saranj wrote: |
Hi JLRowe,
Thanks for your reply. I have changed my code according to your suggestion. i have few more question.
My application will be running on WebSphere server with the above MQ configuration which are defined in Spring. In this case ,does WAS provide connection pooling automatically or not ? if not , what changes has to be done ?
If i want to implement transaction , can i use the same above configuration or do i need use jndi instead of using MQ api ?
Thanks |
Your bean is using JMS. You should use the J2EE model (JNDI/JMS/JTA) to get the full benefit of connection pooling, transaction handling etc... _________________ MQ & Broker admin |
|
Back to top |
|
 |
saranj |
Posted: Mon Nov 26, 2007 7:12 am Post subject: |
|
|
Newbie
Joined: 07 Nov 2007 Posts: 7
|
Hi All,
What changes needs to be done on the above spring configuration file if i want to use JNDI for creating mq queue connection factory and qm destination ? |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|