I have two exactly same consumers
Consumer 1
using (var adapter = new BuiltinHandlerActivator())
{
adapter.Handle<string>(async (bus, message) =>
{
Console.WriteLine("Got message > " + message);
await bus.Reply("Received in consumer 1");
});
Configure.With(adapter)
.Transport(t => t.UseAzureServiceBus(connectionString, "server"))
.Start();
adapter.Bus.Subscribe<string>().Wait();
Console.WriteLine("Press ENTER to quit");
Console.ReadLine();
}
Consumer 2
using (var adapter = new BuiltinHandlerActivator())
{
adapter.Handle<string>(async (bus, message) =>
{
Console.WriteLine("Got message > " + message);
await bus.Reply("Received in Consumer 2");
});
Configure.With(adapter)
.Transport(t => t.UseAzureServiceBus(connectionString, "server"))
.Start();
adapter.Bus.Subscribe<string>().Wait();
Console.WriteLine("Press ENTER to quit");
Console.ReadLine();
}
Producer
using (var adapter = new BuiltinHandlerActivator())
{
adapter.Handle<string>(async message =>
{
Console.WriteLine("Returned > " + message);
});
var bus = Configure
.With(adapter)
.Transport(t => t.UseAzureServiceBus(connectionString, "client"))
.Routing(r => r.TypeBased().Map<string>("server"))
.Start();
Console.WriteLine("Press Q to quit or any other key to produce a job");
while (true)
{
Console.Write("Write something > ");
var text = Console.ReadLine();
if (string.IsNullOrWhiteSpace(text)) break;
bus.Publish(text).Wait();
}
}
What I expect is whenever I send message from the Producer, both my Consumers to display the message. Now it only does it in one of them. When I close that one and send another message, the remaining one receives it.