Azure Servicebus AutoDeleteOnIdle

杀马特。学长 韩版系。学妹 提交于 2019-12-12 20:43:01

问题


I'm trying to figure out the correct behavior when setting AutoDeleteOnIdle. I have a topic called MyGameMessages (not disclosing the game name since it might be considered advertisement).

What I do is that I create a subscription on each node in my server farm.

var manager = GetNameSpaceManager();
_subscriptionId = Guid.NewGuid().ToString();
var description = new SubscriptionDescription(topic, _subscriptionId);
description.AutoDeleteOnIdle = TimeSpan.FromHours(1);
manager.CreateSubscription(description);

Then I start up a thread that pretty much loops for eternity (or at least until signaled to quit)

while(_running)
{
    if (_subscriptionId == null)
        break;

    var message = client.Receive(TimeSpan.FromMinutes(1)); // MARK A
    if (message != null)
    {
        var body = message.GetBody<T>();
        // Do stuff with message
        message.Complete();
    }

}

Question A:

The first implementation had no timeout at MARK A. If no message is sent to this topic within one hour the subscription was autodeleted. Is this the behavior to expect? The client isn't really dead but I guess it just sits around waiting for a message. Is there no keep alive?

Question B:

Would it help to add the timeout as in MARK A or is it a better solution to create a new subscription every 50th minute (to create a small overlap just in case) and abandon the old one?

Thanks

Johan


回答1:


Johan, the scenario you describe above should work per your expectations. A pending receive call will keep the subscription alive even if no messages are flowing. Using longer timeouts for the Receive are better so you do not have chatty traffic when message volume is low. One thing to confirm is if your are setting the AutoDeleteOnIdle value for the Topic, in that case a receive on a subscription will NOT keep the Topic alive and if no messages are sent to the Topic for one hour then it will get deleted. Deleting a Topic results in all the Subscriptions being deleted too.

Are you still seeing this behavior of Subscriptions being deleted? If so then please create a ticket with Azure live site support and the product team an investigate the specifics.



来源:https://stackoverflow.com/questions/16971443/azure-servicebus-autodeleteonidle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!