10

In the Spring AMQP Project, if messageProperties does not have messageId, they always create messageId.

Like This..

if (this.createMessageIds && messageProperties.getMessageId()==null) {
  messageProperties.setMessageId(UUID.randomUUID().toString());
}

I want to know what messageId is. So, I try to find out where messageId is used. But I couldn't find it in Spring AMQP Source.

What happens if messageId does not exist? Why is messageId needed in AMQP?

Mark Chackerian
  • 21,866
  • 6
  • 108
  • 99
Minwoo
  • 213
  • 4
  • 12

1 Answers1

18

The message id is only created if the converter's createMessageIds is true - it is false by default.

It is normally not required, unless you are using stateful retry on the consumer side.

When using stateful retry and a delivery fails, the message is rejected and redelivered by the broker. Since RabbitMQ does not include the number of retries in a header, we have to keep track of how many times the delivery has been attempted so that we can give up after the maxAttempts is reached. The message id is used to look up the retry state for this message.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179