4

I've tried to do my homework on this issue but no searches I can make have gotten me closer to the answer. Closest hit was Detect and Delete Orphaned Queues, Topics, or Subscriptions on Azure Service Bus.

My scenario:

I have multiple services running (standard win service). At startup these processes starts to subscribe to a given topic in Azure Service Bus. Let's call the topic "Messages".

When the service is shut down it unsubcribes in a nice way.

But sometimes stuff happens and the service crashes, causing the unsubscription to fail and the subscription then is left hanging.

My questions:

1) From what I'm seeing, each dead topic subscription counts when a message is sent to that topic. Even if no one is ever going to pick it up. Fact or fiction?

2) Is there anyway to remove subscriptions that haven't been checked for a while, for example for the last 24h? Preferrably by a Power Shell script?

I've raised this issue directly with Microsoft but haven't received any answer yet. Surely, I can't be the first to experience this. I'll also update this if I get any third party info.

Thanks

Johan

Community
  • 1
  • 1
Johan Karlsson
  • 898
  • 1
  • 10
  • 24

2 Answers2

9

In the Azure SDK 2.0 release we have addressed this scenario with the AutoDeleteOnIdle feature. This will allow you to set a timespan on a Queue/Topic/Subscription and the when no activity is detected for the specified duration, the entity will automatically be deleted. See details here, and the property to set is here.

Abhishek Lal
  • 3,233
  • 1
  • 17
  • 16
  • I currently am using silverlight to create topics and subscriptions. I would like to take advantage of this new feature but am having issues with the correct namespace for the data contract. To get my current setup working, I used the Microsoft.Samples.ServiceBus.Messaging package which references a data contract of [DataContract(Name = "SubscriptionDescription", Namespace = "http://schemas.microsoft.com/netservices/2010/10/servicebus/connect")] . Do you have any pointers on where I could get the new namespace? – kjsteuer Jul 29 '13 at 06:08
  • That sources is out of date, you can see the latest XML doc schema and api-version to use from the Azure Java SDK: https://github.com/WindowsAzure/azure-sdk-for-java/blob/master/microsoft-azure-api/src/main/java/com/microsoft/windowsazure/services/serviceBus/models/SubscriptionInfo.java – Abhishek Lal Jul 29 '13 at 23:57
  • There probably isn't an updated source for silverlight then right? I will checkout the java sdk. – kjsteuer Jul 30 '13 at 04:39
  • The AutoDeleteOnIdle does not seem to work if the topic is being filled continuously on a inactive subscription. – Patrick Peters Nov 02 '17 at 13:28
5

On your 1) question, yes messages sent to a topic will be sent to any matching subscription, even if that is Idle (based on your own logic). A subscription is a permanent artifact that you create that is open to receive messages, even when no services are dequeuing messages.

To clean out subscriptions, you can probably use the AccessedAt property of the SubscriptionDescription and use that to check when someone last read the queue (by a Receive operation). http://msdn.microsoft.com/en-us/library/microsoft.servicebus.messaging.subscriptiondescription.accessedat.aspx

If you use that logic, you can build your own 'cleansing' mechanisms

HTH

Sam Vanhoutte
  • 3,247
  • 27
  • 48
  • Perfect! I'll create a blog post about this aswell to outline the procedure. To get subscriptions: http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.servicebus.namespacemanager.getsubscription.aspx – Johan Karlsson May 21 '13 at 07:07
  • And to deleted them http://msdn.microsoft.com/en-us/library/windowsazure/microsoft.servicebus.namespacemanager.deletesubscription.aspx – Johan Karlsson May 21 '13 at 07:08
  • To clarify "counts" on question one. What I mean is that it counts against you quota of messages per month. – Johan Karlsson May 21 '13 at 07:09
  • Indeed > every message + action counts towards billing & usage details. (even a receive that doesn't return a message ...) – Sam Vanhoutte May 21 '13 at 07:25