如何为生产者和消费者绑定Spring云流绑定?
How to bind Spring cloud stream binding for producer and consumer?
我是 Spring 云和 RabbitMQ 的新手。
我正在尝试从 Rabbit MQ 生成和使用消息。
我在为生产者和消费者配置交换名称和队列名称时遇到困难。
我想连接到名为 order
的现有交换和名为 myQueue
的现有队列
下面是application.properties
spring.rabbitmq.addresses=amqp://user:pass@localhost:5672/
spring.cloud.stream.function.bindings.processTable-out-0=order
spring.cloud.stream.function.bindings.processTable-in-0=order
spring.cloud.stream.bindings.order.group=myQueue
spring.cloud.stream.bindings.order.content-type=application/json
以上配置正在连接到 order
交换,但是,它正在创建并连接一个名为 order.myQueue
的新队列。
消费方式如下
@Bean
public Consumer<String> processTable(){
log.info("Conuming message......................");
Consumer<String> consumer = (request)-> System.out.println(request);
System.out.println(consumer);
return consumer;
}
我需要在 application.properties
中进行哪些调整才能连接到 order
交换和 myOrder
队列?
参见Using Existing Queues/Exchanges。
If you have an existing exchange/queue that you wish to use, you can completely disable automatic provisioning as follows, assuming the exchange is named myExchange and the queue is named myQueue:
spring.cloud.stream.bindings..destination=myExchange
spring.cloud.stream.bindings..group=myQueue
spring.cloud.stream.rabbit.bindings..consumer.bindQueue=false
spring.cloud.stream.rabbit.bindings..consumer.declareExchange=false
spring.cloud.stream.rabbit.bindings..consumer.queueNameGroupOnly=真
我是 Spring 云和 RabbitMQ 的新手。 我正在尝试从 Rabbit MQ 生成和使用消息。 我在为生产者和消费者配置交换名称和队列名称时遇到困难。
我想连接到名为 order
的现有交换和名为 myQueue
下面是application.properties
spring.rabbitmq.addresses=amqp://user:pass@localhost:5672/
spring.cloud.stream.function.bindings.processTable-out-0=order
spring.cloud.stream.function.bindings.processTable-in-0=order
spring.cloud.stream.bindings.order.group=myQueue
spring.cloud.stream.bindings.order.content-type=application/json
以上配置正在连接到 order
交换,但是,它正在创建并连接一个名为 order.myQueue
的新队列。
消费方式如下
@Bean
public Consumer<String> processTable(){
log.info("Conuming message......................");
Consumer<String> consumer = (request)-> System.out.println(request);
System.out.println(consumer);
return consumer;
}
我需要在 application.properties
中进行哪些调整才能连接到 order
交换和 myOrder
队列?
参见Using Existing Queues/Exchanges。
If you have an existing exchange/queue that you wish to use, you can completely disable automatic provisioning as follows, assuming the exchange is named myExchange and the queue is named myQueue:
spring.cloud.stream.bindings..destination=myExchange
spring.cloud.stream.bindings..group=myQueue
spring.cloud.stream.rabbit.bindings..consumer.bindQueue=false
spring.cloud.stream.rabbit.bindings..consumer.declareExchange=false
spring.cloud.stream.rabbit.bindings..consumer.queueNameGroupOnly=真