rabbitmq - 通过Spring cloud Stream与rabbitmq binder绑定(bind)exchange进行交换

标签 rabbitmq spring-amqp spring-cloud-stream spring-rabbit

我正在寻找一种通过 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/

相关文章:

python - 如何在计划任务的情况下从 celery 获取任务 ID (beat)

python - celery 不释放内存

java - ActiveMQ 使用 AMQP、MQTT 或 TCP 哪个更好?

java - 当主题有多个分区时,KTable-KTable 外键连接不会产生所有消息

java - 处理慢速消费者 kafka 上的背压并避免重新平衡

apache-kafka - 调度程序没有 channel 订阅者 - spring-cloud-stream-kafka

android - native 应用程序到服务器的通信

messaging - 什么是面向消息的中间件?

java - Spring AMQP——@RabbitListener 是在幕后轮询吗?

spring - 检查rabbitmq中是否存在指定名称的Exchange