Azure / azure-functions-servicebus-extension

Service Bus extension for Azure Functions
MIT License
65 stars 35 forks source link

IsBatched missing? #223

Open jsquire opened 1 year ago

jsquire commented 1 year ago

Issue Transfer

This issue has been transferred from the Azure SDK for .NET repository, #32619.

Please be aware that @onlywithlad is the author of the original issue and include them for any questions or replies.

Details

Hi,

Following document mentions of IsBatch but I can't find it in attribute class

https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus-trigger?tabs=in-process%2Cextensionv5&pivots=programming-language-csharp#attributes

jsquire commented 1 year ago

Additional Context: IsBatched is not a property of the attribute and has not been for some time. This is a case where documentation needs to be updated.

//cc: @shreyabatra4

Henr1k80 commented 1 year ago

Does it mean that batching is gone or how is it setup then? Is it inferred by the type, an array?

Henr1k80 commented 1 year ago

I found a way to set it globally, good enough for me. Maybe it can help someone in the same situation

services.Configure<ServiceBusOptions>(options =>
{
    // if MinMessageBatchSize is not reached within this wait time, it will execute with whatever number present in the batch
    // Default 30s, max 50% of the entity message lock duration. Therefore, the maximum allowed value is 2 minutes and 30 seconds. 
    options.MaxBatchWaitTime = TimeSpan.FromSeconds(10);
    // We are batching, so you probably only need one call executing and execute with concurrency inside the trigger
    // It should keep a one CPU plan pretty busy, without using too much memory.
    // If there is low CPU utilization, caused by waiting for external I/O, increase it to be able to chew though messages faster. 
    options.MaxConcurrentCalls = 1; 
    // Set the minimum to process, if MaxBatchWaitTime is exceeded, it will trigger with whatever batch size there is collected
    options.MinMessageBatchSize = 100;
    // Set the maximum number of messages per batch
    options.MaxMessageBatchSize = 100;
});