<div dir="ltr"><div>Thanks for the quick reply.</div><div><br></div>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.<div><br></div>
<div>I know my code handles the "multiple" flag, but don't know about NAcks.</div><div>I don't really know how to test for nacks since I've never gotten them from rabbitmq server.</div><div><br></div>
<div>Once I know my code handles all responses correctly I will create a pull request for the pika example code.</div><div><br><div class="gmail_quote">On Mon, Nov 28, 2011 at 1:01 PM, Marek Majkowski <span dir="ltr"><<a href="mailto:majek04@gmail.com">majek04@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi,<br>
<br>
I'm not sure if it works - but the pika example showing<br>
publisher confirms usage looks rather similar:<br>
<br>
<a href="https://github.com/pika/pika/blob/120fdea5913e7ed80536ff55634ab0f8f4554e79/examples/demo_send_confirmed.py" target="_blank">https://github.com/pika/pika/blob/120fdea5913e7ed80536ff55634ab0f8f4554e79/examples/demo_send_confirmed.py</a><br>
<br>
Cheer,<br>
Marek<br>
<div><div class="h5"><br>
On Sun, Nov 27, 2011 at 15:20, bergundy <<a href="mailto:roey.berman@gmail.com">roey.berman@gmail.com</a>> wrote:<br>
> Hi everyone,<br>
><br>
> I couldn't find code for implementing publisher confirmations.<br>
><br>
> I wrote this piece of code using pika 0.9.5 (python client).<br>
> Would like to get feedback on this, I hope I got it right ...<br>
><br>
> ---<br>
> class ConfirmingProducer(object):<br>
> def __init__(self, channel):<br>
> self.delivery_tag = 1<br>
> self.acked = 0<br>
> self._callbacks = {}<br>
> self.chan = channel<br>
> self.chan.confirm_delivery(self.on_delivered)<br>
><br>
> def publish(self, message, callback, **kwargs):<br>
> self._callbacks[self.delivery_tag] = callback<br>
> self.delivery_tag += 1<br>
> self.chan.basic_publish(message, **kwargs)<br>
><br>
> def on_delivered(self, frame):<br>
> success = isinstance(frame.method, pika.spec.Basic.Ack)<br>
><br>
> if frame.method.multiple:<br>
> for dtag in range(self.acked+1, frame.method.delivery_tag<br>
> +1):<br>
> self._callbacks.pop(dtag)(success)<br>
> self.acked = frame.method.delivery_tag<br>
> else:<br>
> self._callbacks.pop(frame.method.delivery_tag)(success)<br>
> self.acked += 1<br>
</div></div>> _______________________________________________<br>
> rabbitmq-discuss mailing list<br>
> <a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br>
> <a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
><br>
</blockquote></div><br></div></div>