Export (0) Print
Expand All

BrokeredMessage.TimeToLive Property

Gets or sets the message’s time to live value. This is the duration after which the message expires, starting from when the message is sent to the Service Bus.

Messages older than their TimeToLive value will expire and no longer be retained in the message store. Subscribers will be unable to receive expired messages.

TimeToLive is the maximum lifetime that a message can receive, but its value cannot exceed the entity specified the DefaultMessageTimeToLive value on the destination queue or subscription. If a lower TimeToLive value is specified, it will be applied to the individual message. However, a larger value specified on the message will be overridden by the entity’s DefaultMessageTimeToLive value.

Namespace:  Microsoft.ServiceBus.Messaging
Assembly:  Microsoft.ServiceBus (in Microsoft.ServiceBus.dll)

public TimeSpan TimeToLive { get; set; }

Property Value

Type: System.TimeSpan
The message’s time to live value.

ExceptionCondition
ObjectDisposedException

Thrown if the message is in disposed state.

ArgumentOutOfRangeException

Thrown if the passed in value is less than or equal to TimeSpan.Zero.

The message will be moved to the dead letter queue at TTL expiry if dead lettering is enabled. Otherwise, the message will be discarded from the system. See EnableDeadLetteringOnMessageExpiration and EnableDeadLetteringOnMessageExpiration to learn more about how to control dead lettering setting for Queues and Subscriptions respectively.

If the TTL set on a message by the sender exceeds the destination's TTL, then the message's TTL will be overwritten by the later value. See DefaultMessageTimeToLive, DefaultMessageTimeToLive and DefaultMessageTimeToLive to learn more about how to control message TTL at an entity level.

If there are no receive operations on a queue or subscription, the MessageCount property may include messages for which TimeToLive has expired. When a receive operation is called on the queue, the expired messages will not be delivered and the MessageCount property will be updated appropriately.

There is no minimum or maximum bound on TimeToLive.

Community Additions

ADD
Show:
© 2014 Microsoft