如何将 rabbitmq 的当前交换和队列名称与 spring 云流 rabbitmq 一起使用
How to use current exchange and queue name of rabbitmq with spring cloud stream rabbitmq
我正在将遗留 spring 应用程序切换到 spring 启动。
使用 spring 云流 rabbitmq 迁移 rabbitmq 代码时出现问题。
在遗留系统中,通过给exchange、routingKey和queue name来设置rabbitmq队列
例如,
exchange name = mq-test.topic
routingKey = mq-test
queueName = aa.mq-test
所以在rabbitmq管理视图中我可以看到
交换是 mq-test.topic,队列是 aa.mq-test.
但是对于 spring 云流,队列名称点缀有目的地,如
mq-test.topic.aa.mq-测试
我的spring云流属性是这样的
spring.cloud.stream.bindings.channelName.destination=mq-test.topic
spring.cloud.stream.bindings.channelName.producer.bindingRoutingKey=mq-test
spring.cloud.stream.bindings.channelName.producer.requiredGroups=aa.mq-test
我也用routingKeyExpression 属性代替bindingRoutingKey 但是结果是一样的
有遗留应用程序通过队列名称使用数据,而我的新应用程序只是在生产,所以我无法更改交换和队列名称策略。
如何使用 spring 云流保留 exchange/queue 命名?
感谢任何帮助。
请参阅 RabbitMQ Binder 文档Using Existing Queues/Exchanges。
By default, the binder will automatically provision a topic exchange with the name being derived from the value of the destination binding property . The destination defaults to the binding name, if not provided. When binding a consumer, a queue will automatically be provisioned with the name . (if a group binding property is specified), or an anonymous, auto-delete queue when there is no group. The queue will be bound to the exchange with the "match-all" wildcard routing key (#) for a non-partitioned binding or - for a partitioned binding. The prefix is an empty String by default. If an output binding is specified with requiredGroups, a queue/binding will be provisioned for each group.
There are a number of rabbit-specific binding properties that allow you to modify this default behavior.
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.binding.<binding name>.destination=myExhange
spring.cloud.stream.binding.<binding name>.group=myQueue
spring.cloud.stream.rabbit.bindings.<binding name>.consumer.bindQueue=false
spring.cloud.stream.rabbit.bindings.<binding name>.consumer.declareExchange=false
spring.cloud.stream.rabbit.bindings.<binding name>.consumer.queueNameGroupOnly=true
...
我正在将遗留 spring 应用程序切换到 spring 启动。
使用 spring 云流 rabbitmq 迁移 rabbitmq 代码时出现问题。
在遗留系统中,通过给exchange、routingKey和queue name来设置rabbitmq队列
例如,
exchange name = mq-test.topic
routingKey = mq-test
queueName = aa.mq-test
所以在rabbitmq管理视图中我可以看到 交换是 mq-test.topic,队列是 aa.mq-test.
但是对于 spring 云流,队列名称点缀有目的地,如
mq-test.topic.aa.mq-测试
我的spring云流属性是这样的
spring.cloud.stream.bindings.channelName.destination=mq-test.topic
spring.cloud.stream.bindings.channelName.producer.bindingRoutingKey=mq-test
spring.cloud.stream.bindings.channelName.producer.requiredGroups=aa.mq-test
我也用routingKeyExpression 属性代替bindingRoutingKey 但是结果是一样的
有遗留应用程序通过队列名称使用数据,而我的新应用程序只是在生产,所以我无法更改交换和队列名称策略。
如何使用 spring 云流保留 exchange/queue 命名?
感谢任何帮助。
请参阅 RabbitMQ Binder 文档Using Existing Queues/Exchanges。
By default, the binder will automatically provision a topic exchange with the name being derived from the value of the destination binding property . The destination defaults to the binding name, if not provided. When binding a consumer, a queue will automatically be provisioned with the name . (if a group binding property is specified), or an anonymous, auto-delete queue when there is no group. The queue will be bound to the exchange with the "match-all" wildcard routing key (#) for a non-partitioned binding or - for a partitioned binding. The prefix is an empty String by default. If an output binding is specified with requiredGroups, a queue/binding will be provisioned for each group.
There are a number of rabbit-specific binding properties that allow you to modify this default behavior.
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.binding.<binding name>.destination=myExhange
spring.cloud.stream.binding.<binding name>.group=myQueue
spring.cloud.stream.rabbit.bindings.<binding name>.consumer.bindQueue=false
spring.cloud.stream.rabbit.bindings.<binding name>.consumer.declareExchange=false
spring.cloud.stream.rabbit.bindings.<binding name>.consumer.queueNameGroupOnly=true
...