You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Kim Garcia <js...@hotmail.com> on 2011/03/07 18:41:45 UTC

onMessage() always acknowledges msg even if Session is set to CLIENT_ACK

Hello All,
 
I am trying to set up a ring queue in which multiple clients will want to read the same messages. I set up my session as CLIENT_ACKNOWLEDGE, so that I will need to manually acknowledge the message (although I never intend to due to the multiple clients). I would like to use a MessageListener to be notified every time a new message arrives on the queue. So when onMessage() is called, I process the message, but then when onMessage() returns, it automatically acknowledges the messge. The problem is that once the message is acknowledged, the message will be thrown away and the other clients won't be able to get the message.
 
Is it possible to use the MessageListener to monitor the queue and call onMessage() to process the messages --- but NOT acknowledge the message?
 
Thank you. 		 	   		  

RE: onMessage() always acknowledges msg even if Session is set to CLIENT_ACK

Posted by Kim Garcia <js...@hotmail.com>.
PS. I am using Java 1.6
 
> From: jsmam97@hotmail.com
> To: users@qpid.apache.org
> Subject: onMessage() always acknowledges msg even if Session is set to CLIENT_ACK
> Date: Mon, 7 Mar 2011 11:41:45 -0600
> 
> 
> Hello All,
> 
> I am trying to set up a ring queue in which multiple clients will want to read the same messages. I set up my session as CLIENT_ACKNOWLEDGE, so that I will need to manually acknowledge the message (although I never intend to due to the multiple clients). I would like to use a MessageListener to be notified every time a new message arrives on the queue. So when onMessage() is called, I process the message, but then when onMessage() returns, it automatically acknowledges the messge. The problem is that once the message is acknowledged, the message will be thrown away and the other clients won't be able to get the message.
> 
> Is it possible to use the MessageListener to monitor the queue and call onMessage() to process the messages --- but NOT acknowledge the message?
> 
> Thank you. 
 		 	   		  

Re: onMessage() always acknowledges msg even if Session is set to CLIENT_ACK

Posted by Rajith Attapattu <ra...@gmail.com>.
Just to follow up on this.
I verified that if you don't ack the messages and once you close your
session, the messages are then put back on the queue with the redelivered
flag set.
So another consumer will get it.

Rajith

On Mon, Mar 7, 2011 at 6:07 PM, Rajith Attapattu <ra...@gmail.com> wrote:

> Hi Kim,
>
> I ran a test using MessageListener with CLIENT_ACKNOWLEDGE and it works as
> expected.
> I verified using logging that the message accept command is only sent if I
> call message.acknowledge() or session.acknowledge().
>
> Between how did you verify that the messages are acked ? is it using logs
> or using mgt tools ?
>
> However if I don't ack the messages and close the consumer, then another
> consumer should be getting the messages with the redelivered flag set.
> But in my testing it seems that the broker is not redelivering the
> messages. I will investigate this tomorrow and get back to you.
>
> Regards,
>
> Rajith
>
>
> On Mon, Mar 7, 2011 at 12:41 PM, Kim Garcia <js...@hotmail.com> wrote:
>
>>
>> Hello All,
>>
>> I am trying to set up a ring queue in which multiple clients will want to
>> read the same messages. I set up my session as CLIENT_ACKNOWLEDGE, so that I
>> will need to manually acknowledge the message (although I never intend to
>> due to the multiple clients). I would like to use a MessageListener to be
>> notified every time a new message arrives on the queue. So when onMessage()
>> is called, I process the message, but then when onMessage() returns, it
>> automatically acknowledges the messge. The problem is that once the message
>> is acknowledged, the message will be thrown away and the other clients won't
>> be able to get the message.
>>
>> Is it possible to use the MessageListener to monitor the queue and call
>> onMessage() to process the messages --- but NOT acknowledge the message?
>>
>> Thank you.
>
>
>

Re: onMessage() always acknowledges msg even if Session is set to CLIENT_ACK

Posted by Rajith Attapattu <ra...@gmail.com>.
Hi Kim,

I ran a test using MessageListener with CLIENT_ACKNOWLEDGE and it works as
expected.
I verified using logging that the message accept command is only sent if I
call message.acknowledge() or session.acknowledge().

Between how did you verify that the messages are acked ? is it using logs or
using mgt tools ?

However if I don't ack the messages and close the consumer, then another
consumer should be getting the messages with the redelivered flag set.
But in my testing it seems that the broker is not redelivering the messages.
I will investigate this tomorrow and get back to you.

Regards,

Rajith

On Mon, Mar 7, 2011 at 12:41 PM, Kim Garcia <js...@hotmail.com> wrote:

>
> Hello All,
>
> I am trying to set up a ring queue in which multiple clients will want to
> read the same messages. I set up my session as CLIENT_ACKNOWLEDGE, so that I
> will need to manually acknowledge the message (although I never intend to
> due to the multiple clients). I would like to use a MessageListener to be
> notified every time a new message arrives on the queue. So when onMessage()
> is called, I process the message, but then when onMessage() returns, it
> automatically acknowledges the messge. The problem is that once the message
> is acknowledged, the message will be thrown away and the other clients won't
> be able to get the message.
>
> Is it possible to use the MessageListener to monitor the queue and call
> onMessage() to process the messages --- but NOT acknowledge the message?
>
> Thank you.