Simon MacMullen <simon at rabbitmq.com> writes:
On 05/05/11 22:33, Elias Levy wrote:
While writing some code using the Ruby AMQP gem against RabbitMQ, I've
noticed that if I publish a message and quickly close the connection,
even though I've received a publish-ok response from the server, the
message fails to be queued by the broker.
I'm not at all familiar with the Ruby client, but I should point out
that unlike many of the other AMQP methods, basic.publish does not
have a corresponding basic.publish-ok method; it's always
asynchronous. So I imagine the post-publish callback fires

In order to be able to know when the broker has taken responsibility
for a message you can either wrap the publish in a transaction (when
you see tx.commit-ok you know the server has the message) or use the
rather more lightweight publish confirms: o>
Another way to solve the problem is to do a synchronous AMQP method
rather than abruptly closing the connection. If this the sync method
completes successfully, you can be sure that your published messages
have reached the broker (it doesn't give you all the guarantees of
transactions, but it is much lighter weight).

An easy way to do this with all versions of the AMQP gem (even 0.6.7) is
to use the AMQP#close callback. E.g., add something like this to your

client.close { puts "Closed ok" ; EM.stop }


David Wragg
Staff Engineer, RabbitMQ
VMware, Inc.

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 3 of 22 | next ›
Discussion Overview
grouprabbitmq-discuss @
postedMay 5, '11 at 9:33p
activeJul 11, '11 at 12:35p



site design / logo © 2022 Grokbase