[rabbitmq-discuss] Transactions on acks
matthew at lshift.net
Wed Jan 6 11:26:51 GMT 2010
On Thu, Dec 31, 2009 at 10:21:30AM +0530, vishnu wrote:
> I'm trying to understand how transactions help on the ack side of things.
> I can understand how I'd do a tx_select, a basic ack, my processing and then
> a tx_commit.
You could do that, yes. But that's not the usual case. The usual case on
consumption is to just ack when you're done with processing a message -
no need to use tx at that point.
However, if, as part of your processing, you need to both ack a message
and publish some other messages, then you may well want that to be an
atomic unit - i.e. either they both happen, or neither happen. So at
that point, you can set tx_commit on the channel, and then when
processing the received message, you can publish and ack and only when
you finally tx_commit, do the actions of your transaction take effect.
Thus if you crash, both the act and all publishes get forgotten.
> But when would I do a tx_rollback?
If, at the application level, you realise due to some external event
that you wish to cancel everything that you've done in this transaction,
More information about the rabbitmq-discuss