RE: Non-destructive listener?

"Tim Anderson" <[email protected]>
Newsgroups gmane.comp.java.openjms.user
Message-ID <[email protected]>
> From: Nicolaus.Bauman-SWCg6hSX5lit/[email protected]
> 
> > > From: Nicolaus.Bauman-SWCg6hSX5lit/[email protected]
> > > 
> > > I totally agree, my needs are much better suited for topics. 
> > > Alas, I don't have that choice.
> > > 
> > > One last question: the approach you describe works 
> because while the 
> > > browser scans for a message on the queue, it locks the messages 
> > > until the scan is complete. Is that a correct assumption? If so, 
> > > then, yeah, that does sound VERY resource-intensive.
> > > 
> > > Thanks so much for such a clear and succinct response.
> > 
> > The browser doesn't lock the queue. The approach works because the 
> > browser is used to scan the queue, and individual messages are 
> > subsequently synchronously consumed using a QueueReceiver.
> > 
> > E.g, suppose the queue contains messages A, B, and C.
> > Using a queue browser, you determine you want to consume message B.
> > So you construct a QueueReceiver with a selector:
> >   "JMSMessageID='" + B.getJMSMessageID() + "'"
> > and consume the message using the receive() method.
> > That leaves messages A and C in the queue.
> > If message D is subsequently added to the queue, a subsequent scan 
> > with a browser will see messages, A, C, and D.
> > 
> > Its resource intensive in that you need to continuously 
> scan the queue 
> > to pick up new messages.
> > 
> > -Tim
> 
> First of all, thank you for taking time to explain this. I 
> can't remember when I have gotten better support from any 
> software community, let alone individual, on any product or 
> system I've been concerned with. This is so cool. 
> Furthermore, if the community support is already this good, 
> one can only guess at how much better the actual engineering 
> implementation is.
> 
> Secondly, now perhaps I'm just as thick as a whale omlet, but 
> what you describe seems to indicate that the browser can 
> _still_ miss a message if another Listener is listening on 
> the queue. Is this a wrong assumption?
> 

Yes, the browser will miss messages if there is one or more
receivers consuming from the queue. A browser can also see
messages that have already been consumed, as it is working on
a (partial) snapshot of the queue.

If you want your browser to see all messages, then you 
need to use the browser to drive all message consumption i.e,
only create a consumer for message, selecting on its JMSMessageID
once it has been browsed. 

-Tim





-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP.  Click here to play: http://sourceforge.net/geronimo.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.