We are having a windows service which receives messages from Azure Service bus queue and process those messages with business logic and finally completes them.
To receive messages from service bus we are using MessageReceiver which we are creating with below code snippet.
Here SAS token expires in 60 minutes. And we have registered message handler with,
var options = new OnMessageOptions
{
MaxConcurrentCalls = Convert.ToInt16(MessageMaxConcurrentCalls),
AutoComplete = false
};
options.ExceptionReceived += OptionsOnExceptionReceived;
messageReceiver.OnMessageAsync(MessageHandler, options);
Also I am having a timer which generates new SAS token every 55 minutes and create a messageReceiver again and register same message handler. But issue here is, the older messageReceiver still continues to run message handler and after 60 minutes it gives below exception.
Error - 40105: Malformed authorization token.
So to overcome this issue, I had tried closing messaging factory which creating new message receiver. But it still gives me Error - The operation cannot be performed because the entity has been closed or aborted. This might be because messages might be in process and I am closing the messaging factory.
So I require help here to overcome this issue on how I can update the messaging factory/message receiver with latest SAS token and continue OnMessageAsync or how I can unregister message handler and register with new message receiver without causing any exception.
Service bus nuget package I am using is WindowsAzure.ServiceBus 4.1.8.
Description
We are having a windows service which receives messages from Azure Service bus queue and process those messages with business logic and finally completes them.
To receive messages from service bus we are using MessageReceiver which we are creating with below code snippet.
Here SAS token expires in 60 minutes. And we have registered message handler with,
Also I am having a timer which generates new SAS token every 55 minutes and create a messageReceiver again and register same message handler. But issue here is, the older messageReceiver still continues to run message handler and after 60 minutes it gives below exception.
Error - 40105: Malformed authorization token.
So to overcome this issue, I had tried closing messaging factory which creating new message receiver. But it still gives me Error - The operation cannot be performed because the entity has been closed or aborted. This might be because messages might be in process and I am closing the messaging factory.
So I require help here to overcome this issue on how I can update the messaging factory/message receiver with latest SAS token and continue OnMessageAsync or how I can unregister message handler and register with new message receiver without causing any exception.
Service bus nuget package I am using is WindowsAzure.ServiceBus 4.1.8.