activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin C." <>
Subject Re: Question on consumers
Date Tue, 03 May 2011 12:13:25 GMT

the JMS threading model is based around the Session. Each Session is
to be used by one thread. If you are using asynchronous mode (you
register a MessageListener with the Session), every Session uses one
thread or is to be used by one thread
( If
you attach 5 consumers to a single session, only one of them will be
called. You need 5 Sessions with each 1 consumer in order to feed 5
consumers in parallel in asynchronous mode.

This is not strictly speaking the truth, because in theory you may use
a Session with more than one thread, but you need to ensure proper
synchronization. If you are using asynchronous messaging, the
following from
<quote>Each session must insure that it passes messages serially to
the listener. This means that a listener assigned to one or more
consumers of the same session can assume that the onMessage method is
not called with the next message until the session has completed the
last call.</quote>

So if you want to go parallel, you need to create more Sessions and

Best regards,

On Mon, May 2, 2011 at 11:50 AM, Don Santillan <> wrote:
> Hello,
> I have a basic question about message consumers that I really need to
> confirm that my understanding is correct.
> Do message consumers run in different threads?
> Suppose I have 5 consumers assigned to a queue. Are these consumers
> independent with each other and are running in different threads?
> Thanks!

View raw message