7

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,

mr.b
  • 2,708
  • 8
  • 39
  • 64

2 Answers2

12

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.

Kelly
  • 6,992
  • 12
  • 59
  • 76
5

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

scvalex
  • 14,931
  • 2
  • 34
  • 43