Azure ServiceBus multiple listeners on same machine not working

681 views Asked by At

I am using Azure ServiceBus to process items sent by multiple clients.

I am testing the part which receives these messages and have run 2 listeners side by side. However if I submit 2 items to the queue. Only 1 listener ever works and the second doesn't pick up the other item.

I have however tried running 2 listeners on different machines and they both process the 2 items pushed to the queue.

Is the issue with running multiple listeners on the same machine and if so, what am i doing wrong and how do i fix?

Thanks for your time.

Dan

1

There are 1 answers

0
Fei Han On

Is the issue with running multiple listeners on the same machine

I create a console application to receive messages from Service Bus queue, and then I open and run program twice on my machine, both of queue clients/receivers could receive and process messages from same queue.

Call OnMessage method:

var client = QueueClient.CreateFromConnectionString(connectionString, queueName);

var options = new OnMessageOptions();
options.AutoComplete = false;

client.OnMessage(mes =>
{
    Console.WriteLine(mes.GetBody<string>());
}, options);

Output:

enter image description here

Call Receive method:

var client = QueueClient.CreateFromConnectionString(connectionString, queueName);  

BrokeredMessage mes = client.Receive();
Console.WriteLine(mes.GetBody<string>());

Output:

enter image description here

If possible, please share us your code, and then we will reproduce the issue based on your code.