简体   繁体   English

使用wso2 / rabbitMq / c#在主题消息中通配符如何工作?

[英]How do wildcards work in topic messaging with wso2/rabbitMq/c#?

If I publish a message to a wso2 topic like so: 如果我像这样向wso2主题发布消息:

channel.BasicPublish(someExchangeName,"farm.cow.brown",null,someMessage);

I can retrieve the message if I am listening to the routing key "farm.cow.brown": 如果我正在听路由键“ farm.cow.brown”,则可以检索该消息:

channel.QueueBind(someQueueName,someExchangeName,"farm.cow.brown");

I think I should also be able to get the message if I am listening to a variation such as this: 如果我正在听这样的变化,我也应该能够得到消息:

channel.QueueBind(someQueueName,someExchangeName,"farm.cow.*");

Of the two listening examples above the first works, the second never does, regardless of the routing key combinations attempted (farm.cow.* , farm.*.brown , farm.cow.# , farm.# , etc.). 在上面的两个侦听示例中,第一个起作用,而第二个则永远不起作用,无论尝试了路由键组合如何(farm.cow。*,farm。*。brown,farm.cow。#,farm。#等)。

I am connecting to wso2 using rabbitMq and c#. 我正在使用RabbitMq和C#连接到wso2。

Thank you. 谢谢。

This is working for me now. 这现在为我工作。 It appears that to use a wildcard to listen to multiple topics/routing paths, there need to be existing queues for each topic. 似乎要使用通配符侦听多个主题/路由路径,每个主题都需要有现有的队列。

Here is what I mean: consider the topics "farm.cow.brown" and "farm.cow.white" and a listener consuming route "farm.cow.*". 这就是我的意思:考虑主题“ farm.cow.brown”和“ farm.cow.white”,以及一个监听者使用路由“ farm.cow。*”。

If there is an existing queue on "farm.cow.brown" but not on "farm.cow.white", I will only get messages published to "farm.cow.brown", even though "farm.cow.white" exists and is getting messages published to it. 如果“ farm.cow.white”上已有队列,但“ farm.cow.white”上没有队列,即使“ farm.cow.white”存在,我也只会收到发布到“ farm.cow.brown”的消息。并正在向其发布消息。

If there is a queue on "farm.cow.brown" and another on "farm.cow.white", "farm.cow.*" will get all messages published to "farm.cow.brown" and published to "farm.cow.white". 如果“ farm.cow.brown”上有一个队列,而“ farm.cow.white”上有一个队列,则“ farm.cow。*”会将所有消息发布到“ farm.cow.brown”并发布到“ farm.cow.brown”。 cow.white”。

If neither have queues, "farm.cow.*" retries no messages published to "farm.cow.brown" and "farm.cow.white". 如果两个都没有队列,则“ farm.cow。*”不会重试任何未发布到“ farm.cow.brown”和“ farm.cow.white”的消息。

(As an aside, the "farm.cow.*" examples above are work equivalently using "farm.#") (顺便说一句,上面的“ farm.cow。*”示例等效地使用“ farm。#”工作)

To restate, using wildcards only retrieves messages for topics that have existing queues or subscriptions. 要重新声明,使用通配符仅检索具有现有队列或订阅的主题的消息。

This is my experience. 这是我的经验。 I have been testing this for a few days and it appears to be the consistent behavior. 我已经测试了几天,这似乎是一致的行为。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM