cancel
Showing results for 
Search instead for 
Did you mean: 

How to interrupt and end processinstance?

rusty
Champ in-the-making
Champ in-the-making
Hi,

i'm new to Activiti and Bpmn.

Is it possible to model the possibility to interrupt and end a processinstance at any time of the process? I know how to end it with Java but I want it to be modeled.

Maybe I found a way with Bpmn2.0 but Activiti doesn't support the needed events.
So I tried to model a receiveTask in parallel way to the whole process but this doesn't work either.

Does anyone have an idea?


Thanks,
Rusty
15 REPLIES 15

mhw
Champ in-the-making
Champ in-the-making
Hi,

I would also be interested in that. At the moment I try to reach the following:

Show a Dialog to a user (userTask or javaService). User makes some input. If it ends "normally" the input is returned and its fine. But the user should be enabled to press "cancel" or "esc". Then process should stop returning to parent calling process. How would one model this with activiti?

Rusty, which constructs of BPMN do you mean? Which "needed events" you are talking about?

regards,
Michael

rusty
Champ in-the-making
Champ in-the-making
Hi,

I'm talking about message events.
Maybe it could also work with signal events, but both aren't supported yet.

But I'm not even sure it would work with these events. I've never found an BPMN example, that allows to interrupt and end a process at any time.

Regards,
Rusty

mhw
Champ in-the-making
Champ in-the-making
Hi,

I thought about this issue the whole afternoon. I see no possibility to model this kind of behavior with activity. For our use case it is enough to handle the failing of a sub process with the error event:
<process processType="Private" isExecutable="true" id="EscapeRegionEvent"
  name="Escape region Event Process">

  <startEvent id="theStart" name="StartProcess" />

  <sequenceFlow sourceRef="theStart" targetRef="subprocessThatCouldBeCanceled" />

  <subProcess id="subprocessThatCouldBeCanceled">
   <startEvent id="startSubProcessEvent" />
   <sequenceFlow targetRef="userTaskThatCouldBeCanceled"
    sourceRef="startSubProcessEvent" />
   <userTask id="userTaskThatCouldBeCanceled" name="User task that could be canceled."
    activiti:assignee="kermit" />
   <sequenceFlow targetRef="endSubProcessError" sourceRef="userTaskThatCouldBeCanceled">
    <conditionExpression>
     ${cancelPressed}
    </conditionExpression>
   </sequenceFlow>
   <sequenceFlow targetRef="endSubProcessNormal" sourceRef="userTaskThatCouldBeCanceled">
    <conditionExpression>
     ${!cancelPressed}
    </conditionExpression>
   </sequenceFlow>
   <endEvent id="endSubProcessNormal" />
   <endEvent id="endSubProcessError">
    <errorEventDefinition errorRef="canceled" />
   </endEvent>

  </subProcess>

  <sequenceFlow sourceRef="subprocessThatCouldBeCanceled"
   targetRef="normalEnd" />

  <endEvent id="normalEnd" name="NormalEndProcess">
   <terminateEventDefinition />
  </endEvent>


  <boundaryEvent id="catchError" name="CatchErrorEvent"
   attachedToRef="subprocessThatCouldBeCanceled" cancelActivity="true">

   <errorEventDefinition errorRef="canceled" />

  </boundaryEvent>
 
  <sequenceFlow targetRef="handleEscalation" sourceRef="catchError"></sequenceFlow>

  <userTask id="handleEscalation" name="Handle escalated issue">
   <documentation>Escalation: user task was canceled.
   </documentation>
  </userTask>

  <sequenceFlow sourceRef="handleEscalation" targetRef="escalatedEnd" />

  <endEvent id="escalatedEnd" />

</process>




  runtimeService
    .setVariable(task.getExecutionId(), "cancelPressed", true);

  taskService.complete(task.getId());

  task = taskService.createTaskQuery().processInstanceId(pi.getId())
    .singleResult();

  assertEquals("Handle escalated issue", task.getName());


Just similar to the process in the examples.

Would be nice to hear of some better solution (which could be viewed/edited in the model - without java).

Best regards,
Michael

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
A better solution is to implement the missing events… Feel free to contribute those. The code of activiti is clearly written and fairly easy to understand. 🙂

mhw
Champ in-the-making
Champ in-the-making
Hi Ronald,

yes, you are right. All code I viewed so far is clearly written. I am willing to contribute. I will take these steps here:
http://docs.codehaus.org/pages/viewpage.action?pageId=163872771

Then I will extend the class BpmnParse and add a method like
"parseBoundaryTimerEventDefinition" and "addTimerDeclaration"

Is there a tutorial how to setup a typical activiti developer workspace?

I am not a BPMN-specialist.
@Rusty: Have you a BPMN-example for me?

regards,

Michael

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
Activiti is a typical maven project, nothing specific.

What events are missing btw? Please file jira issues for those after discussing them here

mhw
Champ in-the-making
Champ in-the-making
Ok, I understand the setup. Will try it today evening at home.

We need the "signal boundary event" (not sure how this is formulated in BPMN) for cancellation of a sub process from "outside" (user press the cancel button).

I found the same thing discussed here:
http://forums.activiti.org/en/viewtopic.php?f=10&t=897

Will now try to
mimic a signal event using a wait state (receive task) + signal call from a service task

rusty
Champ in-the-making
Champ in-the-making
Hi,

thanks for your support!
This is the way I would try to model a trigger to interrupt and end a process. But I'm not sure it would work. I'm really new to BPMN.

Regards,
Rusty

[attachment=0]BPMN_Bsp.PNG[/attachment]

rusty
Champ in-the-making
Champ in-the-making
I think this one should work, but I guess it's not the best way.