Class WorkflowReentrancyGuard

java.lang.Object
com.axelor.workflow.exec.WorkflowReentrancyGuard

@Singleton public class WorkflowReentrancyGuard extends Object
Guards against runaway cascades: a run may save records whose events start more runs. A context opened around the dispatch spans the whole chain, rejecting runs past a depth limit and any run whose key (tenant|model|jsonModel|name|recordId|cause) is already active in it. Keys clear when the outermost context closes.
  • Constructor Details

    • WorkflowReentrancyGuard

      public WorkflowReentrancyGuard()
  • Method Details

    • enter

      public void enter()
      Open (or descend into) a cascade context; pair with exit() in a finally block.
    • exit

      public void exit()
      Leave a cascade level; clears all keys once the top-level context unwinds.
    • tryAcquire

      public boolean tryAcquire(String key)
      Reserve a run's key; false past the depth limit or when the key is already active. Always true outside a guard context.
    • key

      public String key(String tenant, String model, String jsonModel, String name, Long recordId, TriggerKind cause)
      Build the execution key for a run; pass to tryAcquire(String).
    • maxDepth

      public int maxDepth()
      The configured cascade depth limit.