• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Alexander Arenas
Greenhorn
Posts: 8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Rob Davies
author
Greenhorn
Posts: 6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 71
Java Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic