12

How can I add a message to Azure queue storage that will show up in the queue exactly tomorrow (after 24 h) ?

user2818430
  • 5,853
  • 21
  • 82
  • 148

1 Answers1

28

If you are using the Storage Client Library, you will be able to use the addMessage overload in CloudQueue that takes the initial visibility delay as an input param.

Specifically, you would have to use the following overload in 2.0:

AddMessage(CloudQueueMessage message, TimeSpan? timeToLive = null, TimeSpan? initialVisibilityDelay = null, QueueRequestOptions options = null, OperationContext operationContext = null)

If you are using version 1.7, you would use the following overload:

public void AddMessage(CloudQueueMessage message, TimeSpan? timeToLive, TimeSpan? initialVisibilityDelay)

You can find more info about Visibility timeout and how it works here.

While the TTL (Time to Live;ie, time until death; not time until live) is not capped (as of version 2017-07-29) the visibilityTimeout "must be larger than or equal to 0, and cannot be larger than 7 days"

Andrew Hill
  • 1,921
  • 1
  • 25
  • 31
  • 3
    We have been using this initialVisibilityDelay property as well, but just "discovered" a limitation with it: You cannot delay the queue message for more than 7 days from the current time! This was a dealbreaker for us, but it may be possible to work around it by throwing another message back on the queue if not enough time has passed (if you need more than 1 week) – starmandeluxe Dec 13 '16 at 06:05
  • @starmandeluxe that is because messages expire if they have been sitting on a queue unprocessed for a week, so any method of awaiting a whole week using a queue will be problematic. – Andrew Hill Feb 06 '19 at 04:48
  • 2
    @AndrewHill It's worth noting that the TTL maximum is no longer 7 days, as long as you're using an ARM template later than 2017-07-29. https://learn.microsoft.com/en-us/rest/api/storageservices/Put-Message – twoleggedhorse Aug 15 '19 at 08:56
  • what if you are using a function binding rather than connecting to the storage service explicitly in your code? – Alex Gordon Dec 18 '19 at 21:28