Azure Servicebus AutoDeleteOnIdle [英] Azure Servicebus AutoDeleteOnIdle

查看:62
本文介绍了Azure Servicebus AutoDeleteOnIdle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在设置AutoDeleteOnIdle时,我试图找出正确的行为.我有一个名为MyGameMessages的主题(未公开游戏名称,因为它可能被视为广告).

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();
    }

}

问题A:

第一个实现在MARK 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?

问题B:

像MARK A中那样增加超时会有所帮助吗?还是每隔50分钟创建一个新的订阅(以防万一,以创建一个小的重叠)并放弃旧的订阅的更好的解决方案?

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?

谢谢

Johan

推荐答案

Johan,您上面描述的方案应符合您的期望.挂起的接收呼叫将使订阅保持活动状态,即使没有消息在流动.为接收使用更长的超时效果更好,因此当消息量较低时,您不会产生闲聊流量.需要确认的一件事是,如果您正在为主题设置AutoDeleteOnIdle值,在这种情况下,订阅的接收将无法使主题保持活动状态,并且如果一小时内没有任何消息发送到主题,则该主题将被删除.删除主题会导致所有订阅也被删除.

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.

您仍然看到订阅的这种行为被删除了吗?如果是这样,请在Azure现场站点支持下创建票证,然后产品团队对具体情况进行调查.

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.

这篇关于Azure Servicebus AutoDeleteOnIdle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