Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 218
AvinashSachdewani Avatar asked Jul 27 '16 10:07

AvinashSachdewani


1 Answers

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.

like image 149
Sean Feldman Avatar answered Nov 15 '22 04:11

Sean Feldman