Reputation: 31
There are a lot of scenarios where batching message processing is far more efficient than working with an individual message.
public void Handle([ServiceBusTrigger("myqueue")] BrokeredMessage[] messages)
{
// Process the batch of messages
}
My scenario is :: I am using service bus queue. I want to process queued messages at particular interval of time in batch.
For example :: Per 10 seconds of interval time, I want to trigger a function to process all messages inside queue
Upvotes: 1
Views: 4567
Reputation: 51
Batching is supported in ServiceBusTrigger
from ver 4.1.0 but for your scenario as suggested TimerTrigger
would be more appropriate.
https://github.com/Azure/azure-functions-servicebus-extension/issues/15
https://github.com/Azure/azure-functions-servicebus-extension/releases/tag/v4.1.0
Upvotes: 3
Reputation: 1494
Azure Service Bus provides Batch operations through SDK. See this link for achieving it.
Azure Function Service Bus trigger gets triggered only when a message is en queued into the Queue.
As your requirement is to check for messages at regular intervals and receive messages in batch, you can process messages in batch inside Azure Function with Timer trigger
Upvotes: 0
Reputation: 26057
ServiceBusTrigger
is not designed to work with batches. Instead, it's designed to be a message pump providing you one message at a time. Azure Functions infrastructure takes care of creating listener and completing the message when Function is done.
If you need batches, suggest to look into Azure Service Bus with EventGrid.
The key scenario of this feature is that Service Bus queues or subscriptions with a low volume of messages do not need to have a receiver that polls for messages continuously.
With this approach, you could have a Function subscribe and triggered on ActiveMessagesAvailableWithNoListeners
event and receive messages in batch.
Upvotes: 3