<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"><<a href="mailto:mikeb@rabbitmq.com">mikeb@rabbitmq.com</a>></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 <<a href="mailto:pathsny@gmail.com" target="_blank">pathsny@gmail.com</a> <mailto:<a href="mailto:pathsny@gmail.com" target="_blank">pathsny@gmail.com</a>>> wrote:<br>
<br>
� �well actually we'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'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'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 <<a href="mailto:mikeb@rabbitmq.com" target="_blank">mikeb@rabbitmq.com</a><br></div><div><div class="h5">
� �<mailto:<a href="mailto:mikeb@rabbitmq.com" target="_blank">mikeb@rabbitmq.com</a>>> wrote:<br>
<br>
� � � �vishnu wrote:<br>
� � � � > we have scenarios where we pick up a message at a time,<br>
� � � �perform a bunch<br>
� � � � > of operations, publish a new message and then ack the message<br>
� � � �we just<br>
� � � � > picked up. Recently we have started to publish the new<br>
� � � �message inside a<br>
� � � � > transaction since this guarantees that the message is<br>
� � � �persisted (it's a<br>
� � � � > persistent message), since we want to minimize the odds of<br>
� � � �message loss.<br>
� � � � > However, we have started to notice that the original message<br>
� � � �we pick up<br>
� � � � > is marked as unacknowledged after we complete our process. Is<br>
� � � �there<br>
� � � � > something fundamentally wrong in what we're doing, or is our<br>
� � � �approach<br>
� � � � > 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'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'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>
� � � �<mailto:<a href="mailto:rabbitmq-discuss@lists.rabbitmq.com" target="_blank">rabbitmq-discuss@lists.rabbitmq.com</a>><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>