ContinueProcessOperation run() called twice when triggerable

Hello,

using Flowable v6.4.2 in one Tomcat server, we’ve noticed that when selecting a TaskActivityBehavior is marked as triggerable the method run() under ContinueProcessOperation class is called twice, one for the sequence flow and another one for the FlowNode. In our project, we are extending TaskActivityBehavior and overriding both trigger and execute methods.

Sample class:

public abstract class AbstractTaskActivityBehavior extends TaskActivityBehavior {

public abstract void behaviorExecute(DelegateExecution execution) throws Exception;

@Override
public void execute(DelegateExecution execution) {
try {

	//Inner app logic
     behaviorExecute(execution);

  } catch (Exception e) {
   
     log.error(e.getMessage(), e);
   
  } finally {
     FlowableLoggerUtils.logFlowableExecutionInfoMessage(log,

execution, finalMessage + getDisplayName());
}
}@Override
public void trigger(DelegateExecution execution, String signalName, Object signalData) {
//Logic for finishing this task
log.info("Doing leave of task " + this.getClass().getSimpleName());
leave(execution);

}

}

However, if we uncheck trigger check box in the workflow diagram, the execute method in ServiceTaskJavaDelegateActivityBehavior is called once.*

Please advise,

Regards,
Jorge

That is correct, depending on the process definition structure it could be it passes there twice.

Triggerable has a very specific meaning: if you mark it as triggerable, the service task will act as a wait state in a way that doesn’t lead to race conditions (see https://flowable.org/docs/userguide/index.html#serviceTaskTriggerable). However, note that this ‘triggerable’ is not the same as the ‘trigger’ method. The trigger method is used when a step has something that externally triggers it and continues after that (like a user task completion).

Not sure what you’re looking for exactly? The fact whether or not to implement the trigger() method depends on whether you’re task is a wait state behavior (like the user task) or a ‘fire-and-continue’ (like calling an HTTP service).