You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/service-bus-messaging/message-expiration.md
+17-33Lines changed: 17 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,15 @@
1
1
---
2
2
title: Azure Service Bus - message expiration
3
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.
4
-
ms.topic: conceptual
5
-
ms.date: 10/10/2023
4
+
ms.topic: concept-article
5
+
ms.date: 12/02/2024
6
+
# Customer intent: As an Azure Service Bus user, developer or architect, I want to know whether the message enqueued expires after a certain amount of time.
6
7
---
7
8
8
9
# Azure Service Bus - Message expiration (Time to Live)
9
-
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.
10
-
11
-
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.
12
-
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).
10
+
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. 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.
15
11
12
+
## Time to live and expires at UTC
16
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.
17
14
18
15
> [!NOTE]
@@ -22,15 +19,15 @@ Past the **expires-at-utc** instant, messages become ineligible for retrieval. T
22
19
23
20
Extremely low TTL in the order of milliseconds or seconds might cause messages to expire before receiver applications receive it. Consider the highest TTL that works for your application.
24
21
25
-
> [!NOTE]
26
-
> For [scheduled messages](message-sequencing.md#scheduled-messages), you specify the enqueue time at which you want the message to materialize in the queue for retrieval. The time at which the message is sent to Service Bus is different from the time at which the message is enqueued. The message expiration time depends on the enqueued time, not on the time at which the message is sent to Service Bus. Therefore, the **expires-at-utc** is still **enqueued time + time-to-live**.
27
-
>
28
-
> For example, if you set the `ScheduledEnqueueTimeUtc` to 5 minutes from `UtcNow`, and `TimeToLive` to 10 minutes, the message will expire after 5 + 10 = 15 minutes from now. The message materializes in the queue after 5 minutes and the 10 minute counter starts from then.
22
+
## Scheduled messages
23
+
For [scheduled messages](message-sequencing.md#scheduled-messages), you specify the enqueue time at which you want the message to materialize in the queue for retrieval. The time at which the message is sent to Service Bus is different from the time at which the message is enqueued. The message expiration time depends on the enqueued time, not on the time at which the message is sent to Service Bus. Therefore, the **expires-at-utc** is still **enqueued time + time-to-live**.
24
+
25
+
For example, if you set the `ScheduledEnqueueTimeUtc` to 5 minutes from `UtcNow`, and `TimeToLive` to 10 minutes, the message will expire after 5 + 10 = 15 minutes from now. The message materializes in the queue after 5 minutes and the 10 minute counter starts from then.
29
26
30
27
## Entity-level expiration
31
28
All messages sent into a queue or topic are subject to a default expiration that is set at the entity level. It can also be set in the portal during creation and adjusted later. The default expiration is used for all messages sent to the entity where time-to-live isn't explicitly set. The default expiration also functions as a ceiling for the time-to-live value. Messages that have a longer time-to-live expiration than the default value are silently adjusted to the default message time-to-live value before being enqueued.
32
29
33
-
The **expires-at-utc** is by design. If the message TTL is not set and only the entity TTL is set then **expires-at-utc** is a computed value and is not computed in the Peek path but is computed in the Receive/Peeklock path. If the message has TTL then this **expires-at-utc** is computed at the time message is sent and stored. So in this case Peek will return correct **expires-at-utc** values.
30
+
The **expires-at-utc** is by design. If the message TTL isn't set and only the entity TTL is set then **expires-at-utc** is a computed value and isn't computed in the Peek path but is computed in the Receive/Peeklock path. If the message has TTL then this **expires-at-utc** is computed at the time message is sent and stored. So in this case Peek will return correct **expires-at-utc** values.
34
31
35
32
> [!NOTE]
36
33
> - 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.
@@ -71,6 +68,7 @@ Here's what considered idleness of entities (queues, topics, and subscriptions):
71
68
> If you have auto forwarding setup on the queue or subscription, that is equivalent to having a receiver peform receives on the queue or subscription and they will not be idle.
72
69
73
70
## SDKs
71
+
You can set the time-to-live property using Software Development Kits (SDKs).
74
72
75
73
- 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#@azure-service-bus-servicebusmessage-timetolive)
76
74
- 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#@azure-service-bus-queueproperties-defaultmessagetimetolive)
@@ -79,23 +77,9 @@ Here's what considered idleness of entities (queues, topics, and subscriptions):
79
77
80
78
81
79
82
-
## Next steps
83
-
84
-
To learn more about Service Bus messaging, see the following articles:
85
-
86
-
-[Message sequencing and time stamps](message-sequencing.md)
87
-
-[Messages, payloads, and serialization](service-bus-messages-payloads.md)
-[Asynchronous messaging patterns and high availability](service-bus-async-messaging.md)
100
-
-[Handling outages and disasters](service-bus-outages-disasters.md)
101
-
-[Throttling](service-bus-throttling.md)
80
+
## Related content
81
+
82
+
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).
83
+
84
+
To learn about advanced features of Azure Service Bus, see [Overview of advanced features](advanced-features-overview.md).
0 commit comments