MyChannels.Nirvana API: Consumers

Consumers are the main means of consuming messages when using the MyChannels.Nirvana API. They allow simple consumption of messages from both Topics and Queues. A Consumer is created using the CreateConsumer() method in either Session.Queues or Session.Topics, depending on the type of Consumer.

The Consumer's MessageReceived event is fired whenever a message is received by the Topic or Queue being consumed. By attaching an appropriate handler, the message can be dealt with in whatever way is desired.


IConsumer consumer = session.Queues.CreateConsumer("Queue1");
consumer.MessageReceived += (s, e) => ProcessMessage(e.Message);

IConsumer consumer = session.Topics.CreateConsumer("Topic1");
consumer.MessageReceived += (s, e) => ProcessMessage(e.Message);