activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruce Snyder <>
Subject Re: what is best practices to implement Multithread + JMS ?
Date Wed, 23 Sep 2009 16:34:35 GMT
On Tue, Sep 22, 2009 at 7:42 AM, Robert Nicholson
<> 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:

Does this help your scenario?

perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"

ActiveMQ in Action:

View raw message