Skip to content

Commit e9706ab

Browse files
authored
Merge pull request #180327 from spelluru/sbusttl1117
Clickthrough perf improvement
2 parents 83e78a5 + fe549ac commit e9706ab

File tree

1 file changed

+42
-31
lines changed

1 file changed

+42
-31
lines changed
Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
---
22
title: Azure Service Bus - message expiration
3-
description: This article explains about expiration and time to live of Azure Service Bus messages. After such a deadline, the message is no longer delivered.
3+
description: This article explains about expiration and time to live (TTL) of Azure Service Bus messages. After such a deadline, the message is no longer delivered.
44
ms.topic: conceptual
5-
ms.date: 11/01/2021
5+
ms.date: 11/17/2021
66
---
77

8-
# Message expiration (Time to Live)
8+
# Azure Service Bus - Message expiration (Time to Live)
99
The payload in a message, or a command or inquiry that a message conveys to a receiver, is almost always subject to some form of application-level expiration deadline. After such a deadline, the content is no longer delivered, or the requested operation is no longer executed.
1010

1111
For development and test environments in which queues and topics are often used in the context of partial runs of applications or application parts, it's also desirable for stranded test messages to be automatically garbage collected so that the next test run can start clean.
1212

13-
The expiration for any individual message can be controlled by setting the **time-to-live** system property, which specifies a relative duration. The expiration becomes an absolute instant when the message is enqueued into the entity. At that time, the **expires-at-utc** property takes on the value **enqueued-time-utc** + **time-to-live**. The time-to-live (TTL) setting on a brokered message isn't enforced when there are no clients actively listening.
13+
> [!NOTE]
14+
> If you aren't familiar with Service Bus concepts yet, see [Service Bus concepts](service-bus-messaging-overview.md#concepts), and [Service Bus queues, topics, and subscriptions](service-bus-queues-topics-subscriptions.md).
1415
15-
Past the **expires-at-utc** instant, messages become ineligible for retrieval. The expiration doesn't affect messages that are currently locked for delivery. Those messages are still handled normally. If the lock expires or the message is abandoned, the expiration takes immediate effect.
16+
The expiration for any individual message can be controlled by setting the **time-to-live** system property, which specifies a relative duration. The expiration becomes an absolute instant when the message is enqueued into the entity. At that time, the **expires-at-utc** property takes on the value **enqueued-time-utc** + **time-to-live**. The time-to-live (TTL) setting on a brokered message isn't enforced when there are no clients actively listening.
1617

17-
While the message is under lock, the application might be in possession of a message that has expired. Whether the application is willing to go ahead with processing or chooses to abandon the message is up to the implementer.
18+
Past the **expires-at-utc** instant, messages become ineligible for retrieval. The expiration doesn't affect messages that are currently locked for delivery. Those messages are still handled normally. If the lock expires or the message is abandoned, the expiration takes immediate effect. While the message is under lock, the application might be in possession of a message that has expired. Whether the application is willing to go ahead with processing or chooses to abandon the message is up to the implementer.
1819

1920
Extremely low TTL in the order of milliseconds or seconds may cause messages to expire before receiver applications receive it. Consider the highest TTL that works for your application.
2021

@@ -23,12 +24,12 @@ All messages sent into a queue or topic are subject to a default expiration that
2324

