aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes Is it possible to create a listener for JMS's QueueBrowser? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Is it possible to create a listener for JMS Watch "Is it possible to create a listener for JMS New topic
Author

Is it possible to create a listener for JMS's QueueBrowser?

Alexander Arenas
Greenhorn

Joined: Feb 24, 2009
Posts: 8
Im at a loss here. How does one go about creating a listener for the QueueBrowser?

It has no .setMessageListener() method so I cant just use a MessageListener.

Do i have to create my own version of the QueueBrowser by implementing QueueBrowser and QueueReceiver interfaces in one class?

Is there a better way?

I need to be able to browse the contents of the queue without creating a block...(in other words, I would like the browse to occur asynchronously.)

Any help on this would be greatly appreciated, thanks all!


!!! RockStarArtist !!!
Rob Davies
author
Greenhorn

Joined: Nov 04, 2010
Posts: 6
Unfortunately you can't create a MessageListener for a QueueBrowser. A QueueBrowser will show you the current state of the Queue - a snapshot of the current messages. You would periodically need to close the QueueBrowser and create a new one and filter out duplicates if you wanted to continuously monitor a Queue. Alternatively, most JMS messaging systems have their own custom API's for remotely monitoring the contents of the Queue, which are a better bet than using a QueueBrowser.

thanks,

Rob Davies
CTO
http://fusesource.com
sourabh girdhar
Ranch Hand

Joined: Feb 10, 2010
Posts: 71

Queue Browser are meant just to check the queue at a point of time. Note that a queue browser represents a static snapshop of the queue. If more messages are added to the queue while browsing, this will not be available to the queue browser.

The order of messages returned by the enumeration reflects the order of messages a regular message receiver would see.

As per JMS API
A client uses a QueueBrowser object to look at messages on a queue without removing them.

The getEnumeration method returns a java.util.Enumeration that is used to scan the queue's messages. It may be an enumeration of the entire content of a queue, or it may contain only the messages matching a message selector.

Messages may be arriving and expiring while the scan is done. The JMS API does not require the content of an enumeration to be a static snapshot of queue content. Whether these changes are visible or not depends on the JMS provider.



There are queue monitors available with different JMS implementors like JBoss,Websphere etc which keeps on monitoring the queue continously.

SCJP SCWCD AIX SOA
The significant problems we face cannot be solved by the same level of thinking that created them -- Albert Einstein

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is it possible to create a listener for JMS's QueueBrowser?