You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Jason Jones <ja...@verizon.net> on 2009/08/31 18:33:08 UTC

Processing then acknowledging message from broker.

Hello,


I am interested in writing a message consumer that cannot tolerate 
message loss. In the event that the message consumer crashes while 
processing a message I want the consumer to be able to restart and 
process the same message that it was working on when it crashed. I am 
assuming that it is possible to receive a message, while leaving on the 
broker, then process it, and then acknowledge to the broker that the 
message was processed thus removing it from the queue. Can someone 
explain and provide an example of how to receive a message from the 
broker, then process the message, and then acknowledge the message?  If 
it doesn't work this way can you explain to me then how to implement 
this functionality?

Thanks,
Jason Jones


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: Processing then acknowledging message from broker.

Posted by Carl Trieloff <cc...@redhat.com>.
Jason Jones wrote:
> John thanks for replying.  I am using the C++ QPID client library.  I 
> am using the SubscriptionManager and MessageListener classes to 
> receive a message.  So are you saying that when the method 
> MessageListener::received() is called the message is received, but 
> still on the queue in the broker, then after 
> MessageListener::received() returns the message is acknowledged and 
> removed from the queue?
>


whether the received message needs to be accepted or not is specified 
when the subscriber is created. That is controlled by the subscription 
options.

Carl.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: Processing then acknowledging message from broker.

Posted by Gordon Sim <gs...@redhat.com>.
On 08/31/2009 06:25 PM, Jason Jones wrote:
> John thanks for replying.  I am using the C++ QPID client library.  I am
> using the SubscriptionManager and MessageListener classes to receive a
> message. So are you saying that when the method
> MessageListener::received() is called the message is received, but still
> on the queue in the broker, then after MessageListener::received()
> returns the message is acknowledged and removed from the queue?

Yes, with the default subscription settings, that is indeed the case.


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: Processing then acknowledging message from broker.

Posted by Jason Jones <ja...@verizon.net>.
John thanks for replying.  I am using the C++ QPID client library.  I am 
using the SubscriptionManager and MessageListener classes to receive a 
message.  So are you saying that when the method 
MessageListener::received() is called the message is received, but still 
on the queue in the broker, then after MessageListener::received() 
returns the message is acknowledged and removed from the queue?

Thanks,
Jason Jones

John Dennis wrote:
> On 08/31/2009 12:33 PM, Jason Jones wrote:
>> Hello,
>>
>>
>> I am interested in writing a message consumer that cannot tolerate
>> message loss. In the event that the message consumer crashes while
>> processing a message I want the consumer to be able to restart and
>> process the same message that it was working on when it crashed. I am
>> assuming that it is possible to receive a message, while leaving on the
>> broker, then process it, and then acknowledge to the broker that the
>> message was processed thus removing it from the queue. Can someone
>> explain and provide an example of how to receive a message from the
>> broker, then process the message, and then acknowledge the message? If
>> it doesn't work this way can you explain to me then how to implement
>> this functionality?
>
> This is how AMQP clients already work. You read a message and then you 
> "accept" the message after having fully processed it. When you accept 
> the message you're telling the broker you're done with it.
>
> You didn't say which language you're using, the symbol names are 
> slightly different, but you'll want to look for "accept" in the symbol 
> name. In C++ look for accept(), acceptMode, getUnaccepted(), etc. Also 
> checkout acquireMode and acquire*, they may also be of use to you.
>
>
>


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: Processing then acknowledging message from broker.

Posted by John Dennis <jd...@redhat.com>.
On 08/31/2009 12:33 PM, Jason Jones wrote:
> Hello,
>
>
> I am interested in writing a message consumer that cannot tolerate
> message loss. In the event that the message consumer crashes while
> processing a message I want the consumer to be able to restart and
> process the same message that it was working on when it crashed. I am
> assuming that it is possible to receive a message, while leaving on the
> broker, then process it, and then acknowledge to the broker that the
> message was processed thus removing it from the queue. Can someone
> explain and provide an example of how to receive a message from the
> broker, then process the message, and then acknowledge the message? If
> it doesn't work this way can you explain to me then how to implement
> this functionality?

This is how AMQP clients already work. You read a message and then you 
"accept" the message after having fully processed it. When you accept 
the message you're telling the broker you're done with it.

You didn't say which language you're using, the symbol names are 
slightly different, but you'll want to look for "accept" in the symbol 
name. In C++ look for accept(), acceptMode, getUnaccepted(), etc. Also 
checkout acquireMode and acquire*, they may also be of use to you.



-- 
John Dennis <jd...@redhat.com>

Looking to carve out IT costs?
www.redhat.com/carveoutcosts/

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org