We handle users and contracts in our system, for every user there are multiple contracts …
On every contract change there might be side-effects like re-calculating an aggregated status on the user record based on the new list of contracts that he holds.
Some of the above re calculations might required contracting a 3rd party system and we wanted to have durability and asynchronicity to speed up the update process (it comes in bulk imports).
the bulk import is its own workflow and a single activity inside is to update each users contracts, which in turn will launch a contract-updated workflow for every one.
We have decided to launch a workflow per contract with the ID (contract-updated-123-445-65566)
we missed 2 facts (that are slightly connected):
- if another update comes while a workflow is running we will skip it since a workflow with the same id is already running
- if we have two different contract updating for a single user the will launch 2 separate workflows that will cause a race condition with regards who updates to which status.
Obviously the design is flawed, but i wonder how would you re-desing it.
I know Temporal does not support FIFO queueing of workflows (nor is design to…)
I really would like to avoid adding more components into the overall system like Rabbit, or SQS …
I had some thoughts … i will share them but i would really like your feedback first ! Thanks!