我正在寻找一种通过 Spring 云流将 RabbitMQ 交换绑定(bind)到另一个交换的方法。我知道我可以通过设置 Producer.requiredGroups 属性将队列绑定(bind)到交换器:
spring.cloud.stream.bindings.foo.producer.requiredGroups=queueA queueB
我可以使用哪个属性来创建交换到交换的绑定(bind)?
最佳答案
不要添加所需的组,而是为两个交换添加 @Bean
并为绑定(bind)添加 @Bean
。
请参阅Spring AMQP documentation .
@Bean
public TopicExchange destinatioExchange() {
return new TopicExchange("myDest");
}
@Bean
public DirectExchange boundExchange() {
return new DirectExchange("bound");
}
@Bean
public Binding binding() {
return BindingBuilder
.bind(boundExchange())
.to(destinatioExchange())
.with("myRoutingKey");
}
和
spring.cloud.stream.bindings.output.destination=myDest
spring.cloud.stream.rabbit.bindings.output.producer.routing-key-expression='myRoutingKey'
关于rabbitmq - 通过Spring cloud Stream与rabbitmq binder绑定(bind)exchange进行交换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55616937/