Hello <span class="gD">Marek,<br><br>Thanks for finding that annoying bug! Excellent!<br><br>In regards to publisher confirms, am I understanding correctly that to implement this with Net::Rabbitmq, I simply need to set no_ack =&gt; 0 (enabling acks), and then check for a defined delivery_tag, and if it is defined, then return ack, as so:<br>
<br>������� if ($consume_vars-&gt;{no_ack} == 0 &amp;&amp; defined($msg-&gt;{delivery_tag}))<br>������� {<br>��������������� #send the ack that the message was received successfully and return<br>��������������� eval{<br>
����������������������� $self-&gt;{_rabbit}-&gt;ack($self-&gt;{_channel}, $msg-&gt;{delivery_tag}, 0);<br>��������������� }; if ($@) { error_handler($self, &quot;ack - $@&quot;); }<br>������� }<br><br>Otherwise it wont return an ack and I assume stay in the queue. I haven&#39;t figured out how I would go about testing this other than perhaps timing the shut down of a consumer while it is consuming the message.<br>
<br>Thanks much for the tips!<br><br>-James<br></span><br><div class="gmail_quote">On Wed, Apr 4, 2012 at 3:57 AM, Marek Majkowski <span dir="ltr">&lt;<a href="mailto:majek04@gmail.com">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"><div class="im">On Tue, Apr 3, 2012 at 17:22, iceblaze &lt;<a href="mailto:iceblaze@gmail.com">iceblaze@gmail.com</a>&gt; wrote:<br>

&gt; Thanks for attempting to assist me here. I have made a light version of the<br>
&gt; module and a sender script as you requested. You can find the files here:<br>
&gt;<br>
&gt; <a href="http://iceblaze.com/rabbit.zip" target="_blank">http://iceblaze.com/rabbit.zip</a><br>
&gt;<br>
&gt; Simply unzip the files into the same directory and run the &quot;<a href="http://sender.pl" target="_blank">sender.pl</a>&quot;<br>
&gt; script. Note that you will need to install Net::RabbitMQ from CPAN. You can<br>
&gt; also modify the login credentials for rabbit (right now its just using<br>
&gt; guest/guest) in $self of Rabbit.pm&#39;s new() function:<br>
&gt;<br>
&gt; ������� my $self =<br>
&gt; ������� {<br>
&gt; ��������������� _rabbit =&gt; Net::RabbitMQ-&gt;new(),<br>
&gt; ��������������� _rabbit_user =&gt; &quot;guest&quot;,<br>
&gt; ��������������� _rabbit_pass =&gt; &quot;guest&quot;,<br>
&gt; ��������������� _rabbit_host =&gt; &quot;localhost&quot;,<br>
&gt; ��������������� _rabbit_port =&gt; 5672,<br>
&gt; ��������������� _queue =&gt; $queue,<br>
&gt; ��������������� _channel =&gt; $channel,<br>
&gt; ��������������� _no_ack =&gt; $no_ack,<br>
&gt; ��������������� _queue_declared =&gt; &#39;&#39;,<br>
&gt; ������� };<br>
<br>
</div>Oh, installing Net::RabbitMQ from CPAN wasn&#39;t easy at all!<br>
But in the end after few attempts &quot;cpan; notest install Net::RabbitMQ&quot;<br>
did the trick.<br>
<br>
So, the problem is that in your code the &quot;delivery_mode =&gt; 2&quot;<br>
doesn&#39;t work.<br>
<br>
(btw, I debugged your issue by using the management plugin and<br>
getting a message from the queue using it - it clearly shows<br>
that &quot;delivery_mode&quot; is not set)<br>
<br>
Reading the docs:<br>
<a href="http://search.cpan.org/%7Ejesus/Net--RabbitMQ-0.2.2/RabbitMQ.pm" target="_blank">http://search.cpan.org/~jesus/Net--RabbitMQ-0.2.2/RabbitMQ.pm</a><br>
<br>
 � �publish($channel, $routing_key, $body, $options, $props)<br>
 � �[...]<br>
 � �$props is an optional hash (the AMQP &#39;props&#39;) respecting the<br>
following keys: { content_type =&gt; $string, content_encoding =&gt;<br>
$string, correlation_id =&gt; $string, reply_to =&gt; $string, expiration =&gt;<br>
$string, message_id =&gt; $string, type =&gt; $string, user_id =&gt; $string,<br>
app_id =&gt; $string, delivery_mode =&gt; $integer, priority =&gt; $integer,<br>
timestamp =&gt; $integer, }<br>
<br>
So, &quot;delivery_mode&quot; is a feature of &quot;props&quot;, not &quot;options&quot;.<br>
Appropriate code should therefore look like:<br>
<br>
 � �$self-&gt;{_rabbit}-&gt;publish($self-&gt;{_channel}, $self-&gt;{_queue},<br>
$data, {mandatory =&gt; 1, immediate =&gt; 0 }, {delivery_mode =&gt; 2});<br>
<br>
<br>
Additionally, if you want to shield against broker falling down,<br>
and have a reliable message delivery you should be using<br>
transactions or publish confirms.<br>
<br>
By default sending messages in rabbit is asynchronous. You don&#39;t know<br>
when the message reached the broker and even if it did so.<br>
Rabbit recognizes this and it doesn&#39;t immediately flush messages<br>
to disk. Actually it will be quire reluctant to save them on disk<br>
(this has been tweaked in RabbitMQ 2.8.0).<br>
<br>
If you wish to make sure that Rabbit indeed handled messages<br>
reliably, you must use transactions or publisher confirms to<br>
get a confirmation of delivery from the broker.<br>
Once the confirmation is received you can be sure the messages<br>
are safe.<br>
<br>
On the other hand if you are only going to be closing rabbit<br>
gracefully (via the init scripts), setting the &quot;delivery_mode&quot;<br>
properly should be enough to persist your messages.<br>
<span class="HOEnZb"><font color="#888888"><br>
Marek<br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br>&quot;Of course, the actual government of any computer is run by that fascist dictator known as the operating system. But a wise dictator knows when to let the people think they&#39;re capitalists--and when to let them think they&#39;re communists.&quot; - Programming Perl third edition<br>