[rabbitmq-discuss] publishing inside a transaction before acking

Matthias Radestock matthias at rabbitmq.com
Wed May 19 07:22:57 BST 2010

vishnu wrote:
>     well actually we're doing
>     basic.consume
>     some stuff
>     tx.select
>     basic.publish
>     tx.commit
>     some stuff
>     basic.ack
>     currently, we're  trying to make sure the publish is inside a
>     transaction. 

As Michael pointed out ...
Transactions are implicitly started immediately after a commit or 
rollback, and acknowledgements are transactional, so if you're
committing after the publish but before the ack [which is exactly what 
you are doing] then the state at this point is a published message, and 
an uncommitted transaction with the ack.

Unless the code does a subsequent commit the ack will be lost.

You either need to
a) issue a second commit, after the ack,
b) move the ack to before the first commit, or
c) use two channels - one for consuming and acking non-transactionally, 
and the other for publishing transactionally.



More information about the rabbitmq-discuss mailing list