Description
In what version(s) of Spring AMQP are you seeing this issue?
3.0.4
Describe the bug
When sending a message via delayed-message-exchange, and get the message via amqpTemplate, we get a null receivedDelay
To Reproduce
Send a message via delayed-message-exchange, with a delay of 5 seconds. The message will show up with x-delay of -5000 in the queue:
When using amqpTemplate to receive the message, it reaches DefaultMessagePropertiesConverter#toMessageProperties, the header value shows up as type Short:
Therefore the message will show up with receivedDelay as null.
While we are at it, we should also ensure receivedDelay is a positive number here, therefore a Math.abs() should help.
I did observe negative receivedDelay, but have not been able to reproduce it yet.
Expected behavior
The message should show up with receivedDelay as 5000
Sample
@SpringBootApplication
public class RabbitTestApplication implements CommandLineRunner {
@Autowired
private AmqpTemplate amqpTemplate;
public static void main(String[] args) {
SpringApplication.run(BunyipRabbitTestApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
Message message = amqpTemplate.receive("test-delay");
}
}