I have a service that distributes tasks to operators. Inside a method I distribute many tasks in time inside a loop. I want to flush the task, the operator, and a DistributionLog. If I just had one domain to save I think I could do something like
Operator.withTransaction{ //...some code }
but I have at least 3 domains to save and to make it even worse, two of them have dependency on each other. The operator have a list of tasks.
I can't wait all the distribution to finish before an operator can get his tasks, so I have to force it to flush. To make it even harder, it's all inside a multitenantService.doWithTenant() (multitenant plugin)