我在Spring中有简单的RabbitMQ配置(不是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。
如何将异常详细信息(例如,消息,堆栈跟踪)附加到要发送到DLQ的消息的消息头中?