'Azure.Messaging.ServiceBus QueueProperties property DefaultMessageTimeToLive not updating correctly
I'm trying to leverage the Time To Live property of Azure Service Bus Queues to clear the queue if it gets backed up. I've been trying to use the DefaultMessageTimeToLive property on the queue to do this by setting it to one second like so
private static ServiceBusAdministrationClient client = new ServiceBusAdministrationClient(Environment.GetEnvironmentVariable("ServiceBusNamespaceConnectionString"));
QueueProperties properties = await client.GetQueueAsync(queueName);
properties.DefaultMessageTimeToLive = new TimeSpan(0, 0, 5);
However, after executing this code, the TimeSpan has stayed the same on the Azure portal and no messages have expired. I'm guessing because the setting is simply set locally. How would I get these changes to be set on the actual queue itself?
Solution 1:[1]
To anyone else that comes across this, use the UpdateQueueAsync call to do this.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | rhetoric3 |
