<div>aha thanks. I sorta get it now<br></div><div><br></div><div>why does rabbitmq implicitly start a transaction after a commit. Does this mean after a commit every single operation now has to be transactional?</div><div>
thanks</div><br><div class="gmail_quote">On Wed, May 19, 2010 at 2:50 PM, Michael Bridgen <span dir="ltr">&lt;<a href="mailto:mikeb@rabbitmq.com">mikeb@rabbitmq.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"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Tue, May 18, 2010 at 7:59 PM, vishnu &lt;<a href="mailto:pathsny@gmail.com" target="_blank">pathsny@gmail.com</a> &lt;mailto:<a href="mailto:pathsny@gmail.com" target="_blank">pathsny@gmail.com</a>&gt;&gt; wrote:<br>
<br>
 � �well actually we&#39;re doing<br>
 � �basic.consume<br>
<br>
 � �some stuff<br>
 � �tx.select<br>
 � �basic.publish<br>
 � �tx.commit<br>
<br>
 � �some stuff<br>
 � �basic.ack<br>
<br>
 � �currently, we&#39;re �trying to make sure the publish is inside a<br>
 � �transaction. <br>
</blockquote>
<br></div>
Right, that fits the first pattern. �You will want to move the ack inside the transaction. �Then the ack of the old incoming message will happen atomically with publishing the outgoing message, and you won&#39;t see a published outgoing message along with an unacked incoming message.<div class="im">
<br>
<br>
 � � basic.consume<br>
<br>
 � � some stuff<br>
 � � tx.select<br>
 � � basic.publish<br>
<br></div>
 � � some stuff<br>
 � � basic.ack<br>
 � � tx.commit<br>
<br>
<br>
Michael.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
 � �On Tue, May 18, 2010 at 4:34 PM, Michael Bridgen &lt;<a href="mailto:mikeb@rabbitmq.com" target="_blank">mikeb@rabbitmq.com</a><br></div><div><div class="h5">
 � �&lt;mailto:<a href="mailto:mikeb@rabbitmq.com" target="_blank">mikeb@rabbitmq.com</a>&gt;&gt; wrote:<br>
<br>
 � � � �vishnu wrote:<br>
 � � � � &gt; we have scenarios where we pick up a message at a time,<br>
 � � � �perform a bunch<br>
 � � � � &gt; of operations, publish a new message and then ack the message<br>
 � � � �we just<br>
 � � � � &gt; picked up. Recently we have started to publish the new<br>
 � � � �message inside a<br>
 � � � � &gt; transaction since this guarantees that the message is<br>
 � � � �persisted (it&#39;s a<br>
 � � � � &gt; persistent message), since we want to minimize the odds of<br>
 � � � �message loss.<br>
 � � � � &gt; However, we have started to notice that the original message<br>
 � � � �we pick up<br>
 � � � � &gt; is marked as unacknowledged after we complete our process. Is<br>
 � � � �there<br>
 � � � � &gt; something fundamentally wrong in what we&#39;re doing, or is our<br>
 � � � �approach<br>
 � � � � &gt; correct?<br>
<br>
 � � � �The approach is correct. �What order are you doing things in?<br>
 � � � �Transactions are implicitly started immediately after a commit or<br>
 � � � �rollback, and acknowledgements are transactional, so if you&#39;re<br>
 � � � �committing after the publish but before the ack --<br>
<br>
 � � � �basic.publish(new_message)<br>
 � � � �tx.commit()<br>
 � � � �basic.ack(old_message)<br>
<br>
 � � � �the state at this point is a published message, and an uncommitted<br>
 � � � �transaction with the ack. �If you do this:<br>
<br>
 � � � �basic.publish(new_message)<br>
 � � � �basic.ack(old_message)<br>
 � � � �tx.commit()<br>
<br>
 � � � �then you&#39;ll have atomically acked the old message and published<br>
 � � � �the new<br>
 � � � �one; which is, I believe, what you want.<br>
<br>
<br>
 � � � �Michael.<br>
<br>
<br>
 � � � �_______________________________________________<br>
 � � � �rabbitmq-discuss mailing list<br>
 � � � �<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com" target="_blank">rabbitmq-discuss@lists.rabbitmq.com</a><br></div></div>
 � � � �&lt;mailto:<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com" target="_blank">rabbitmq-discuss@lists.rabbitmq.com</a>&gt;<div class="im"><br>
 � � � �<a href="http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
<br>
<br>
<br>
<br></div>
------------------------------------------------------------------------<div class="im"><br>
<br>
_______________________________________________<br>
rabbitmq-discuss mailing list<br>
<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com" target="_blank">rabbitmq-discuss@lists.rabbitmq.com</a><br>
<a href="http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss" target="_blank">http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br>
</div></blockquote>
<br>
</blockquote></div><br>