Share via


BrokeredMessage.TimeToLive Property

Definition

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.

public TimeSpan TimeToLive { get; set; }
member this.TimeToLive : TimeSpan with get, set
Public Property TimeToLive As TimeSpan

Property Value

The message’s time to live value.

Exceptions

Thrown if the message is in disposed state.

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

Remarks

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 one. See DefaultMessageTimeToLive, DefaultMessageTimeToLive and DefaultMessageTimeToLive to learn more about how to control message TTL at an entity level.

Applies to