Azure-webjobs-sdk: confusion about NewBatchThreshold

Created on 12 Feb 2016  路  2Comments  路  Source: Azure/azure-webjobs-sdk

What is the _NewBatchThreshold_ doing exactly?

I just realized that my queues were I want synchronous processing require Batchsize = 1 and NewBatchThreshold = 0 in my Custom Queue Processor.
I left NewBatchThreshold always on the default values before.

when I do it global with:
config.Queues.BatchSize = 1;

this automatically sets NewBatchThreshold to 0 which I was nor aware of and is a bit confusing to me.

Thanks,
Alex

Most helpful comment

The NewBatchThreshold is a the number of messages to have left to process in the batch before the SDK refreshes the batch.

For example, if your batch size is 20 and NewBtachThreshold is 5, the SDK will grab 20 messages off the queue each time, pass them to your code for you to process them one by one, then when it gets down to the last 5 unprocessed messages (so you've processed 15) it will grab the next 20. See here under "Parallel execution"

By default the NewBatchThreshold is half of BatchSize (see source code) which is why you are seeing a value of 0 for a batch size of 1.

All 2 comments

The NewBatchThreshold is a the number of messages to have left to process in the batch before the SDK refreshes the batch.

For example, if your batch size is 20 and NewBtachThreshold is 5, the SDK will grab 20 messages off the queue each time, pass them to your code for you to process them one by one, then when it gets down to the last 5 unprocessed messages (so you've processed 15) it will grab the next 20. See here under "Parallel execution"

By default the NewBatchThreshold is half of BatchSize (see source code) which is why you are seeing a value of 0 for a batch size of 1.

Correct :)

Was this page helpful?
0 / 5 - 0 ratings