File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Websphere and the fly likes Help with simple MQ poller Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Products » Websphere
Reply Bookmark "Help with simple MQ poller" Watch "Help with simple MQ poller" New topic
Author

Help with simple MQ poller

Bjorne Karlsson
Greenhorn

Joined: Dec 08, 2010
Posts: 2
How should I implement a simple "poller"?

Basically all I want to do is to get messages off a queue.

The below code works great if there are messages on the queue. However once the queue is depleted MQQueue.get throws and exception.

I could solve it by surrounding it all in a try-catch loop and so on, but that jsut screams dirty. So how should I do a very simple minimal implementation?

Any help/links (I've searched for this extensively) would be greatly appreciated!

Thanks in advance!

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 16483
    
    2

I don't see that the queue.get method has any choice but to throw an exception once the wait time has expired. Not the way it's designed. So catch the exception.
Steve Harney
Greenhorn

Joined: Jun 19, 2010
Posts: 18
you could check the queue for messages before asking for one. ie

Bjorne Karlsson
Greenhorn

Joined: Dec 08, 2010
Posts: 2
Steve Harney wrote:you could check the queue for messages before asking for one. ie



This worked great! Thanks!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Help with simple MQ poller
 
Similar Threads
append to a text file at the end of the week
How to append to a text file for a week
MQ: MQException: Completion Code 2, Reason 2033
MQWebsphere(MQJE001: An MQException occurred: Completion Code 2, Reason 2059)
problem in reading message for IBM MQ series using IBM MQ classes