通过 Spring 云流与 rabbitmq binder 绑定 exchange

Bind exchange to exchange through Spring cloud stream with rabbitmq binder

我正在寻找一种通过 Spring 云流将 RabbitMQ 交换绑定到另一个的方法。我知道我可以通过设置 producer.requiredGroups 属性:

将队列绑定到交换器
spring.cloud.stream.bindings.foo.producer.requiredGroups=queueA queueB

我可以使用哪个 属性 来创建交换到交换绑定?

不是添加所需的组,而是为两个交换添加 @Beans 并为绑定添加一个 @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'