简体   繁体   English

如何在RabbitMQ上进行非阻塞?

[英]How to do non-blocking on RabbitMQ?

I am new to RabbitMQ. 我是RabbitMQ的新手。 I just started yesterday. 我刚开始昨天。 I did few spikes on sending and consuming stuff. 我发送和消费的东西很少见。 What I noticed was on their documentation and even on articles that I've read most of them are implementing the subscription piece in a way that they are looping it to get the message from a queue. 我注意到的是他们的文档,甚至我读过的文章中的大多数都正在实现订阅部分,他们正在循环它以从队列中获取消息。 How can I make it so that it will be event driven? 我怎样才能使它成为事件驱动的? What I wanted to accomplish is when a message is sent to a queue it will raise and event to the receiver and do something about it. 我想要完成的是当一个消息被发送到一个队列时,它会向接收者发出事件并对它做一些事情。 Perhaps like displaying the message. 也许就像显示消息一样。

Your reply is greatly appreciated. 非常感谢您的回复。

Best regards, 最好的祝福,

Should use EventingBasicConsumer. 应该使用EventingBasicConsumer。 I have an example on my website that shows how it's used RabbitMQ Events using EventingBasicConsumer 我在我的网站上有一个例子,它显示了如何使用EventingBasicConsumer使用RabbitMQ事件

Basically it's just a new consumer that exposes a Received event so you don't need to block. 基本上它只是一个新的消费者,它暴露了一个Received事件,所以你不需要阻止。

Some of the examples use that looping style because it's easier to explain and understand. 一些示例使用循环样式,因为它更容易解释和理解。

You want to use IModel.BasicConsume instead of BasicGet . 您想使用IModel.BasicConsume而不是BasicGet See the API Guide for examples (search for subscribe and consume). 有关示例,请参阅API指南 (搜索订阅和使用)。

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

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