On Tue, Sep 22, 2009 at 7:42 AM, Robert Nicholson <robert.nichol...@gmail.com> wrote: > I know of no way to only acknowledge what you've processed without > potentially acknowledging what you're might not have already processed. > > In order to ensure that all records I have received are processed I > currently store the state in the database such that if my process needs to > be > restarted without having processed what's been removed from the queue it can > consult the database to determine what's left to do. > > This obviously is a very expensive operation and I'm looking for ideas as to > how to avoid this? > > One way I found was to not do the processing in a separate thread. IF I > dispatch to "child queues" I can then have a transacted session and > have consumers/receivers attached to those queues such that I know when I've > committed the session I've processed what was received. I believe > it's still possible to commit messages that weren't processed but this seems > to have the semantics where if I rolled back the session the messages > are still left on the queue. > > When you introduce a thread pool and do the work in worker threads it then > becomes challenging to get the right semantics where you know > that if something hasn't been processed but a delivery attempt was made that > that will still be on the queue. JMS doesn't let me do anything > with the Session in a worker thread except close it. I cannot commit or > acknowledge in a worker thread. ie. the place where I know I've fully > processed the message or not. > > Looking for ideas.
Oh, are you talking about how calling message.acknowledge() acks all messages on the session rather than just a single message? Starting in ActiveMQ 5.2.0, a new ack mode was added named INDIVIDUAL_ACKNOWLEDGE that is used to ack messages individually: http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/ActiveMQSession.html#INDIVIDUAL_ACKNOWLEDGE Does this help your scenario? Bruce -- perl -e 'print unpack("u30","D0G)u8...@4vyy9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*" );' ActiveMQ in Action: http://bit.ly/2je6cQ Blog: http://bruceblog.org/ Twitter: http://twitter.com/brucesnyder