Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Topic DefaultMessageTimeToLive and Subscription DefaultMessageTimeToLive on Azure Service Bus

Both a Topic on the Azure Service Bus and an associated Subscription expose the DefaultMessageTimeToLive property; initialised like so:

if (!NamespaceManager.TopicExists(TopicName))
{
    NamespaceManager.CreateTopic(
        new TopicDescription(TopicName)
            {
                MaxSizeInMegabytes = 5120,
                DefaultMessageTimeToLive = TimeSpan.FromDays(14)
            });
}

if (!NamespaceManager.SubscriptionExists(TopicName, SubscriptionName))
{
    NamespaceManager.CreateSubscription(
        new SubscriptionDescription(TopicName, SubscriptionName)
            {
                LockDuration = TimeSpan.FromMinutes(5),
                DefaultMessageTimeToLive = TimeSpan.FromDays(7),
                EnableDeadLetteringOnMessageExpiration = true
            });
}

What is the difference between the two and what is the purpose of having two TTL settings? Furthermore; if a message expires on the Topic what happens to it?

like image 812
Luke Merrett Avatar asked Dec 10 '13 10:12

Luke Merrett


1 Answers

The TTL set on a Topic is applied to all of its subscriptions. subscriptions can have their own TT if needed, however it should be less than Topic TTL. TTL applied on subscription is applied on all the a messages sent to it and messages can have its own TTL which should be again less than Subscription TTL. If the message expires and if DeadLettering enabled on the Subscription, expired messaged will be moved to DeadLetter queue else will be deleted permanently.

More info from here: http://msdn.microsoft.com/en-us/library/windowsazure/hh780749.aspx

like image 64
Dhana Krishnasamy Avatar answered Sep 28 '22 17:09

Dhana Krishnasamy