Search code examples
.netazureazure-storage-queues

How does WebJob QueueTrigger trigger, polling or event?


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?


Solution

  • This link has your answer;

    https://web.archive.org/web/20160131173918/https://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();