MrCalzone
MrCalzone

Reputation: 13

Use Azure webjobs and queue storage to execute at a given time

My goal is to push a message to the Azure queue, and have the webjob handle it at a given time. E.g. { message : "remember the milk", time: 2016-02-10-10:10:00}

I could do this naively by dequeueing the message, check the timestamp, and put it back on the queue if the time has not come.

Is there a more idiomatic way of doing this in the Azure world?

Upvotes: 1

Views: 256

Answers (1)

Peter
Peter

Reputation: 27944

You can set the initialVisibilityDelay:

[DoesServiceRequestAttribute]
public void AddMessage(
    CloudQueueMessage message,
    Nullable<TimeSpan> timeToLive = null,
    Nullable<TimeSpan> initialVisibilityDelay = null,
    QueueRequestOptions options = null,
    OperationContext operationContext = null
)

The message will be visible when the delay timeouts:

initialVisibilityDelay Type: System.Nullable A TimeSpan specifying the interval of time from now during which the message will be invisible. If null then the message will be visible immediately.

MSDN: microsoft.windowsazure.storage.queue.cloudqueue.addmessage

Upvotes: 2

Related Questions