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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With