AvinashSachdewani
AvinashSachdewani

Reputation: 156

How to set message time to live unlimited in azure service bus queue?

I am trying to create azure service bus queue using azure-sdk-for-node but not able to find the resource to set time to live unlimited .

Here is my sample code :

var queueOptions = {
      MaxSizeInMegabytes: '5120',
      DefaultMessageTimeToLive: 'PT1M'
    };

serviceBusService.createQueueIfNotExists('myqueue', queueOptions, function(error){
    if(!error){
        // Queue exists
    }
});

What will be in DefaultMessageTimeToLive for unlimited time ?

Upvotes: 7

Views: 6793

Answers (2)

Sagi Sulimani
Sagi Sulimani

Reputation: 86

"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." (From Microsoft docs)

Upvotes: 0

Sean Feldman
Sean Feldman

Reputation: 26012

Your code sets the message TTL to 1 minute only. You can't set TTL to unlimited as it requires a TimeSpan value, so you have to assign something. It could be a fairly large value, but I'd recommend to avoid this practice for a few reasons:

  1. It's a hosted service. TTL is not constrained today, but could be.
  2. For messaging, having a very long TTL is an indication of something that should not be done (messages should be small and processed fast).

Saying that, as of today, you could set TTL to the TimeSpan.MaxValue, which is

  • 10675199 days
  • 2 hours
  • 48 minutes
  • 5 seconds
  • 477 milliseconds

or in iso8601 format is P10675199DT2H48M5.4775807S.

Realistically, 365 days (P365D) or even 30 days (P30D) is way too much for messaging.

Upvotes: 13

Related Questions