Batch Bundling Multi threading in x++ in D365F&O.
๐งบ Batch Bundling: The Efficiency Trap
Batch Bundling is a simple idea: Take a big pile of work and divide it into smaller, equal-sized groups—called bundles—and assign each group to a different processor.
Think of it like dividing a huge stack of mail into 10 smaller bundles, and giving one to each of your 10 assistants.
Cons:
However, a major drawback can occur: even if every bundle contains the same quantity of work items, the effort required for each item may be vastly different.
The problem comes down to complexity. While each bundle has the same number of items (say, 100 sales orders), the work required for each item isn't the same. One bundle might contain 100 simple, single-item orders. Another might contain 100 massive, multi-line corporate orders.
The assistants who got the simple bundles are done in minutes. But the others are still slogging through the complex work. Now, you have a bunch of people sitting idle, waiting for the others to finish. You've lost the efficiency you tried to gain.
Process:
To Divide make bundle and assign the task to batch.
- We need a controller class, contract class and service class. Generally prefix with processing
- We need normal controller class, contract class and service class.
Processing Contract class.
internal final class ProcessingContract{
Process Controller class:
Process Service class:
This is class actually creating the bundles as a task (calls business logic service class) and assign to the batch.
Actual business logic service class.
And let me know your thoughts in the comments below.๐๐
Comments
Post a Comment