Given two subscribers, processing synchronously Message objects from RabbitMQ queue, one at a time for 3s,
when publisher send 4 messages:
Message { Text: 1 }
Message { Text: 2 }
Message { Text: 3 }
Message { Text: 4 }
Is it possible to divide work this way:
Subscriber1 - 1 - 00:00:00
Subscriber2 - 2 - 00:00:00
Subscriber1 - 3 - 00:00:03
Subscriber2 - 4 - 00:00:03
so that subscribers start immediately with first two messages and then, when they finish, with next ones? Order is not important for me. I would like to use EasyNetQ, because of its nice api, but default .NET/C# RabbitMQ client would also be fine.
This code does not work as expected:
var Bus = RabbitHutch.CreateBus("host=localhost");
Bus.Subscribe<Message>("subscriptionId", x =>
{
Console.WriteLine("Subscriber1 - " + x.Text + " - " + DateTime.Now.ToString("HH:mm:ss"));
Thread.Sleep(3000);
});
Bus.Subscribe<Message>("subscriptionId", x =>
{
Console.WriteLine("Subscriber2 - " + x.Text + " - " + DateTime.Now.ToString("HH:mm:ss"));
Thread.Sleep(3000);
});
Bus.Publish(new Message("1"));
Bus.Publish(new Message("2"));
Bus.Publish(new Message("3"));
Bus.Publish(new Message("4"));
Anyone?