The event-based Gateway allows you to make a decision based on events. Each outgoing sequence flow of the gateway needs to be connected to an intermediate catching event. When process execution reaches an event-based Gateway, the gateway acts like a wait state: execution is suspended. In addition, an event subscription is created for each outgoing sequence flow.

Note that the sequence flows running out of an event-based Gateway are different than ordinary sequence flows. These sequence flows are never actually “executed”. On the contrary, they allow the process engine to determine which events an execution arriving at an event-based Gateway needs to subscribe to. The following restrictions apply:

  • An event-based Gateway must have two or more outgoing sequence flows.
  • An event-based Gateway may only be followed by elements of the type intermediateCatchEvent.(Receive Tasks after an event-based Gateway are not supported by the engine yet.)
  • An intermediateCatchEvent connected to an event-based Gateway must have a single incoming sequence flow.
    The following process is an example of a process with an event-based Gateway. When the execution arrives at the event-based Gateway, process execution is suspended. Additionally, the process instance subscribes to the alert signal event and creates a timer which fires after 10 minutes. This effectively causes the process engine to wait for ten minutes for a signal event. If the signal event occurs within 10 minutes, the timer is canceled and execution continues after the signal. If the signal is not fired, execution continues after the timer and the signal subscription is canceled.

The corresponding xml looks like this:

  1. <definitions>
  2. <signal id="alertSignal" name="alert" />
  3. <process id="catchSignal">
  4. <startEvent id="start" />
  5. <sequenceFlow sourceRef="start" targetRef="gw1" />
  6. <eventBasedGateway id="gw1" />
  7. <sequenceFlow sourceRef="gw1" targetRef="signalEvent" />
  8. <sequenceFlow sourceRef="gw1" targetRef="timerEvent" />
  9. <intermediateCatchEvent id="signalEvent" name="Alert">
  10. <signalEventDefinition signalRef="alertSignal" />
  11. </intermediateCatchEvent>
  12. <intermediateCatchEvent id="timerEvent" name="Alert">
  13. <timerEventDefinition>
  14. <timeDuration>PT10M</timeDuration>
  15. </timerEventDefinition>
  16. </intermediateCatchEvent>
  17. <sequenceFlow sourceRef="timerEvent" targetRef="exGw1" />
  18. <sequenceFlow sourceRef="signalEvent" targetRef="task" />
  19. <userTask id="task" name="Handle alert"/>
  20. <exclusiveGateway id="exGw1" />
  21. <sequenceFlow sourceRef="task" targetRef="exGw1" />
  22. <sequenceFlow sourceRef="exGw1" targetRef="end" />
  23. <endEvent id="end" />
  24. </process>
  25. </definitions>

Camunda Extensions

Attributes
camunda:asyncBefore, camunda:exclusive, camunda:jobPriority
Extension Elements
——-
camunda:failedJobRetryTimeCycle, camunda:executionListener
Constraints
——-
The camunda:exclusive attribute is only evaluated if the attribute camunda:asyncBefore is set to true

Additional Resources

原文: https://docs.camunda.org/manual/7.9/reference/bpmn20/gateways/event-based-gateway/