MrCalzone February 2016

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?

Answers


Peter February 2016

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

Post Status

Asked in February 2016
Viewed 1,374 times
Voted 7
Answered 1 times

Search




Leave an answer