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 » MQJava listener

Post new topic  Reply to topic
 MQJava listener « View previous topic :: View next topic » 
Author Message
Vin
PostPosted: Tue Apr 02, 2002 8:12 pm    Post subject: Reply with quote

Master

Joined: 25 Mar 2002
Posts: 212
Location: India

If I use an option of MQWI_WAITUNLIMITED as my GMO (get message options)is this equivalent to a MessageListener in JMS? The thing I'm trying to acheive is get messages from the group as soon as they arrive. Is there the correct way of doing it or do I need to use the WAIT INTERVAL? I wanted to know the difference and which one is more efficient. Thanks for your time.
Back to top
View user's profile Send private message
kolban
PostPosted: Tue Apr 02, 2002 8:42 pm    Post subject: Reply with quote

Grand Master

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

JMS is an industry standard messaging and queueing API in the Java space. MQSeries is a proprietary product from IBM. Using the MQWI_WAITUNLIMITED blocks the calling thread and returns immediately that there is a message available.

The JMS MessageListener is an interface you implement and register with the queueReceiver object and, when a message arrives, a new thread will be created and the thread passed a reference to the received message.

These are quite radically different programming styles. One is single threaded where you have control (remember, you can spawn a thread and issue the block within the thread), the other is inherently asynchronous. Note that you can also do blocking gets (receives) in JMS too.

In IBM's implementation, the blocking get is more efficient.
Back to top
View user's profile Send private message
Vin
PostPosted: Wed Apr 03, 2002 10:34 am    Post subject: Reply with quote

Master

Joined: 25 Mar 2002
Posts: 212
Location: India

Kolban,
Thanks for the answer. If I'm using MQJava which approach is more efficient. WAIT_UNLIMITED or WAIT_INTERVAL specified? also I'm trying to get this statement
in your answer.
remember, you can spawn a thread and issue the block within the thread?

Can you point me to any code samples which spawn a thread the above mentioned way? I really need them badly. Thanks.
Back to top
View user's profile Send private message
kolban
PostPosted: Wed Apr 03, 2002 11:46 am    Post subject: Reply with quote

Grand Master

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

Both WAIT_INTERVAL and WAIT_UNLIMITED have identical performance attributes. The difference is one will wake up from the get after a configurable period of time even if no message arrives.

In Java, you can create a new thread. See the Thread class documentation supplied as part of your JDK. In this thread, you can create an MQQueueManager and MQQueue objects and perform your work in this thread allowing your other threads to progress in parallel.
Back to top
View user's profile Send private message
Vin
PostPosted: Wed Apr 03, 2002 5:42 pm    Post subject: Reply with quote

Master

Joined: 25 Mar 2002
Posts: 212
Location: India

Kolban,
Just trying to get you right here. My application uses a request/reply paradigm. When I post a message on to a queue, I'm waiting for a response on a different queue, so in my get method I spawn a thread which will create a new QueueManager and Queue objects in its run method and start a while loop which will wait for all the messages to arrive and then terminate, is this the right approach? Since this is a request/reply application performance is fairly critical, any suggestions on this are most welcome.Thanks for all the help.
Back to top
View user's profile Send private message
kolban
PostPosted: Wed Apr 03, 2002 8:43 pm    Post subject: Reply with quote

Grand Master

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

Now if you'd asked this in the first place

The logic should be something like:
Code:

Get an MQQueueManager object for my queue manager;
Get an MQQueue object for my request queue;
Get an MQQueue object for my reply queue;
Put the request message to my request queue;
Get the response message from my response queue, waiting for (say 5 seconds max)
If a message was returned
   Process the reply
else
   Process no reply
End
Back to top
View user's profile Send private message
Vin
PostPosted: Wed Apr 03, 2002 9:51 pm    Post subject: Reply with quote

Master

Joined: 25 Mar 2002
Posts: 212
Location: India

Kolban,
Actually I need to wait in the while loop until all the messages arrive on the response queue Thanks.
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 » MQJava listener
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.