cancel
Showing results for 
Search instead for 
Did you mean: 

How to stop timer boundary event?

neo1
Champ in-the-making
Champ in-the-making
Hello,
  We have a requirement to send Escalation notification if sub-process workflow doesn't response by certain time duration. Here is implementation.
  1) Timer boundary event to attache to main workflow, and the 'cancelActivity="false"'.
  2) A Java service task which send escalation notification email to supervisor, which is connect to Timer boundary event
  3) Sub-process workflow connects to a Parallel gateway
  4) The 2) java service task connects to the Parallel gateway as well

  Condition:
  1) The sub-process workflow completes before Timer duration

  Problem:
  1) Workflow stop at the Parallel gateway to wait for Timer boundary event branch to reach the gateway

  Expected:
  1) Timer boundary event should be skip because attached sub-process completes

  We cannot set the 'cancelActivity="true"' because our requirement need sub-process still can continue. We also tried to delete the timer job, but it doesn't work.

  How do we cancel/stop timer boundary event when attached sub-process complete?

thanks
6 REPLIES 6

vasile_dirla
Star Contributor
Star Contributor
Hi,
could you please upload here a unit test or at least a bpmn20.xml file for a better understanding of the problem?

neo1
Champ in-the-making
Champ in-the-making
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions" targetNamespace="http://activiti.org/bpmn20"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:activiti="http://activiti.org/bpmn">


<process id="timerProcess" name="The Testing event Process">
  <startEvent id="theStart" />
  <sequenceFlow id="flow01" sourceRef="theStart" targetRef="subProcess" />
  <boundaryEvent id="escalationUnresolvedTimer"
   cancelActivity="false" attachedToRef="subProcess">
   <timerEventDefinition>
    <timeDuration>PT15S</timeDuration>
   </timerEventDefinition>
  </boundaryEvent>

  <subProcess id="subProcess">
   <startEvent id="theSubStart" />
   <sequenceFlow id="flow02" sourceRef="theSubStart"
    targetRef="StartSubProcessScript" />
   <scriptTask id="StartSubProcessScript" scriptFormat="JavaScript">
    <script>
     print("Start sub process")
    </script>
   </scriptTask>
   <receiveTask id="waitState" name="wait" />
   <sequenceFlow id="flow03" sourceRef="StartSubProcessScript"
    targetRef="waitState" />
   <scriptTask id="EndSubProcessScript" scriptFormat="JavaScript">
    <script>
     print("End sub process")
    </script>
   </scriptTask>
   <sequenceFlow id="flow04" sourceRef="waitState"
    targetRef="EndSubProcessScript" />
   <endEvent id="theSubEnd" />
   <sequenceFlow id="flow05" sourceRef="EndSubProcessScript"
    targetRef="theSubEnd" />
  </subProcess>
  <parallelGateway id="parallelGateway" />

  <scriptTask id="timerScript" scriptFormat="JavaScript">
   <script>
    print("Reach escalation unresolved timer")
   </script>
  </scriptTask>
  <sequenceFlow id="flow06" sourceRef="escalationUnresolvedTimer"
   targetRef="timerScript" />
  <sequenceFlow id="flow07" sourceRef="timerScript"
   targetRef="parallelGateway" />

  <sequenceFlow id="flow08" sourceRef="subProcess"
   targetRef="parallelGateway" />

  <scriptTask id="successfulScript" scriptFormat="JavaScript">
   <script>
    print("Successful complete workflow")
   </script>
  </scriptTask>

  <sequenceFlow id="flow09" sourceRef="parallelGateway"
   targetRef="successfulScript" />

  <sequenceFlow id="flow10" sourceRef="successfulScript"
   targetRef="theEnd" />
  <endEvent id="theEnd" />
</process>
</definitions>

there is a BPMN definition xml example I test it. Here is four use cases.
1) Sub-process is complete before timer reaches duration: we use REST API send signal to 'receiveTask'
    Console print results: Start sub process -> End sub process
    Conclusion: Parallel gateway is waiting for execution token from Timer boundary branch, but activity will be hang for ever, because the Sub-process already finished before timer duration, the timer job had been canceled.
    Expected result: Once the Sub-process is complete, the Timer boundary event should be canceled, and workflow should be successfully complete.

2) Timer is triggered before the Sub-process completes: we don't send signal to 'receiveTask'
    Console print results: Start sub process -> Reach escalation unresolved timer
    Conclusion: Parallel gateway is waiting for execution token from Sub-process branch, but activity will be hang until system send signal to 'receiveTask' to complete the Sub-process
    Expected result: this use case is correct because we set cancelActivity="false", system has to wait for send signal to 'receiveTask'

3) Timer is triggered before the Sub-process completes, then we send signal to 'receiveTask'
    Console print results: Start sub process -> Reach escalation unresolved timer -> End sub process -> Successful complete workflow
    Conclusion: workflow is successfully complete because both branch(Sub-process and Timer boundary) reach the parallel gateway
    Expected result: this use case is correct because we set cancelActivity="false", system has to wait for send signal to 'receiveTask' to complete the workflow

4) Sub-process completes before the timer is triggered, then wait for timer duration is done
    Console print results: Start sub process ->  End sub process -> Reach escalation unresolved timer -> Successful complete workflow
    Conclusion: workflow is successfully complete because both branch(Sub-process and Timer boundary) reach the parallel gateway
    Expected result: Once the Sub-process is complete, the Timer boundary event should be canceled, and workflow should be successfully complete, system should not wait for Timer boundary event done.

   Or is there any other existing feature we can use to accomplish our requirement?

neo1
Champ in-the-making
Champ in-the-making
Found out the BPMN2 xml format I pasted previous comment is not correct, and upload the workflow definition file again.

neo1
Champ in-the-making
Champ in-the-making
Finally, I figured out by myself. I removed the parallel gateway, and timer connected to a separate end event. The new thing I learned is the timer end event doesn't end the main workflow, therefore, the main workflow is still in process.

jbarrez
Star Contributor
Star Contributor
A timer end event doesn't exist. There is only a timer start event.

neo1
Champ in-the-making
Champ in-the-making
Yes, you are right. Actually, we have a Escalation notification task between Timer boundary event and end event, that is why we add a separate end event for Timer boundary branch.

Btw, I am kind of misleading by Activiti User guide, the Timer Boundary Event section shows a  BPMN diagram of Escalation example, there is a parallel gateway, however, I think it is not quite correct for our requirement.