Search code examples
azurepublish-subscribeservicebusorphaned-objects

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?


Solution

  • that exact feature is on the backlog for one of the next releases. that said, in azure you could use the instance-id fro the role environment to create the name of your subscription and thus have a restarting instance reuse a subscription. the instance-id names are stable.

    Edit: The feature is AutoDeleteOnIdle https://learn.microsoft.com/en-us/dotnet/api/microsoft.servicebus.messaging.subscriptiondescription