Auto-expire lost subscription (Azure ServiceBus Messaging SubscriptionClient)

The scenario I have in mind is this: the service bus is used to communicate between instances, so the subscription is unique for each instance of the service. The end result is that if the instance does not close gracefully, its subscription is not deleted.

When the service instance dies and restarts, the previous contents of the subscription are irrelevant and may be discarded.

So, is there a way to set the "time to live" for subscribing to the service bus or imitate something like this without resorting to some special mechanism for detecting orphans?

+6
source share
3 answers

this exact function is lagging for one of the next releases. that in azure mode you can use the instance identifier for the role environment to create the name of your subscription and thus restart the instance to reuse the subscription. the names of instance identifiers are stable.

Edit: AutoDeleteOnIdle function https://docs.microsoft.com/en-us/dotnet/api/microsoft.servicebus.messaging.subscriptiondescription

+4
source

Starting with the Azure SDK 2.0, this works as expected.

In addition, contrary to other reports, in my testing the subscription is not deleted if there is a pending receiver listening to this subscription.

var description = new SubscriptionDescription(topicPath, subscriptionId); description.AutoDeleteOnIdle = TimeSpan.FromSeconds(600); namespaceManager.CreateSubscription(description); 
+6
source

I had the same problem: the preview was released in early 2013: http://msdn.microsoft.com/en-us/library/microsoft.servicebus.messaging.subscriptiondescription.autodeleteonidle.aspx

It is very easy to use (see example below). Unfortunately, it seems that the subscription expires if there is no message published for the AutoDeleteOnIdle period, even if you have some kind of process waiting for messages (according to the Azure Servicebus AutoDeleteOnIdle ).

 NamespaceManager manager=NamespaceManager.CreateFromConnectionString(serviceBusConnectionString); if(!manager.SubscriptionExists(topic,subscriptionName)) { manager.CreateSubscription(new SubscriptionDescription(topic,subscriptionName) { AutoDeleteOnIdle=TimeSpan.FromDays(2) }); } 
0
source

All Articles