cancel
Showing results for 
Search instead for 
Did you mean: 

Intermediate Catching/Throwing Events

egore911
Champ in-the-making
Champ in-the-making
Right now I'm trying to model the possibility to terminate a process after a given amount of time has passed (i.e. "if the process did not terminate normally withing x hours -> terminate it"). So I've been looking at the Signavio Modeler which now allows to select the subset of BPMN that is supported by Activiti (as far as I understand). This is a great feature. But since intermediate events are missing in that list I'm wondering how I could react to a timer. Is that possible programmatically? Or is it just missing in the editor and supported anyway? Or is this functionality missing and will follow in 5.1 (or later).

Same goes for the "Terminate End Event". Right now it seems to be missing in the editor but is it supported? I think implementing could be rather easy. From my understanding of the code it might work like the following:


  private void terminateExecution(ExecutionImpl execution) {
    for (ExecutionImpl e : execution.getExecutions()) {
      terminateExecution(e);
    }
    terminateExecution(execution.getSubProcessInstance());
    execution.end();
  }

  ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().singleResult();
  ExecutionEntity executionEntity = (ExecutionEntity) processInstance;
  for (ExecutionImpl e : executionEntity.getExecutions()) {
    terminateExecution(e);
  }

This way all executions belonging to the process instance will get terminated (which is what I need the terminate event to do). I'm currently thinking about putting this code into a user task but ending the process the user task belongs to does not sound to be right 🙂 Is there another way to do this properly?
5 REPLIES 5

jbarrez
Star Contributor
Star Contributor
- Timers are definitely supported by the engine. I would need to double check if the Activiti perspective doesnt have it. However, you can switch to the Complete perspective and use the timer event.

The terminate end event is not yet implemented. However, it is definitely a valid request (and should not be that hard to implement indeed), I added a Jira for it: http://jira.codehaus.org/browse/ACT-432

To implement it yourself currrently, just use a service task with custom implementation.

egore911
Champ in-the-making
Champ in-the-making
I found the timer event. I guess I must have been blind. On the other hand now I need a intermediate escalation event. Am I blind again? I double checked and it is not available in the Activiti tileset of the modeler. And I looked at the sources and could also not find any trace of it.

Oops, I'm having bad timing 🙂 I just tried to implement the terminating end event myself and opened an issue (which I resolved a duplicate of yours). You can find my code at ACT-432

lsmall
Champ in-the-making
Champ in-the-making
We could use support for a terminate end event because our current proprietary workflow implementation behavior supports it.

Couldn't the terminate node simply cause the instance to be deleted with a delete reason of "process termination" or something similar? Not sure how that would work in a subprocess though. We currently terminate the subprocess without affecting peer subprocesses or the parent process.

We will take a look at the open Jira issue (ACT-432) and possibly provide an implementation via pull request if we work out the logistics unless you have and example or an implementation-in-progress we can leverage.

lsmall
Champ in-the-making
Champ in-the-making
I see a terminate node available in the Designer palette and a test for termination at the process and subprocess levels:

/activiti-engine/src/test/java/org/activiti/engine/test/bpmn/event/end/TerminateEndEventTest.java

Also, there are behavior classes in the engine:

/activiti-engine/src/main/java/org/activiti/engine/impl/bpmn/behavior/TerminateEndEventActivityBehavior.java

Are terminate nodes supported or not?

I see that terminate nodes are changed to none end events when importing and deploying in Modeler. Is that the only issue?

lsmall
Champ in-the-making
Champ in-the-making
Also not documented in the User Guide yet.