Azure 如何在ServiceBus ManagementClient CreateSubscriptionAsync上设置TTL
当我创建如下订阅时,TTL默认为10675199天Azure 如何在ServiceBus ManagementClient CreateSubscriptionAsync上设置TTL,azure,azureservicebus,ttl,azure-servicebus-subscriptions,Azure,Azureservicebus,Ttl,Azure Servicebus Subscriptions,当我创建如下订阅时,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.CreateSubscription
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);
}
有关更多详细信息,请参阅