ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Websphere ,Spring and MQ

Post new topic  Reply to topic
 Websphere ,Spring and MQ « View previous topic :: View next topic » 
Author Message
saranj
PostPosted: Thu Nov 22, 2007 5:52 pm    Post subject: Websphere ,Spring and MQ Reply with quote

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
View user's profile Send private message
JLRowe
PostPosted: Fri Nov 23, 2007 3:56 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
saranj
PostPosted: Sun Nov 25, 2007 7:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Mon Nov 26, 2007 3:41 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
saranj
PostPosted: Mon Nov 26, 2007 7:12 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Websphere ,Spring and MQ
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.