Add Rule Machine actions for multiple thread locking / synchronization / gating

Hello...There can be certain cases where multiple threads executing the same Rule Machine rule asynchronously can be a problem for the logic in the rule. This is especially the case for rule actions that schedule Repeat loops. This can result in multiple Repeat jobs being scheduled and running in parallel.

The ask is for a way to influence gates and locking of multiple threads to wait on executing the same block of actions in parallel. This is similar to "synchronization" or "monitors" in the Java language. The approach chosen should not cause other parallel executions to be abandoned or skipped. The loss of other events processing could be detrimental to needed logic. The approach should just block the other threads executions until the lock is released and then they continue.

Thank You

Sounds like you have a use case that needs to be written as a Groovy app.


It is easy to prevent a "re-entrant" rule: use a required expression of Private Boolean True, then set Private Boolean false as your first action and true as your last.

This doesn't help with your stated case of wanting to queue (re-)execution of the entire actions sections. However, I'm curious what real-world use case you have for that or if there's another approach that may be better. (Repeats are at the very least seconds long and often minutes and can be hours, so if your trigger events are happening faster than that, you're probably going to have a long, potentially meaningless, queue by the time the whole thing is done...)

1 Like