我有一个使用RabbitMQ的Spring Cloud Streaming transformer应用程序。它从兔子队列中读取数据,进行一些转换,然后写入兔子交换。我将应用程序部署到PCF,并绑定到Rabbit服务。
这很好,但现在我需要一个单独的连接来消费和生成消息。(我想使用一个连接从兔子队列中读取,并使用另一个连接写入兔子交换)。如何配置?是否可以使用1作为生产者,1作为消费者,将我的应用程序绑定到2个不同的Rabbit服务?
从版本开始 1.3 ConnectionFactory https://docs.spring.io/spring-cloud-stream/docs/Ditmars.RELEASE/reference/htmlsingle/#_rabbitmq_binder
1.3
ConnectionFactory
RabbitMessageChannelBinder 创建内部
RabbitMessageChannelBinder
所以,升级到Spring Cloud Stream Ditmars后,这可能就足够了。
我该如何使用不同的连接属性配置这个内部ConnectionFactory副本?
不,那是不同的故事。你需要的是 multi-binder https://docs.spring.io/spring-cloud-stream/docs/Ditmars.RELEASE/reference/htmlsingle/#multiple-binders
multi-binder
您应该为不同的连接工厂声明几个块:
spring.cloud.stream.bindings.input.binder=rabbit1 spring.cloud.stream.bindings.output.binder=rabbit2 ... spring: cloud: stream: bindings: input: destination: foo binder: rabbit1 output: destination: bar binder: rabbit2 binders: rabbit1: type: rabbit environment: spring: rabbitmq: host: <host1> rabbit2: type: rabbit environment: spring: rabbitmq: host: <host2>