简体   繁体   English

RabbitMQ消息交换

[英]RabbitMQ Message Exchange

I have Created a RabbitMQ Producer and a RabbitMQ Consumer.... 我已经创建了RabbitMQ生产者和RabbitMQ消费者。

suppose my producer produces 10 messages. 假设我的生产者产生了10条消息。 How can i get a particular message from those 10 messages. 我如何从那10条消息中获取特定消息。

I want to know how can i uniquely identify a message and read that or consume that message. 我想知道如何唯一标识一条消息并阅读或使用该消息。

我有一个示例,该示例显示了如何在C#中执行主题队列,这似乎是您在寻找RabbitMQ教程的目标。我也有一个示例,该示例显示了如何使用EventingBasicConsumer来避免在获取消息时出现阻塞RabbitMQ EventingBasicConsumer

There are several ways to do this, but the one I use most is to use a routing key that is unique to the type of message. 有几种方法可以做到这一点,但是我最常使用的一种方法是使用消息类型唯一的路由密钥。 Consumers, then, bind to that exchange using a specific routing key, which causes messages to go only to those consumers. 然后,消费者使用特定的路由密钥绑定到该交换机,这将导致消息仅发送给那些消费者。

If you can avoid it, you should never just dump messages into a single queue and let the consumers sort them out. 如果可以避免,则永远不要仅将消息转储到单个队列中,而让使用者将其整理出来。 The routing keys and exchanges are powerful tools made specifically for routing messages. 路由密钥和交换是专门用于路由消息的强大工具。 You should leverage that. 您应该利用它。

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

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