activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bruce Snyder <>
Subject Re: How to tell if everything in a queue has been processed
Date Thu, 10 Sep 2009 14:31:40 GMT
On Sun, Aug 9, 2009 at 8:32 AM, amp834 <> wrote:
> I'm using ActiveMQ to "Submit a job" to queue "Job53" (a queue for each job),
> with (say) 500 subtasks, and want to know when the 500 items have been
> processed completely.  I thought of creating a queue just for that job,
> writing 500 messages to it, and when the 500 messages have been processed,
> the job is done.
> Is there a way to tell if a queue is empty?  (no messages in the queue, no
> messages that a consumer has taken but has not finished processing)?
> I found an old post, but it's so old that I thought I'd ask the question
> again.

IMO, you shouldn't use messaging with a client/server mind set of
querying the message broker. Instead, you should utilize a
messaging-based approach to the problem. I suggest using asynchronous
messaging for such designs whereby messages are sent to another queue
to indicate that a job/message has been processed. By sending a
message to a different queue upon completion of such processing, the
client can poll for messages on that queue and know immediately when
the processing is complete. There's a pattern in the EIP book that
covers event messages, see the following:

You could also consider using request/reply messaging on a per message
basis. For each request message that is sent to one queue, processing
is completed a reply message is sent to a different queue to indicate
that processing of that message has completed. The EIP book has an
example for request/reply style of messaging available here:

There are many such patterns in the EIP book for messaging-based
design. Additionally, you may want to take a look at Apache Camel, an
integration framework that is designed to provide ease of
implementation for the EIP patterns. Also, Camel integrates easily
with ActiveMQ and many other technologies:

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