如何在 ServiceBus ManagementClient CreateSubscriptionAsync 上设置 TTL
How to set TTL on ServiceBus ManagementClient CreateSubscriptionAsync
当我按如下方式创建订阅时,TTL 默认为 10675199 天
var client = new ManagementClient(connStr);
if (!await client.SubscriptionExistsAsync(topicName, subscriptionName))
{
// TODO: this has an unlimited TTL, which needs to be reduced to 1 day.
client.CreateSubscriptionAsync(topicName, subscriptionName);
}
如何从代码中设置?
你应该使用CreateSubscriptionAsync
的重载方法,它以SubscriptionDescription
为参数。
如下所示:
var sd = new SubscriptionDescription(topicName, subscriptionName)
{
DefaultMessageTimeToLive = TimeSpan.FromDays(1)
};
if (!await client.SubscriptionExistsAsync(topicName, subscriptionName))
{
client.CreateSubscriptionAsync(sd);
}
有关详细信息,请参阅 here。
当我按如下方式创建订阅时,TTL 默认为 10675199 天
var client = new ManagementClient(connStr);
if (!await client.SubscriptionExistsAsync(topicName, subscriptionName))
{
// TODO: this has an unlimited TTL, which needs to be reduced to 1 day.
client.CreateSubscriptionAsync(topicName, subscriptionName);
}
如何从代码中设置?
你应该使用CreateSubscriptionAsync
的重载方法,它以SubscriptionDescription
为参数。
如下所示:
var sd = new SubscriptionDescription(topicName, subscriptionName)
{
DefaultMessageTimeToLive = TimeSpan.FromDays(1)
};
if (!await client.SubscriptionExistsAsync(topicName, subscriptionName))
{
client.CreateSubscriptionAsync(sd);
}
有关详细信息,请参阅 here。