0

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

Danhol86
  • 1,352
  • 1
  • 11
  • 20
  • It isn't clear what you want - do you want them both to get all messages? If so, you should use a topic with with 2 subscriptions. – snow_FFFFFF May 05 '17 at 16:33
  • Apologies. No I want them both to pick up the next item in the queue. However only 1 of the 2 listeners ever picks one up at a time. If I run 2 listeners on 2 machines it works how I want. However, when 2 listeners are on same machine they both dont pick up different messages at the same time. – Danhol86 May 05 '17 at 17:03

1 Answers1

0

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.

Fei Han
  • 26,415
  • 1
  • 30
  • 41