Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto-expire orphaned Subscription (Azure ServiceBus Messaging SubscriptionClient)

The scenario I have in mind is this: Service Bus is used for instance-to-instance communication, so a Subscription is unique per service instance. The end result is that if an instance does not shut down gracefully, its subscription does not get deleted.

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

So, is there a way to set a "time to live" for Service Bus Subscription or simulate something similar, without having to resort to some custom orphan detection mechanism?

like image 666
Andrei Avatar asked Nov 02 '12 19:11

Andrei


People also ask

Where are the expired messages in queue stored?

When you enable dead-lettering on queues or subscriptions, all expiring messages are moved to the DLQ.

What is message lock duration in Azure Service Bus?

The default value for the lock duration is 30 seconds. You can specify a different value for the lock duration at the queue or subscription level. The client owning the lock can renew the message lock by using methods on the receiver object.

What is Service Bus in Azure?

Azure Service Bus is a fully managed enterprise message broker with message queues and publish-subscribe topics (in a namespace). Service Bus is used to decouple applications and services from each other, providing the following benefits: Load-balancing work across competing workers.

Does Azure Service Bus store messages?

What is an Azure Service Bus queue? A Service Bus queue is an entity in which messages are stored. Queues are useful when you have multiple applications, or multiple parts of a distributed application that need to communicate with each other.


1 Answers

Starting with Azure SDK 2.0 this works as expected.

Also, contrary to other reports, in my testing, subscription does not get deleted as long as there is a pending receiver listening to that subscription.

var description = new SubscriptionDescription(topicPath, subscriptionId);
description.AutoDeleteOnIdle = TimeSpan.FromSeconds(600);
namespaceManager.CreateSubscription(description);
like image 166
Andrei Avatar answered Nov 11 '22 08:11

Andrei