[英]RabbitMq topic exchange
Is it possible to achieve the following scenario using RabbitMQ topic exchange. 使用RabbitMQ主题交换是否可以实现以下方案。
Lets say I have two queues: 可以说我有两个队列:
Queue1: routing key MainRoute.Route1 Queue1:路由键MainRoute.Route1
Queue2: routing key MainRoute.Route2 Queue2:路由键MainRoute.Route2
When I publish my message with routing key: 当我使用路由密钥发布消息时:
MainRoute.Route1 -> Queue1 MainRoute.Route1->队列1
MainRoute.Route2 -> Queue2 MainRoute.Route2->队列2
MainRoute -> Queue1 and Queue2 MainRoute->队列1和队列2
Is it possible to achieve this without implementing some special filtering, routing process ? 是否可以在不执行某些特殊的过滤,路由过程的情况下实现这一目标?
If not can you please advise on a possible solution for the problem. 如果不能,请就可能的问题提出建议。
Thank you. 谢谢。
This can be done with a direct or a topic exchange, and would require 4 bindings in your exchange. 这可以通过直接交换或主题交换来完成,并且在交换中需要4个绑定。
Assuming an exchange named "MainEx" as an example, the routing keys would be set up like this: 假设以一个名为“ MainEx”的交换机为例,则路由密钥的设置应如下所示:
| exchange | binding | queue | | -------- | ---------------- | ------ | | MainEx | MainRoute.Route1 | Queue1 | | MainEx | MainRoute.Route2 | Queue2 | | MainEx | MainRoute | Queue1 | | MainEx | MainRoute | Queue2 |
With a topic exchange, you could send multiple messages to a single queue by using flags. 通过主题交换,您可以使用标志将多个消息发送到单个队列。 For example, binding "MainRoute.#" to "Queue3" would send all MainRoute messages to Queue3.
例如,将“ MainRoute。#”绑定到“ Queue3”会将所有 MainRoute消息发送到Queue3。
But, there is no way to do the opposite with a single binding. 但是,没有办法对单个绑定执行相反的操作。 You need to create multiple bindings to do what you want.
您需要创建多个绑定才能执行所需的操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.