"Brackets" tasks

Hi, do you have alternatives to implement the following requirement more elegantly?

We want to run through the following loop until a signal (in my example is this a timer) event occurs. The specialty is that if the flow is on one of the tasks B, C or D, these three must always be processed one after the other. After that the loop is broken and the End task is reached.

Do any of you have any idea how to do this more easily with BPMN?

@Miles Attaching interrupting timer boundary event to Activity ‘A’ would be sufficient without event sub process., anyway the event subprocess also will serve the purpose.

@aravindhrs thanks for the comment. Maybe I wasn’t precise enough: While the loop is up, a signal should interrupt this loop. No matter where the flow is within the loop A-D.
The loop should only run through to the gateway at the end if one of the tasks B, C or D is active.

@Miles, then configure a subprocess with activities (A, B, C, D) which are to be part of the loop and attach an interrupting timer boundary event to the subprocess.

@aravindhrs My BPMN diagram above meets the requirements - it works.
The loop is broken when the signal event comes. As long as B, C or D do not yet have a flow, i.e. A has the flow, the loop is interrupted directly. If B, C or D have the flow, all three are processed first and the loop is only interrupted after D.

My question is whether the BPMN can be made even more elegant. But the functionality from the BPMN diagram above is 100% retained.

@Miles If I understood correctly, when signaled and the execution token is still active in B, C, D then B, C, D has to complete the flow and then the loop should be terminated only after the execution.

Then attach a non interrupting timer boundary event to trigger the parallel execution to set flag as cancel=true without interrupting the current flow. So the execution of B, C, D flow will be continued and when the execution arrives at the gateway the condition will be evaluated to true for #cancel==true and it will exit the looping.

When you start the process instance set process variable value as false for looping.

execution.setVariable("cancel", false);

In the script task just set it like below:

execution.setVariable("cancel", true);

Without having script task, the process variable can be set in end event also by adding execution listener and using inline scripts like below:

<bpmn:endEvent id="Cancelled">
     <camunda:executionListener event="start">
       <camunda:script scriptFormat="javascript">execution.setVariable("cancel", true);</camunda:script>