You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by StanleyH <st...@gmail.com> on 2006/08/25 17:19:52 UTC

QueueBrowser and OnMessage

hi,  my application works like an email client.  I want to use queuebrowser
to browse all the messages on the queue/keep them on the server  and also be
notified if a new message has arrived. queuebrowser does not have a
OnMessage method.  is there a way I can be notified that  a new message has
arrived on the queue and then have queuebrowser lists the updated queue.

thanks 
-- 
View this message in context: http://www.nabble.com/QueueBrowser-and-OnMessage-tf2165346.html#a5985541
Sent from the ActiveMQ - User forum at Nabble.com.


Re: QueueBrowser and OnMessage

Posted by James Strachan <ja...@gmail.com>.
On 8/25/06, StanleyH <st...@gmail.com> wrote:
> Hi, if I create another message (type==NewMessageNotification) and send it
> with my message from the producer, and the recipient listens selectively to
> NewMessageNotify and then call queuebrowse will that work? thanks.

Yes; you can use selectors on both regular message listeners or on
queue browsers.

Another idea is we could add an interceptor to the broker to add an
incrementing number to each message as a header.

http://incubator.apache.org/activemq/interceptors.html

then you could start off browsing all the messages; then keep track of
the maximum messageCounter header you see. Then you could periodically
poll the queue using a QueueBrowser with a selector for the new
messages you've not seen. e.g. selector

messageCounter > 1234

(where 1234 is the last messageCounter you saw)

Right now the broker attaches a header called JMSTimestamp which is
increasing over time so you could maybe use that?

-- 

James
-------
http://radio.weblogs.com/0112098/

Re: QueueBrowser and OnMessage

Posted by StanleyH <st...@gmail.com>.
Hi, if I create another message (type==NewMessageNotification) and send it
with my message from the producer, and the recipient listens selectively to
NewMessageNotify and then call queuebrowse will that work? thanks.

James.Strachan wrote:
> 
> On 8/25/06, StanleyH <st...@gmail.com> wrote:
>> hi,  my application works like an email client.  I want to use
>> queuebrowser
>> to browse all the messages on the queue/keep them on the server  and also
>> be
>> notified if a new message has arrived. queuebrowser does not have a
>> OnMessage method.  is there a way I can be notified that  a new message
>> has
>> arrived on the queue and then have queuebrowser lists the updated queue.
> 
> I'm afraid not.
> 
> You could watch the MBeans to see the enqueue count rise. Or you could
> create a dummy consumer then when a message arrives, close the
> consumer - though that could break ordering on your queue.
> 
> -- 
> 
> James
> -------
> http://radio.weblogs.com/0112098/
> 
> 

-- 
View this message in context: http://www.nabble.com/QueueBrowser-and-OnMessage-tf2165346.html#a5987110
Sent from the ActiveMQ - User forum at Nabble.com.


Re: QueueBrowser and OnMessage

Posted by James Strachan <ja...@gmail.com>.
On 8/25/06, StanleyH <st...@gmail.com> wrote:
> hi,  my application works like an email client.  I want to use queuebrowser
> to browse all the messages on the queue/keep them on the server  and also be
> notified if a new message has arrived. queuebrowser does not have a
> OnMessage method.  is there a way I can be notified that  a new message has
> arrived on the queue and then have queuebrowser lists the updated queue.

I'm afraid not.

You could watch the MBeans to see the enqueue count rise. Or you could
create a dummy consumer then when a message arrives, close the
consumer - though that could break ordering on your queue.

-- 

James
-------
http://radio.weblogs.com/0112098/

Re: QueueBrowser and OnMessage

Posted by colincrist <co...@hermesjms.com>.
A common misue of message queues is to treat them like a database table that
can be queried when really a queue is a transient place for data to flow
that decouples the producers and consumers. Selectors  are there to break
down the message flow into many sub-ordered streams of data that can be
handled by different consumers. Indeed, some schools of thought recommend a
single queue only contain a single type of data although I think this is a
bit restrictive myself. The reality is probably somewhere in the middle but
there is a lot to be said for the data driven approach as it avoids system
to system coupling. Another common design goal is that in a well running
system queue depths are zero - meaning that all consumers are up and working
normally, if one is down then queues build up and you can get alerts and
monitor for this.

Your application sounds like an inbox or blotter type of application and
over time with this kind of system I can think of a few issues off the top
of my head:

1. You want to have more complicated ways to filter the messages to let a
user view them. Using messaging you can end up with header property
explosion.
2. You want to attach state to the message as it moves through some kind of
workflow - e.g. not read/read/accepted/rejected. 
3. Refile the message elsewhere, using the inbox analogy, into another
folder.
4. Keep a fully history of certain kinds of messages somewhere.
5. Audit trail all operations.

I don't know much about your application but I'd keep my (JMS) messaging
system to do just messaging and then hand the messages off into a good old
database for manipulation and viewing with its benefits of flexible
transactions, SQL, security, heaps of visualistion tools etc etc.

Hope this helps!

Regards,

Colin.
http://hermesjms.com



StanleyH wrote:
> 
> hi,  my application works like an email client.  I want to use
> queuebrowser to browse all the messages on the queue/keep them on the
> server  and also be notified if a new message has arrived. queuebrowser
> does not have a OnMessage method.  is there a way I can be notified that 
> a new message has arrived on the queue and then have queuebrowser lists
> the updated queue.
> 
> thanks 
> 

-- 
View this message in context: http://www.nabble.com/QueueBrowser-and-OnMessage-tf2165346.html#a6007715
Sent from the ActiveMQ - User forum at Nabble.com.