0

I have one resque job which is run at some event which finally publishes the message to RabbitMQ's exchange, how can I check in bunny(Rabbit MQ ruby client) that whether the message has been successfully published?

Using Acknowledgment or any way?

Thanks in advance!

kamal
  • 996
  • 15
  • 25

2 Answers2

1

When you execute the publish you are not sure that the message is published on the queue.

If you want to be sure you have to use you have to use publish confirm or tx transaction.

Read this post http://www.rabbitmq.com/blog/2011/02/10/introducing-publisher-confirms/

Note: By default the clients don't have any HA policy, you have to implement it. See the section Streaming Lightweight Publisher Confirms:

private volatile SortedSet<Long> unconfirmedSet =

    Collections.synchronizedSortedSet(new TreeSet());

...

ch.setConfirmListener(new ConfirmListener() {
    public void handleAck(long seqNo, boolean multiple) {
        if (multiple) {
            unconfirmedSet.headSet(seqNo+1).clear();
        } else {
            unconfirmedSet.remove(seqNo);
        }
    }
    public void handleNack(long seqNo, boolean multiple) {
        // handle the lost messages somehow
    }
});

Note2: the message is never "put" inside an exchange, but always inside a queue.

Gabriele Santomaggio
  • 21,656
  • 4
  • 52
  • 52
0

Once the publish method returns, the message has published to the queue. There is no deferred action to publishing a message.

Michael Gaskill
  • 7,913
  • 10
  • 38
  • 43
  • When you call `publish` method, it put it into the exchange, my question is what if rabbit MQ server is down and my resque job is not able to publish, how to republish/retry? see this section **How Message Acknowledgements Relate to Transactions and Publisher Confirms** of link http://rubybunny.info/articles/queues.html#message_acknowledgements, It says what if S1 is down, This is what i am looking solution for. – kamal May 23 '16 at 07:49