Search code examples
c#azureazureservicebusservicebusazure-queues

Azure Service Bus failover


Must be a simple question, but I didn't really find the answer. I'm going to create few asp.net hosted services where I want to start threads that will send and receive messages from azure service bus (queue). Let's take a look at receiving hosted service which effectively create ServiceBusClient and ServiceBusProcessor instances during starting HostedService and then always calling only callbacks.

I wonder whether I should worry about any failover related behavior which will force me recreating client let's say in case the azure server is temporary not available (just example).

As far as I understand, the answer is no and creating client and processor during starting should be enough and as long as the issue will be gone, the callback will proceed to be called as before, but would be good to confirm it.


Solution

  • The scenario that you're asking about seems to be a temporary outage that will eventually be resolved and does not require moving to a different Service Bus namespace.

    Assuming the above is correct, the answer is "no" - there's nothing that your application would need to do.

    Context

    The Service Bus clients create and recover connections on demand as service operations require them. If a connection is lost, the next service operation will detect it and recreate it.

    The processor is written to be highly resilient and able to recover from transient failures, such as this. Once started, it will continue to run and attempt to make forward progress by reading and dispatching messages. Failures will be reported to your error handler, and the processor will continue to retry forever until it is explicitly stopped.