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 » JMSMessageListener

Post new topic  Reply to topic
 JMSMessageListener « View previous topic :: View next topic » 
Author Message
Gary Zhong
PostPosted: Fri Aug 16, 2002 12:55 pm    Post subject: JMSMessageListener Reply with quote

Newbie

Joined: 15 Aug 2002
Posts: 7

I wrote the following logic using JMSMessageListener:

In the main class,
1) get connection, get session (call it theSession)
2) get an instance of a class (call it MyListener) that implements JMSMessageListener by
MyListener theListener = new MyListener(theSession);
Notice theSession is passed onto theListener
3) get a receiver from theSession
4) register theListener to the receiver

Now in the onMessage() method of MyListener class,
5) get a text message
6) get the reply queue that comes along with the message
7) create a sender from theSession (the same one from 1) above)
Finally call the send method from the sender to dispatch a reply message

I have two questions:
i) does the above logic violates the session/thread safe guard? I did a small test without much volume, it seems to work fine.
ii) if I create more similar receivers for the same queue in the main class, will it improve the throughput?
Back to top
View user's profile Send private message
kolban
PostPosted: Sun Aug 18, 2002 12:44 pm    Post subject: Reply with quote

Grand Master

Joined: 22 May 2001
Posts: 1072
Location: Fort Worth, TX, USA

Looking at the JMS Spec, it appears that a Session created in one thread can be used by a different thread, but not at the same time. The Session is not thread safe and may not be used concurrently in multiple threads ... but using it in one thread at a time appears perfectly safe.
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 » JMSMessageListener
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.