[rabbitmq-discuss] Consumer's confirm

Steve Powell steve at rabbitmq.com
Thu Jul 19 12:11:56 BST 2012


ML,

I realise that I haven't really answered your question:

>> what should I do to route consumers ack to producer?


The RabbitMQ broker isolates the publishers from knowledge of the
consumers and vice versa; this includes knowing if there are there and
have acknowledged the message. This makes it tricky to get RabbitMQ to
do what you want directly.

One way to achieve it is to use reply-to queues: temporary queues which
the publisher sets up (for a particular message, or for many messages)
which the consumer can then publish a response to. If the reply-to queue
is provided to the consumer with the published message, the consumer can
programmatically respond to the publisher without having to know who the
publisher is (or if it is available, etc.).

This mechanism is exploited in the RPC tutorial [1], which you should
read. With RPC, the client (caller) blocks until the reply is received;
but you might not want to do that. I'm sure this will help you to
implement a solution for your case.

Good luck,

Steve Powell
steve at rabbitmq.com
[wrk: +44-2380-111-528] [mob: +44-7815-838-558]

[1] http://www.rabbitmq.com/tutorials/tutorial-six-java.html

> ML,
> 
> The definitive guide to Publish-confirms is in the extensions
> documentation [1], where it says:
> 
>> By confirming a message the broker assumes responsibility for it and
>> indicates that it has done something it deems reasonable with it.
>> Unroutable mandatory or immediate messages are confirmed right after
>> thebasic.return. Transient messages are confirmed as soon as they arrive
>> on all the queues they were routed to. Persistent messages are confirmed
>> when all queues have either delivered the message and received an
>> acknowledgement (if required), or persisted the message.
> 
> Notice that a confirmation does not necessarily mean that a consumer has
> received and acknowledged the message; in general it means that RabbitMQ
> has successfully 'processed' the message, which might mean 'persisted' it, if
> it is persistent, or returned it, if it was unroutable (and marked
> mandatory), etc.
> 
> You may wish to investigate the 'immediate' and 'mandatory' flags. Be
> aware that you cannot use 'publisher confirms' on a transactional
> channel.
> 
> [1] http://www.rabbitmq.com/extensions.html#confirms
> 
> Steve Powell
> steve at rabbitmq.com
> [wrk: +44-2380-111-528] [mob: +44-7815-838-558]
> 
> On 19 Jul 2012, at 10:25, Mohsen Lotfizad wrote:
> 
>> Hi
>> 
>> I have a project that producers want to assure their message are delivered to consumers.
>> I make a Google search and find rabbitMQ transaction and confirm from (http://www.rabbitmq.com/blog/2011/02/10/introducing-publisher-confirms/) . I download discussed examples and run them. But I comment the consumer part. with my surprise producer gives ack, even if I uncomment  consumer part and send NACK instead of ack!
>> 
>> what should I do to route consumers ack to producer?
>> 
>> ps: does com.rabbitmq.client.Channel#addReturnListener helps me?
>> 
>> -- 
>> 
>> Sincerely 
>> ML
>> 
>> _______________________________________________
>> rabbitmq-discuss mailing list
>> rabbitmq-discuss at lists.rabbitmq.com
>> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
> 
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss



More information about the rabbitmq-discuss mailing list