[rabbitmq-discuss] Transactions

Matthias Radestock matthias at rabbitmq.com
Tue Jan 8 00:47:37 GMT 2013


On 08/01/13 00:34, CJ wrote:
> I have my producer send another 100 messages.
> But this time I have the consumer only read 50 persistent messages with
> a txcommit.
> I read in all of the first 50 messages correctly.
> So I run the consumer again, hoping to get the next 50, but this time it
> does not see any persistent Tx on the Q, and receive zero messages.

 From http://www.rabbitmq.com/semantics.html#tx
<quote>
AMQP transactions only apply to publishes and acks. [...] On the 
consuming side, the acknowledgements are transactional, not the 
consuming of the messages themselves.
</quote>

So for your test to work the way you expect, it needs to a) consume in 
ack-mode, and b) ack all the received messages, before issuing the 
tx.commit.

As an aside, the tx mode doesn't actually buy you much on the consuming 
side; you are probably better off consuming & ack'ing on a 
non-transactional channel. And on the producing side 'confirms' 
(http://www.rabbitmq.com/confirms.html) are more efficient than 
transactions and provide most of the same guarantees.

Regards,

Matthias.


More information about the rabbitmq-discuss mailing list