Search code examples
azureazure-servicebus-queues

Dynamic Update of MaxConcurrentCalls


I have a similar question as another user, it was never answered:

I am creating a Worker Role using Windows Azure and have the following code: OnMessageOptions options = new OnMessageOptions() { MaxConcurrentCalls = 10 }; ... Client.OnMessage((receivedMessage) => { ... }, options); Is it possible to update the MaxConcurrentCalls after the the message pump has started?

I know i can cycle my worker role to update the setting, but short of recycling the code is there another way? Calling OnMessage again throws an exception, there are no settings exposed that I can change once its called, and I cannot find a way to cycle/close the QueueClient.


Solution

  • I found you can close the QueueClient.MessageFactory it will stop the current listener allowing jobs already inflight to complete, then you can create a new QueueClient with the updated concurrency settings. Not as elegant as updating the concurrency with the listener still active, but it works for us.