• 扩大事件是一个引用了被命名的扩大,它们大多数被用在连接子流程和父流程。与错误不同,扩大事件不是临界事件,在抛出的扩大事件的地方会继续执行
img
一、定义一个扩大事件(Defining Escalation):

扩大事件是通过escalationEventDefinition元素定义声明的,escalationRef属性引用了一个扩大(escalation)元素,下面是一个声明了引用了扩大中间抛出事件的流程的摘要 [图片上传中...(image.png-91ca96-1601972205230-0)]

<definitions>
 <escalation id="lateShipment" escalationCode="ORDER-LATE-SHIPMENT" />
 <!-- ... -->
 <process>
   <!-- ... -->
   <intermediateThrowEvent id="throwEscalation" name="late shipment">
     <escalationEventDefinition escalationRef="lateShipment" />
   </intermediateThrowEvent>
   <!-- ... -->
 </process>
</definitions>
二、扩大开始事件(Escalation Start Event):

扩大事件只能用作触发一个子流程,不能发起流程实例

img

带有扩大开始事件的子流程只能被在相同作用域或者子作用域(子流程或者调用的任务)的扩大事件触发。当子流程被一个调用活动触发了扩大事件,那调用活动中定义的输出参数将会传递给子流程 扩大开始事件有两个可选属性,escalationRef和escalationCodeVariable:

<subprocess triggeredByEvent="true">
 <startEvent id="catchEscalation" isInterrupting="false">
   <escalationEventDefinition camunda:escalationCodeVariable="code"/>
 </startEvent>
 <!-- ... -->
</subprocess>

1.如果escalationRef没有提供,或者escalationCode属性引用的escalation没有提供,扩大开始事件子流程会被任何扩大事件触发,不管escalation传过来的是什么escalation code都会触发 ​ 2.如果escalationRef设置了,扩大开始事件子流程只会被定义了escalation code的扩大事件触发 ​ 3.如果escalationCodeVariable设置了,触发了扩大事件的escalation code可以被获取并作为参数

当前的一些限制: 1.在同一个作用域下,扩大开始事件的escalation code必须唯一 2.如果扩大开始事件没有带有引用了一个扩大的escalationRef或者escalationCode属性,那么它就不支持另一个带有扩大开始事件的子流程

三、扩大边界事件(Escalation Boundary Event):

活动边界上的中间捕获扩大事件,或者简称扩大边界事件。用作捕获一个在作用域内的活动抛出的被定义的扩大 ​ 扩大边界事件只能依附于一个被包含的子流程,或者一个活动调用。扩大只能被扩大中间抛出事件或者扩大结束事件抛出,当扩大边界事件被一个活动调用触发,那么这个活动定义的输出参数将会传递给扩大边界事件作用域 ​ 扩大边界事件有两个可选属性,escalationRef和escalationCodeVariable,跟边界开始事件类似:

<boundaryEvent id="catchEscalation" name="late shipment" attachedToRef="productProcurement">
 <escalationEventDefinition escalationRef="lateShipment" cancelActivity="false" />
</boundaryEvent>

当前的限制: 1.在同一个作用域下,扩大开始事件的escalation code必须唯一 2.如果扩大开始事件没有带有引用了一个扩大的escalationRef或者escalationCode属性,那么它就不支持其他带有扩大开始事件的子流程

四、扩大中间抛出事件(Escalation Intermediate Throw Event):

当流程执行到扩大中间抛出事件时,一个被命名的扩大被抛出,这个扩大可以被扩大边界事件捕获,或者触发一个拥有相同escalation code或者没有有escalation code的子流程。 ​ 跟错误事件类似,扩大事件将会向上层作用域扩散,直到它被捕获住。如果没有边界事件或者子流程捕获到这个事件,这个执行将会像普通流程一样。如果扩大通过调用活动传播到上层作用域,那么调用活动中定义的输出参数将会传递到上层作用域。

<intermediateThrowEvent id="throwEscalation" name="order shipped">
 <escalationEventDefinition escalationRef="orderShipped" />
</intermediateThrowEvent>
五、扩大结束事件(Escalation End Event):

当流程到达扩大结束事件时,当前路径的执行结束,并且会抛出一个被命名的扩大。扩大结束事件与扩大中间抛出事件的行为类似

<endEvent id="throwEscalation" name="late shipment">
 <escalationEventDefinition escalationRef="lateShipment" />
</endEvent>

世间山河广,祝你得偿所愿!