activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eugeny N Dzhurinsky <>
Subject Re: CLIENT_ACKNOWLEDGE mode for a session misunderstanding?
Date Wed, 29 Oct 2008 15:07:22 GMT
On Tue, Oct 28, 2008 at 05:44:26PM +0000, James Strachan wrote:
> 2008/10/28 Eugeny N Dzhurinsky <>:
> > Hello!
> >
> > I am facing some strange issue with acknowledge mode in ActiveMQ. After
> > reading the specs, I realized the broker will never deliver a message to the
> > consumer unless the consumer acknowledges the previous message. So I thought
> > it is enough to not send the acknowledgement message to the server in the
> > onMessage method of the consumer and sent it later from another thread, which
> > does it's job. This means I spawn a thread when onMessage is called and forget
> > about it in this method.
> You should only be using a JMS session from one thread at once - so
> you should call message.acknowlege() from the consumer thread.

   final MessageConsumer consumer = serverSession
   consumer.setMessageListener(new MessageListener() {

       public void onMessage(final Message message) {
           System.out.println("Got message");
           try {
               // message.acknowledge();
           } catch (final Exception e) {


Calling or not calling acknowledge doesn't make any difference - as soon as
onMessage returns, the next message is delivered to the consumer.

> If you don't want the message broker to send another message to the
> consumer until it is acknowledged, set prefetch to 1

   private static final String CONNECTION_URL = "vm://localhost?broker.persistent=false&jms.prefetchPolicy.all=1";

I am doing in this way, as can be found in the source I originally posted.

So is there a bug in ActiveMQ regarding the acknowledge mode or I still
missing something?

Eugene N Dzhurinsky

View raw message