我想在我的应用程序中实现以下场景:
我能够(参见下面的代码)在死信队列中将消息延迟一定的时间。并且消息在传入队列和死信队列之间无限循环。到目前为止,一切都很好。
主要问题:如何拦截该进程并手动将消息(如步骤 3 中所述)路由到 parkingLot 队列以供以后进一步分析?
第二个问题:我可以只用一次交换来实现相同的过程吗?
这是我的两个课程的简化版本:
配置类
@Configuration
public class MailRabbitMQConfig {
@Bean
TopicExchange incomingExchange() {
TopicExchange incomingExchange = new TopicExchange(incomingExchangeName);
return incomingExchange;
}
@Bean
TopicExchange dlExchange() {
TopicExchange dlExchange = new TopicExchange(deadLetterExchangeName);
return dlExchange;
}
@Bean
Queue incomingQueue() {
return QueueBuilder.durable(incomingQueueName)
.withArgument(
"x-dead-letter-exchange",
dlExchange().getName()
)
.build();
}
@Bean
public Queue parkingLotQueue() {
return new Queue(parkingLotQueueName);
}
@Bean
Binding incomingBinding() {
return BindingBuilder
.bind(incomingQueue())
.to(incomingExchange())
.with("#");
} …
Run Code Online (Sandbox Code Playgroud)