Search code examples
spring-amqpspring-rabbit

spring amqp ConfirmCallback CorrelationData is null sometimes


I enable publish confirm, and call RabbitTemplate send method with CorrelationData. But when i get CorrelationData in ConfirmCallback, sometimes CorrelationData is null and ack is true. I must add judgement Correlation!=null.

Is it a normal behavior in spring amqp?


Solution

  • If you configure the RabbitTemplate to support confirms you have to provide correlation data.

    If you invoke a send method with no correlation data parameter or with a null argument, you will get null in the callback.

    The intention is that, if you want confirmations, you need to provide correlation data for every send (so you can determine which send the confirmation is for).