Background
I'm using the Azure Service Bus. Inside a namespace, I have a topic with an active subscription. I have a producer pushing messages to the topic, and I have n numbers of services subscribing to the same subscription (for scalability reasons). These services are using PeekLock() to fetch messages, performing some work on them and are then releasing the message lock through Complete() once work has finished.
Problem
Whenever a service has a message locked, no new services seem to be able to fetch messages from the same topic/subscription. It seems as if the whole topic is locked, not only the message that has a lock on itself.
The actual problem is that I have services just sitting around doing nothing but waiting for the service with an active PeekLock() to be finished.
Questions
Is there a way to enable concurrent readers (or concurrent locks) in the topic (and subscription) or queue?
The (for me unwanted) scenario which I explain above - is it a consequence of some sort of a guarantee to deliver messages in the order they are recieved?
Code snippet: Csharp
public static void main(...)
{
// configure the options
OnMessageOptions messageOptions = new OnMessageOptions();
messageOptions.AutoComplete = false;
// look for messages
serviceBusClient.OnMessage(msg => processMessage(msg, connectionKey), messageOptions);
}
private static void processMessage(BrokeredMessage msg, string connectionKey)
{
try
{
// do stuff to the message
//...
// for debugging: no new clients grab messages
// while this client has lock active. the sleep
// is to simulate heavy work load
Thread.Sleep(5000);
// release lock on message
msg.Complete();
}
catch (Exception e)
{
msg.Abandon();
}
}