java - 使用spring-cloud-stream发送rabbitmq消息时,无法指定发送的RoutingKey
问题描述
我使用的是 3.1.3 版本。如下配置后,'output-out-0.producer.bindingRoutingKey'不生效。当我发送消息时,路由键 = command_exchange_open 而不是:ORDER_PUSH
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-stream-binder-rabbit</artifactId>
</dependency>
spring:
rabbitmq:
addresses: amqp://sycx:sycx@192.168.1.204
cloud:
stream:
rabbit:
bindings:
input-in-0:
consumer:
bindingRoutingKey: ORDER_PUSH
exchangeType: direct
queueNameGroupOnly: true
output-out-0:
producer:
bindingRoutingKey: ORDER_PUSH
queueNameGroupOnly: true
bindQueue: false
bindings:
input-in-0:
destination: command_exchange_open
group: ORDER_END
output-out-0:
destination: command_exchange_open
group: ORDER_END
function:
definition: input;output
解决方案
routing-key-expression: '''ORDER_PUSH'''
生产者属性不应该是bindingRoutingKey
。
output-out-0:
producer:
bindingRoutingKey: ORDER_PUSH
queueNameGroupOnly: true
bindQueue: false
这些属性不适用于生产者(除非您已required-groups
设置)。
推荐阅读
- javascript - 在javascript中呈现用户的输出
- java - 如何在java中实现正确的完全对齐?
- python - 在关闭跟踪器的 Python 乌龟中,有没有办法在不使用 screen.update() 的情况下更新屏幕?
- reactjs - 使用 react-app-rewired-alias 进行 React 生产
- javascript - 在 Rails 6 中使用 js.erb 文件更改 HTML 元素的内容
- javascript - 如何设计一个函数,以便它为每个按钮单击做不同的事情
- python - 使用 Python 从 encrypted-tbn0.gstatic.com 下载图像
- python - How do I get a legend along my categorical colored scatter plot?
- python - Flask request.files.getlist() appearing to be empty on post request
- r - Merge two data frames by id and date