ealsur / WebJobs.Extensions.GroupQueueTrigger

Extension for Azure Webjobs SDK that returns groups of messages of an Azure Queue
MIT License
20 stars 1 forks source link
azure azure-webjobs-sdk

Azure Webjobs SDK Extension for Azure Queue

Introduction

This extension will enable you to trigger functions and receive the group of messages instead of a single message like with [QueueTrigger]

Once referenced you can enable it on the JobHostConfiguration object.

var config = new JobHostConfiguration
{
    StorageConnectionString = "...",
    DashboardConnectionString = "..."
};
config.UseGroupQueueTriggers();
var host = new JobHost(config);
host.RunAndBlock();

It supports POCO objects and returns always a List.

And decorate each function like this:

public static void MyFunction([GroupQueueTrigger("my_queue")]List<MyClass> messages)

This way you will only get one trigger of the function and receive all the obtained messages, instead of one trigger per message with the [QueueTrigger].

There are optional parameters too: the size of the requested block:

public static void MyFunction([GroupQueueTrigger("my_queue", 10)]List<MyClass> messages)

And the Minimun and Maximun Polling intervals (in minutes):

public static void MyFunction([GroupQueueTrigger("my_queue", 10, 1, 10)]List<MyClass> messages)

Installation

You can obtain it through Nuget with:

Install-Package Microsoft.Azure.WebJobs.Extensions.GroupQueueTrigger

Or clone this repo and reference it.