I'm using Rabbitmq Queue solution and i have 4 queues and one consumer. i want my consumer consume all of these queues and provide separate Handler for each one.
I googled this and found that Rabbitmq and EasyNetQ (.Net Client for RabbitMQ), provides this feature with The Advanced API (this link and This link)
The sample code provided in this articles to define multiple handler for a consumer :
bus.Advanced.Consume(queue, x =>
x.Add<MyMessage>((message, info) => { Console.WriteLine("Got MyMessage {0}", message.Body.Text); countdownEvent.Signal(); })
.Add<MyOtherMessage>((message, info) => { Console.WriteLine("Got MyOtherMessage {0}", message.Body.Text); countdownEvent.Signal(); })
);
My Problem : So when i try to use this example, the Add<> method is unknown. What is The problem? and what i should do to make this method available?
my code's using part :
using RabbitMQ;
using EasyNetQ;
using EasyNetQ.Consumer;
My Code :
using (var bus = RabbitHutch.CreateBus("host=localhost;prefetchcount=100"))
{
var queue = bus.Advanced.QueueDeclare("QueueMessageTypes.VehicleDeviceChangeMessage:QueueMessageTypes_VehicleDeviceChangeMsg");
bus.Advanced.Consume(queue, x => x
.Add<PositionMessage>((message, info) =>
{
Console.WriteLine("Got MyMessage {0}", message.Body.Text);
})
.Add<VehicleDeviceChangeMessage>((message, info) =>
{
Console.WriteLine("Got MyOtherMessage {0}", message.Body.Text);
})
);
}
I think i should use a namespace or a class to use Add<> method. may it's a extension method that i should find and add related class from a library.