I am trying to use EasyNetQ to send and receive messages from RabbitMQ, I need to send same message to multiple receivers or whom ever is connected at the time.
I have tried publish-subscribe messaging pattern and it works fine, but it's more like round-robin, where once the message is received by a receiver it's removed from the queue and nobody else can see the message.
Here's my message sender.
for (int i = 0; i < 10; i++)
{
using (IBus bus = RabbitHutch.CreateBus(Host))
{
bus.Publish(new TextMessage { Text = $"{i}: Hello World from EasyNetQ" }, "dashboard");
}
}
Here's my receiver.
public void GetMessages() {
using (IBus bus = RabbitHutch.CreateBus(Host))
{
bus.Subscribe<TextMessage>("dashboard", HandleTextMessage);
Console.WriteLine("Listening for messages. Hit <return> to quit.");
Console.ReadLine();
}
}
static void HandleTextMessage(TextMessage textMessage)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Got message: {0}", textMessage.Text);
Console.ResetColor();
}
Once a message is received no other receiver can see that message and I need all of the connected receivers see the same message.
I did not understand how RabbitMQ works. All I needed was to create an Exchange and have Exchange send the messages to the queues. I though Queues did that.