RabbitMQ之tutorial-7

RabbitMQ之tutorial-7

Tutorial Seven

https://www.rabbitmq.com/tutorials/tutorial-seven-java.html

Publisher confirms are a RabbitMQ extension to implement reliable publishing.

confirmSelect

Strategy #1: Publishing Messages Individually

it significantly slows down publishing,as the confirmation of a message blocks the publishing of all subsequent messages.

Strategy #2: Publishing Messages in Batches

One drawback is that we do not know exactly what went wrong in case of failure, so we may have to keep a whole batch in memory to log something meaningul or to re-publish the messages.

Strategy #3: Handling Publisher Confirms Asynchronously

2 callbacks: one for confirmed messages and one for nack-ed messages

  • sequence number: a number that identifies the confirmed or nack-ed message. We will see shortly how to correlate it with the published message.

  • multiple: this is a boolean value. If false, only one message is confirmed/nack-ed, if true, all messages with a lower or equal sequence number are confirmed/nack-ed.

correlate messages:

Screen Shot 2020-07-22 at 10.15.46 PM
  • provide a way to correlate the publishing sequence number with a message.
  • register a confirm listener on the channel to be notified when publisher acks/nacks arrive to perform the appropriate actions, like logging or re-publishing a nack-ed message. The sequence-number-to-message correlation mechanism may also require some cleaning during this step.
  • track the publishing sequence number before publishing a message.
Screen Shot 2020-07-22 at 10.16.12 PM