Auto-expire orphaned Subscription (Azure ServiceBus Messaging SubscriptionClient)

前端 未结 3 1361
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-12 02:37

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

3条回答
  •  爱一瞬间的悲伤
    2021-01-12 03:39

    I had the exact same problem, preview solving it was released beginning of 2013: http://msdn.microsoft.com/en-us/library/microsoft.servicebus.messaging.subscriptiondescription.autodeleteonidle.aspx

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

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

提交回复
热议问题