[rabbitmq-discuss] Published message not queued after publish-ok received when connection quickly closed

Matthias Radestock matthias at rabbitmq.com
Mon Jul 11 13:35:12 BST 2011


Michael,

On 08/07/11 17:37, Michael Nacos wrote:
> the code is similar to the one I originally posted
>
>      @queue1.subscribe(:ack => true) do |metadata, data|
>        @channel.tx_select
>        @channel.default_exchange.publish(data, \
>          :routing_key => @deliver_to, \
>          :persistent => true, \
>          :nowait => false)
>        puts '.'
>        @channel.tx_commit
>        metadata.ack
>        @channel.tx_commit # <-- if not present, there is always one
> unacked msg in @queue1
>      end
>
> it wasn't hanging, but because of the tx_select, the ack didn't happen
> until the next time the consume callback was run, which I fixed by
> introducing another tx_commit right after the ack. mind you, with one
> tx_commit right after metadata.ack I lost messages.

Under what circumstances did messages get lost? When killing the broker?

I could see that happening if the broker is killed during the tx.commit 
- the 'ack' may get processed before the 'publish', and if the broker is 
nuked in-between the latter would get lost.

'confirms' would be a better way to handle the above scenario, i.e. wait 
for confirmation of the 'publish' and only then send the ack.

Regards,

Matthias.


More information about the rabbitmq-discuss mailing list