简体   繁体   中英

How to do non-blocking on RabbitMQ?

I am new to 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. I have an example on my website that shows how it's used RabbitMQ Events using EventingBasicConsumer

Basically it's just a new consumer that exposes a Received event so you don't need to block.

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 . See the API Guide for examples (search for subscribe and consume).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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