【发布时间】:2021-05-20 09:47:52
【问题描述】:
我需要将扇出交换绑定到 Spring Boot RabbitMQ 客户端中的默认交换,但我做不到。当我尝试下面的代码时,我没有看到任何错误,但没有绑定交换(至少它没有显示在 rabbitmq admin 中,消息也没有路由到该交换)。我的代码:
带有路由键 testq 放入 testex 交换的消息消失了 - 没有传递到 testq 队列。
@Bean
FanoutExchange testExchange() {
return new FanoutExchange("testex");
}
@Bean
Binding testExchangeToDefaultBinding() {
return new Binding("", DestinationType.EXCHANGE, "testex", null, null);
}
@Bean
Queue testQueue() {
return new Queue("testq");
}
这样绑定不行吗?
编辑:还有其他方法可以做类似的事情吗?
【问题讨论】:
标签: spring-boot rabbitmq