• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Help with simple MQ poller

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!

 
Marshal
Posts: 24594
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 19
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you could check the queue for messages before asking for one. ie

 
Bjorne Karlsson
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Steve Harney wrote:you could check the queue for messages before asking for one. ie



This worked great! Thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!