[rabbitmq-discuss] publisher confirmations

Marek Majkowski majek04 at gmail.com
Mon Nov 28 11:26:14 GMT 2011


On Mon, Nov 28, 2011 at 11:11, Roey Berman <roey.berman at gmail.com> wrote:
> Oh one fix:
> self.chan.basic_publish(message, **kwargs) -> self.chan.basic_publish(body =
> message, **kwargs)
>
> On Mon, Nov 28, 2011 at 1:08 PM, Roey Berman <roey.berman at gmail.com> wrote:
>>
>> Thanks for the quick reply.
>> At first I used the code from the example you referred me to but it
>> doesn't handle the "multiple" flag and NAcks from the server.
>> I know my code handles the "multiple" flag, but don't know about NAcks.
>> I don't really know how to test for nacks since I've never gotten them
>> from rabbitmq server.

http://www.rabbitmq.com/extensions.html#publishing

"In exceptional cases when the broker is unable to handle messages
successfully, instead of a basic.ack, the broker will send a
basic.nack. In this context, fields of the basic.nack have the same
meaning as the corresponding ones in basic.ack and the requeue field
should be ignored. By nack'ing one or more messages, the broker
indicates that it was unable to process the messages and refuses
responsibility for them; at that point, the client may choose to
re-publish the messages.

After a channel is put into confirm mode, all subsequently published
messages will be confirmed or nack'd once. No guarantees are made as
to how soon a message is confirmed. No message will be both confirmed
and nack'd."

That's all I know.


>> Once I know my code handles all responses correctly I will create a pull
>> request for the pika example code.

Good!

Marek


>> On Mon, Nov 28, 2011 at 1:01 PM, Marek Majkowski <majek04 at gmail.com>
>> wrote:
>>>
>>> Hi,
>>>
>>> I'm not sure if it works - but the pika example showing
>>> publisher confirms usage looks rather similar:
>>>
>>>
>>> https://github.com/pika/pika/blob/120fdea5913e7ed80536ff55634ab0f8f4554e79/examples/demo_send_confirmed.py
>>>
>>> Cheer,
>>>  Marek
>>>
>>> On Sun, Nov 27, 2011 at 15:20, bergundy <roey.berman at gmail.com> wrote:
>>> > Hi everyone,
>>> >
>>> > I couldn't find code for implementing publisher confirmations.
>>> >
>>> > I wrote this piece of code using pika 0.9.5 (python client).
>>> > Would like to get feedback on this, I hope I got it right ...
>>> >
>>> > ---
>>> > class ConfirmingProducer(object):
>>> >    def __init__(self, channel):
>>> >        self.delivery_tag = 1
>>> >        self.acked        = 0
>>> >        self._callbacks   = {}
>>> >        self.chan = channel
>>> >        self.chan.confirm_delivery(self.on_delivered)
>>> >
>>> >    def publish(self, message, callback, **kwargs):
>>> >        self._callbacks[self.delivery_tag] = callback
>>> >        self.delivery_tag += 1
>>> >        self.chan.basic_publish(message, **kwargs)
>>> >
>>> >    def on_delivered(self, frame):
>>> >        success = isinstance(frame.method, pika.spec.Basic.Ack)
>>> >
>>> >        if frame.method.multiple:
>>> >            for dtag in range(self.acked+1, frame.method.delivery_tag
>>> > +1):
>>> >                self._callbacks.pop(dtag)(success)
>>> >            self.acked = frame.method.delivery_tag
>>> >        else:
>>> >            self._callbacks.pop(frame.method.delivery_tag)(success)
>>> >            self.acked += 1
>>> > _______________________________________________
>>> > 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