users@glassfish.java.net

Re: How do you poll a Glassfish JMS queue say every hour?

From: <glassfish_at_javadesktop.org>
Date: Wed, 07 Oct 2009 01:33:00 PDT

You could also have a look at this pattern http://www.eaipatterns.com/Aggregator.html.

You could write an MDB with receives message and stores them in database. Then a timer fires periodically, aggregates the message and send a second "aggregated" message to a second MDB. The second MDB would be the one doing the real processing. Depending on how you handle the transaction, the whole batch would either succeed or fails.

A variant would be to rely on JMS itself to queue the message, then the timer open a connection, consumes the message from queue1 and send them one by one to queue 2 which are then process with a MDB. The system must be sized and configured so that no message get discarded from queue 1 in case the load is too important.

You could also process the message in the timer itself, as suggested in previous posts. The different will be mainly in the nature of the retry mechanism. MDB can be configured with retry attempt, dead message queue, etc. Timer also have retry mechanism, but are a bit more limited.
[Message sent by forum member 'ewernli' (erwann.wernli_at_gmail.com)]

http://forums.java.net/jive/thread.jspa?messageID=367088