2425
> [!NOTE]
2526
> - The default time-to-live value for a brokered message is the largest possible value for a signed 64-bit integer if not otherwise specified.
26-
> - For messaging entities (queues and topics), the default expiration time is also largest possible value for a signed 64-bit integer for Service Bus standard and premium tiers. For the **basic** tier, the default (also maximum) expiration time is **14 days**.
27+
> - For messaging entities (queues and topics), the default expiration time is also largest possible value for a signed 64-bit integer for [Service Bus standard and premium](service-bus-premium-messaging.md) tiers. For the **basic** tier, the default (also maximum) expiration time is **14 days**.
2728
> - If the topic specifies a smaller TTL than the subscription, the topic TTL is applied.
2829
2930
Expired messages can optionally be moved to a [dead-letter queue](service-bus-dead-letter-queues.md). You can configure this setting programmatically or using the Azure portal. If the option is left disabled, expired messages are dropped. Expired messages moved to the dead-letter queue can be distinguished from other dead-lettered messages by evaluating the [dead-letter reason](service-bus-dead-letter-queues.md#moving-messages-to-the-dlq) property that the broker stores in the user properties section.
3031

31-
In the aforementioned case in which the message is protected from expiration while under lock and if the flag is set on the entity, the message is moved to the dead-letter queue as the lock is abandoned or expires. However, it isn't moved if the message is successfully settled, which then assumes that the application has successfully handled it, in spite of the nominal expiration.
32+
If the message is protected from expiration while under lock and if the flag is set on the entity, the message is moved to the dead-letter queue as the lock is abandoned or expires. However, it isn't moved if the message is successfully settled, which then assumes that the application has successfully handled it, in spite of the nominal expiration. For more information about message locks and settlement, see [Message transfers, locks, and settlement](message-transfers-locks-settlement.md).
3233

3334
The combination of time-to-live and automatic (and transactional) dead-lettering on expiry are a valuable tool for establishing confidence in whether a job given to a handler or a group of handlers under a deadline is retrieved for processing as the deadline is reached.
3435

@@ -39,36 +40,46 @@ For example, consider a web site that needs to reliably execute jobs on a scale-
3940

4041
Service Bus queues, topics, and subscriptions can be created as temporary entities, which are automatically removed when they haven't been used for a specified period of time.
4142

42-
Automatic cleanup is useful in development and test scenarios in which entities are created dynamically and aren't cleaned up after use, due to some interruption of the test or debugging run. It is also useful when an application creates dynamic entities, such as a reply queue, for receiving responses back into a web server process, or into another relatively short-lived object where it is difficult to reliably clean up those entities when the object instance disappears.
43+
Automatic cleanup is useful in development and test scenarios in which entities are created dynamically and aren't cleaned up after use, due to some interruption of the test or debugging run. It's also useful when an application creates dynamic entities, such as a reply queue, for receiving responses back into a web server process, or into another relatively short-lived object where it's difficult to reliably clean up those entities when the object instance disappears.
4344

44-
The feature is enabled using the **auto delete on idle** property on the namespace. This property is set to the duration for which an entity must be idle (unused) before it is automatically deleted. The minimum value for this property is 5 minutes.
45+
The feature is enabled using the **auto delete on idle** property on the namespace. This property is set to the duration for which an entity must be idle (unused) before it's automatically deleted. The minimum value for this property is 5 minutes.
4546

4647
## Idleness
4748

4849
Here's what considered idleness of entities (queues, topics, and subscriptions):
4950

50-
- Queues
51-
- No sends
52-
- No receives
53-
- No updates to the queue
54-
- No scheduled messages
55-
- No browse/peek
56-
- Topics
57-
- No sends
58-
- No updates to the topic
59-
- No scheduled messages
60-
- No operations on the topic's subscriptions (as shown below)
61-
- Subscriptions
62-
- No receives
63-
- No updates to the subscription
64-
- No new rules added to the subscription
65-
- No browse/peek
51+
| Entity | What's considered idle |
52+
| ------ | ---------------------- |
53+
| Queue | <ul><li>No sends</li><li>No receives</li><li>No updates to the queue</li><li>No scheduled messages</li><li>No browse/peek</li> |
54+
| Topic | <ul><li>No sends</li><li>No updates to the topic</li><li>No scheduled messages</li><li>No operations on the topic's subscriptions (see the next row)</li></ul> |
55+
| Subscription | <ul><li>No receives</li><li>No updates to the subscription</li><li>No new rules added to the subscription</li><li>No browse/peek</li></ul> |
56+
57+
## SDKS
58+
59+
- To set time-to-live on a message: [.NET](/dotnet/api/azure.messaging.servicebus.servicebusmessage.timetolive), [Java](/java/api/com.azure.messaging.servicebus.servicebusmessage.settimetolive), [Python](/python/api/azure-servicebus/azure.servicebus.servicebusmessage), [JavaScript](/javascript/api/@azure/service-bus/servicebusmessage#timeToLive)
60+
- To set the default time-to-live on a queue: [.NET](/dotnet/api/azure.messaging.servicebus.administration.createqueueoptions.defaultmessagetimetolive), [Java](/java/api/com.azure.messaging.servicebus.administration.models.createqueueoptions.setdefaultmessagetimetolive), [Python](/python/api/azure-servicebus/azure.servicebus.management.queueproperties), [JavaScript](/javascript/api/@azure/service-bus/queueproperties#defaultMessageTimeToLive)
61+
- To set the default time-to-live on a topic: [.NET](/dotnet/api/azure.messaging.servicebus.administration.createtopicoptions.defaultmessagetimetolive), [Java](/java/api/com.azure.messaging.servicebus.administration.models.createtopicoptions.setdefaultmessagetimetolive), [Python](/python/api/azure-servicebus/azure.servicebus.management.topicproperties), [JavaScript](/javascript/api/@azure/service-bus/topicproperties#defaultMessageTimeToLive)
62+
- To set the default time-to-live on a subscription: [.NET](/dotnet/api/azure.messaging.servicebus.administration.createsubscriptionoptions.defaultmessagetimetolive), [Java](), [Python](), [JavaScript](/java/api/com.azure.messaging.servicebus.administration.models.createsubscriptionoptions.setdefaultmessagetimetolive), [Python](/python/api/azure-servicebus/azure.servicebus.management.subscriptionproperties), [JavaScript](/javascript/api/@azure/service-bus/subscriptionproperties)
6663

6764

68-
## Next steps
6965

70-
To learn more about Service Bus messaging, see the following topics:
66+
## Next steps
7167

72-
* [Service Bus queues, topics, and subscriptions](service-bus-queues-topics-subscriptions.md)
73-
* [Get started with Service Bus queues](service-bus-dotnet-get-started-with-queues.md)
74-
* [How to use Service Bus topics and subscriptions](service-bus-dotnet-how-to-use-topics-subscriptions.md)
68+
To learn more about Service Bus messaging, see the following articles:
69+
70+
- [Message sequencing and time stamps](message-sequencing.md)
71+
- [Messages, payloads, and serialization](service-bus-messages-payloads.md)
72+
- [Message sessions](message-sessions.md)
73+
- [Duplicate message detection](duplicate-detection.md)
74+
- [Topic filters](topic-filters.md)
75+
- [Message browsing](message-browsing.md)
76+
- [Message transfers, locks, and settlement](message-transfers-locks-settlement.md)
77+
- [Dead-letter queues](service-bus-dead-letter-queues.md)
78+
- [Message deferral](message-deferral.md)
79+
- [Pre-fetch messages](service-bus-prefetch.md)
80+
- [Autoforward messages](service-bus-auto-forwarding.md)
81+
- [Transaction support](service-bus-transactions.md)
82+
- [Geo-disaster recovery](service-bus-geo-dr.md)
83+
- [Asynchronous messaging patterns and high availability](service-bus-async-messaging.md)
84+
- [Handling outages and disasters](service-bus-outages-disasters.md)
85+
- [Throttling](service-bus-throttling.md)

0 commit comments

Comments
 (0)