Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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,

like image 706
mr.b Avatar asked Mar 30 '12 01:03

mr.b


2 Answers

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.

like image 98
Kelly Avatar answered Oct 14 '22 18:10

Kelly


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).

like image 33
scvalex Avatar answered Oct 14 '22 17:10

scvalex