|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
JMSMessageListener |
« View previous topic :: View next topic » |
Author |
Message
|
Gary Zhong |
Posted: Fri Aug 16, 2002 12:55 pm Post subject: JMSMessageListener |
|
|
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 |
|
 |
kolban |
Posted: Sun Aug 18, 2002 12:44 pm Post subject: |
|
|
 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 |
|
 |
|
|
 |
|
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
|
|
|
|