简体   繁体   中英

Azure Function Trigger for List<POCO> Storage Queue

We have a subscription to Event Grid with an endpoint type as Storage Queue (say xyz-queue). We also have an Azure Function which is a Queue (xyz-queue) trigger. Every message in xyz-queue storage Queue is EventGridEvent object. I have Azure Function trigger something like below:

public static void Run([QueueTrigger(xyz-queue, Connection = "connnection")] EventGridEvent ege)

Since, there will be 1000's of messages with same POCO object (in this case EventGridEvent), is there a way where we can read multiple messages, process them together and also ensure we are not reading more than 5 messages so that function do not take long time to process.

The number of queue messages that the Functions runtime retrieves simultaneously and processes in parallel . When the number being processed gets down to the newBatchThreshold , the runtime gets another batch and starts processing those messages. So the maximum number of concurrent messages being processed per function is batchSize plus newBatchThreshold . This limit applies separately to each queue-triggered function.

{
    "version": "2.0",
    "extensions": {
        "queues": {
            "maxPollingInterval": "00:00:02",
            "visibilityTimeout" : "00:00:30",
            "batchSize": 5,
            "maxDequeueCount": 5,
            "newBatchThreshold": 2
        }
    }
}

For more details, you could refer to this article .

Also, if you want to output queue message multiple with poco, you could use ICollector and IAsyncCollector .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM