How to Safely Update a Parent Object After All GLTransaction Batches Complete via Task Queue?
0
Hi all, In my Mendix application, I am processing a large number of GLTransaction records. These are grouped under a parent object called GLBatch. I create GLTransaction records in batches, and each batch is added to a Task Queue for parallel processing. Each batch of GLTransactions is queued and processed via Task Queue. My goal is to update the GLBatch object only once, after all the GLTransaction records under it are fully processed. However, I'm facing issues with timing and synchronization—especially when multiple tasks finish around the same time—leading to the GLBatch sometimes not being updated correctly. To handle this, I’ve implemented the following logic: When all child batches are added to the task queue, I queue one final task whose job is to update the GLBatch. This final task checks if all GLTransaction records are processed (e.g., by comparing expected and actual count). If not all are processed yet, it waits (sleeps) for 20 seconds, rechecks, and repeats this loop. It retries for up to 5 minutes, and if still incomplete, it exits without updating. This mostly works, but I'm concerned about a case where the last transaction batch takes more than 5 minutes to complete—then the GLBatch won’t be updated correctly. My questions: Is there a better Mendix-native way to handle this kind of post-processing synchronization? How can I avoid race conditions or timing issues when checking and updating the GLBatch? Any suggestions or best practices would be greatly appreciated. Thanks in advance!