[rabbitmq-discuss] publisher confirmations

Roey Berman roey.berman at gmail.com
Mon Nov 28 11:08:34 GMT 2011


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.

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

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
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20111128/b40ae62e/attachment.htm>


More information about the rabbitmq-discuss mailing list