У меня простая конфигурация RabbitMQ в Spring (не SpringBoot):
@Bean
public Queue queueTest() {
return QueueBuilder.durable("test")
.withArgument("x-dead-letter-exchange", "myexchange")
.withArgument("x-dead-letter-routing-key", "mykey")
.build();
}
@Bean
public Queue queueTestDlq() {
return new Queue("test.dlq", true);
}
@Bean
public Binding bindingTest(DirectExchange directExchange, Queue queueTest) {
return BindingBuilder
.bind(queueTest)
.to(directExchange)
.with("testkey");
}
@Bean
public Binding bindingTestDlq(DirectExchange directExchange, Queue queueTestDlq) {
return BindingBuilder
.bind(queueTestDlq)
.to(directExchange)
.with("testdlqkey");
}
Обработка работает правильно, и в случае исключения сообщение перемещается в DLQ.
Как я могу добавить информацию об исключении (например, message, stacktrace) в заголовки сообщения для сообщения, отправляемого в DLQ?