[rabbitmq-discuss] publishing inside a transaction before acking

vishnu pathsny at gmail.com
Wed May 19 07:00:51 BST 2010


resending this to the list :)

On Tue, May 18, 2010 at 7:59 PM, vishnu <pathsny at gmail.com> 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.
>
> On Tue, May 18, 2010 at 4:34 PM, Michael Bridgen <mikeb at rabbitmq.com>wrote:
>
>> vishnu wrote:
>> > we have scenarios where we pick up a message at a time, perform a bunch
>> > of operations, publish a new message and then ack the message we just
>> > picked up. Recently we have started to publish the new message inside a
>> > transaction since this guarantees that the message is persisted (it's a
>> > persistent message), since we want to minimize the odds of message loss.
>> > However, we have started to notice that the original message we pick up
>> > is marked as unacknowledged after we complete our process. Is there
>> > something fundamentally wrong in what we're doing, or is our approach
>> > correct?
>>
>> The approach is correct.  What order are you doing things in?
>> 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 --
>>
>> basic.publish(new_message)
>> tx.commit()
>> basic.ack(old_message)
>>
>> the state at this point is a published message, and an uncommitted
>> transaction with the ack.  If you do this:
>>
>> basic.publish(new_message)
>> basic.ack(old_message)
>> tx.commit()
>>
>> then you'll have atomically acked the old message and published the new
>> one; which is, I believe, what you want.
>>
>>
>> Michael.
>>
>>
>> _______________________________________________
>> rabbitmq-discuss mailing list
>> rabbitmq-discuss at lists.rabbitmq.com
>> http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20100519/8017f715/attachment.htm 


More information about the rabbitmq-discuss mailing list