How does WebJob QueueTrigger trigger, polling or event?

Alexander S. picture Alexander S. · Jan 7, 2015 · Viewed 10.2k times · Source
public static void ProcessMessage([QueueTrigger("queue")] string message, TextWriter log)
{
    //processing message
}

How exactly this method will be triggered.

Is WebJob host just poling the Storage Queue. Or Storage Queue raising new message event, that host subscribed to?

Answer

daronyondem picture daronyondem · Jan 7, 2015

This link has your answer;

http://azure.microsoft.com/en-us/documentation/articles/websites-dotnet-webjobs-sdk-storage-queues-how-to/

Polling algorithm

The SDK implements a random exponential back-off algorithm to reduce the effect of idle-queue polling on storage transaction costs. When a message is found, the SDK waits two seconds and then checks for another message; when no message is found it waits about four seconds before trying again. After subsequent failed attempts to get a queue message, the wait time continues to increase until it reaches the maximum wait time, which defaults to one minute. The maximum wait time is configurable.

This can help too;

JobHostConfiguration config = new JobHostConfiguration();       
config.Queues.MaxPollingInterval = TimeSpan.FromMinutes(1);        
JobHost host = new JobHost(config);
host.RunAndBlock();