CMMN sentry evaluation

Hello,

I come to you with an issue about sentries i 've been working on for days.
Let’s say i have a CMMN process with 3 tasks :

Each have a link to a BPMN subprocess and has a repetition option based on an impact variable (A-impacted, B-impacted and C-impacted) defined as an on-part variable in their sentries (with an update event). Tasks A and B are independants and may runs at the same time.

The C task has more complex activation conditions : it needs that tasks A and B are terminated :

<cmmn:sentry id="Sentry_0e0dnpl">
	<cmmn:extensionElements>
		<camunda:variableOnPart variableName="C-Impacted">
			<camunda:variableEvent>update</camunda:variableEvent>
		</camunda:variableOnPart>
	</cmmn:extensionElements>
	<cmmn:ifPart id="IfPart_11beqdb">
		<cmmn:condition id="Expression_16zdmrc">
			<![CDATA[${A-Terminated && B-Terminated}]]>
		</cmmn:condition>
	</cmmn:ifPart>
</cmmn:sentry>

This configuration may seems a bit complex but it corresponds to my use case :

  • at the start of the process, tasks A and B are waiting to be terminated
  • when they are both terminated, task C is launched
  • an external event may asks for the repetition of one of the task by setting the corresponfing impacted variable (supposing that repetition may occurs only when the task is already executed at least once)
  • if task A or B are asked to be repeated, task C must be launched after execution is completed
  • if task C is asked for repetition, only task C must be launched

In order to set the differents needed variables, i have defined listeners which execute at the end of tasks :

  • at the end of task A : A-terminated and C-impacted are set to true
  • at the end of task B : B-terminated and C-impacted are set to true

My problem is linked to the fact that each time a variable is set, the sentries conditions are evaluated. Supposing that the task A finished first, then task B :

  • in the A task end listener, A-terminated and C-impacted are set to true. In both case, task C sentry conditions are not verified
  • then in the B task end listener, B-terminated is set to true (at this moment i notice task C is activated) and C-impacted is set to true (at this moment task C is activated again) : as a result task C is activated twice

I suppose this situation is linked to this part of documentation :

The engine evaluates IfParts at every lifecycle transition of a plan item contained in the sentry’s stage. That means, if an IfPart is not satisfied immediately when all OnParts have occurred, the sentry may still occur at any later lifecycle transition.

I understand that if a sentry is combined with on-part and if-part conditions, if the on-part is validated but not the if-part, engine will suspend the sentry activation until the if-part is validated, which may result in a double activation like in my case.

After such explanations, my questions are now :

  • is my problems really linked to the facts i supposed ?
  • if yes, is that really normal ? (not a bug ?)
  • is there an alternative configuration i’m not aware of that could match my use case ?

Thank you for reading me, any piece of advice will be fully appreciated :slight_smile:
Vincent

2 Likes