<div dir="ltr">Oh one fix:<div>self.chan.basic_publish(message, **kwargs) -&gt; self.chan.basic_publish(body = message, **kwargs)<br><br><div class="gmail_quote">On Mon, Nov 28, 2011 at 1:08 PM, Roey Berman <span dir="ltr">&lt;<a href="mailto:roey.berman@gmail.com">roey.berman@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><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&#39;t handle the &quot;multiple&quot; flag and NAcks from the server.<div>
<br></div>
<div>I know my code handles the &quot;multiple&quot; flag, but don&#39;t know about NAcks.</div><div>I don&#39;t really know how to test for nacks since I&#39;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><div class="h5"><div><br><div class="gmail_quote">On Mon, Nov 28, 2011 at 1:01 PM, Marek Majkowski <span dir="ltr">&lt;<a href="mailto:majek04@gmail.com" target="_blank">majek04@gmail.com</a>&gt;</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&#39;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><br>
On Sun, Nov 27, 2011 at 15:20, bergundy &lt;<a href="mailto:roey.berman@gmail.com" target="_blank">roey.berman@gmail.com</a>&gt; wrote:<br>
&gt; Hi everyone,<br>
&gt;<br>
&gt; I couldn&#39;t find code for implementing publisher confirmations.<br>
&gt;<br>
&gt; I wrote this piece of code using pika 0.9.5 (python client).<br>
&gt; Would like to get feedback on this, I hope I got it right ...<br>
&gt;<br>
&gt; ---<br>
&gt; class ConfirmingProducer(object):<br>
&gt;    def __init__(self, channel):<br>
&gt;        self.delivery_tag = 1<br>
&gt;        self.acked        = 0<br>
&gt;        self._callbacks   = {}<br>
&gt;        self.chan = channel<br>
&gt;        self.chan.confirm_delivery(self.on_delivered)<br>
&gt;<br>
&gt;    def publish(self, message, callback, **kwargs):<br>
&gt;        self._callbacks[self.delivery_tag] = callback<br>
&gt;        self.delivery_tag += 1<br>
&gt;        self.chan.basic_publish(message, **kwargs)<br>
&gt;<br>
&gt;    def on_delivered(self, frame):<br>
&gt;        success = isinstance(frame.method, pika.spec.Basic.Ack)<br>
&gt;<br>
&gt;        if frame.method.multiple:<br>
&gt;            for dtag in range(self.acked+1, frame.method.delivery_tag<br>
&gt; +1):<br>
&gt;                self._callbacks.pop(dtag)(success)<br>
&gt;            self.acked = frame.method.delivery_tag<br>
&gt;        else:<br>
&gt;            self._callbacks.pop(frame.method.delivery_tag)(success)<br>
&gt;            self.acked += 1<br>
</div></div>&gt; _______________________________________________<br>
&gt; rabbitmq-discuss mailing list<br>
&gt; <a href="mailto:rabbitmq-discuss@lists.rabbitmq.com" target="_blank">rabbitmq-discuss@lists.rabbitmq.com</a><br>
&gt; <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>
&gt;<br>
</blockquote></div><br></div></div></div></div>
</blockquote></div><br></div></div>