The documentation on BrokeredMessage says:
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.
So, to achieve messages to be automatically removed from my "Log" subscription, When creating the subscription, I have set the SubscriptionDescription.DefaultMessageTimeToLive
property to TimeSpan.FromDays(5)
.
When I create and send a brokered message, leaving the TimeToLive
property on that message to the default value, when I inspect messages arriving in that the subscription, the ExpiresAtUtc
property for the messages is 31-12-9999 23:59
. and the TimetoLive
property is 10675199.02:48:05.4775807
. Since the TTL on the 'destination' subscription is 5 days, I would have expected a value 5.00:00:00
there.
Is there something else that I need to do to get this working?
Steps to reproduce with Service Bus Explorer 2.2.1.0
Apparenlty the TTL value on peeked messages is meaningless:
This behavior is currently by design and should be seen independent of SDK version: the effective TTL is the minimum TTL of message and entity and is checked at runtime, rather than imprinted on the message at enqueue time (because the entity-level TTL could be changed at any time after messages were enqueued). The documentation is misleading and should be fixed.
This answer was given on this MSDN thread: http://social.msdn.microsoft.com/Forums/windowsazure/en-US/dfe58dbb-186d-4c71-a708-8f6f7267b451/when-peeking-for-messages-the-time-to-live-value-seems-not-to-be-set-is-this-a-bug