I’m kind of confused with TaskListener and ExecutionListener. I use them with spring-native event-bridge.
A few questions
I have a TaskListener like this:
@EventListener(condition = "#event.eventName=='create'")
public void onTaskCreatedEvent(TaskEvent event) {
// handle immutable task event
log.info("handle task event {} for task id {}", event.getEventName(), event.getId());
}
@EventListener(condition = "#event.eventName=='complete'")
public void onTaskCompletedEvent(TaskEvent event) {
// handle immutable task event
log.info("handle task event {} for task id {}", event.getEventName(), event.getId());
}
Does this listener is triggered only on user task type ? If yes, how to do the same thing with for instance all service task type without impact in bpmn files ?
@keuss, TaskListener is applicable only for UserTask types and ExecutionListener is common for all types like, Start/End events, boundary events, usertasks, service tasks, call activity, embedded sub process, sequence flows, etc.
public class ExampleExecutionListenerOne implements ExecutionListener {
public void notify(DelegateExecution execution) throws Exception {
// can access instances of process engine services and delegateExecution
}
}
public class ExampleExecutionListenerOne implements ExecutionListener {
public void notify(DelegateExecution execution) throws Exception {
// can access instances of process engine services and delegateExecution
execution.getCurrentActivityId(); //activity
execution.getCurrentActivityName(); //activity
execution.getProcessDefinitionId(); //process
execution.getEventName(); // type of event
//type of activity including transitions
String activityType = execution.getBpmnModelElementInstance()
.getElementType().getTypeName();
}
}