Reputation: 61
I'm working with RabbitMQ in java. I'd like to publish multiple messages, knowing if the broker recieved it or not. Note that i don't want to know if the message was acknowledged or not. The examples I found seem to rely in the client sending a basicAck or Nack.
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
}
});
I only want to know if the message was recieved in the broker as a publisher, after a basicPublish.
Upvotes: 1
Views: 1023
Reputation: 4926
You are looking for publisher confirms.
The ACK's usage you are citing is for consumers, since RabbitMQ require a message to be ACKed, before removing it from its queues.
Note that receiving a confirm for a published message, does not imply that the message has been stored in a queue: that message can be "unroutable", and in this case the confirms are sent to the publisher immediately, but the message discarded. See: When will messages be confirmed
If you want to track also unroutable messages, you have to use Alternate Exchanges.
Upvotes: 1