bgmulinari / B1SLayer

A lightweight SAP Business One Service Layer client for .NET
MIT License
136 stars 47 forks source link

Large batch request, best approach ? #64

Open WitmondPaul opened 6 months ago

WitmondPaul commented 6 months ago

Hi Bruno,

What is the best solution to update a large number of special prices ? We must update 1.000.000 prices on a regular basis.

Regards,

Paul

bgmulinari commented 6 months ago

Hi, @WitmondPaul.

Batch requests are not really meant for such a large procedure (updating all in one go). Each operation inside a batch is processed sequentially by Service Layer, so the larger your batch, the longer it will take for it to complete. The main advantages of batch requests is the reduction of the network latency and the possibility to use a global transaction.

However, that does not mean will couldn't use batch requests for this. For your use case, I believe the best approach would be to split this load into several batches (100 updates per batch or so), but more importantly, developing it in a way that you can send several batch requests in parallel (non-sequentially), taking advantage of the asynchronous programming model in C#.

If you are not familiar with this concept, I recommend the reading: https://learn.microsoft.com/en-us/dotnet/csharp/asynchronous-programming/