@Jonathan_H You can refer this post.
Additionally, in the respective methods you can check for the type of event like below:
@Slf4j
@Component
public class CamundaEventListeners {
@EventListener
public void onTaskEvent(DelegateTask taskDelegate) {
String eventType = taskDelegate.getEventName();
log.info("onTaskEvent##DelegateTask##Event {} triggered", eventType);
if (TaskState.STATE_DELETED.name().equals(taskDelegate.getEventName())) {
// implementation code goes here
}
}
@EventListener
public void onTaskEvent(TaskEvent taskEvent) {
String eventType = taskEvent.getEventName();
log.info("onTaskEvent##TaskEvent##Event {} triggered", eventType);
if (TaskState.STATE_DELETED.name().equals(taskEvent.getEventName())) {
// implementation code goes here
}
}
@EventListener
public void onExecutionEvent(DelegateExecution executionDelegate) {
String eventType = executionDelegate.getEventName();
log.info("onExecutionEvent##DelegateExecution##Event {} triggered", eventType);
}
@EventListener
public void onExecutionEvent(ExecutionEvent executionEvent) {
String eventType = executionEvent.getEventName();
log.info("onExecutionEvent##ExecutionEvent##Event {} triggered", eventType);
}
@EventListener
public void onHistoryEvent(HistoryEvent historyEvent) {
String eventType = historyEvent.getEventType();
log.info("onHistoryEvent##HistoryEvent##Event {} triggered. Is process Instance Resource deleted?: {}", eventType,
historyEvent.isEventOfType(HistoryEventTypes.PROCESS_INSTANCE_END));
}
}
Here’s some sample logs:
[http-nio-8086-exec-7] INFO c.b.c.e.CamundaEventListeners - onHistoryEvent##HistoryEvent##Event complete triggered. Is process Instance Resource?: false
[http-nio-8086-exec-7] INFO c.b.c.e.CamundaEventListeners - onHistoryEvent##HistoryEvent##Event end triggered. Is process Instance Resource?: true
[http-nio-8086-exec-7] INFO c.b.c.e.CamundaEventListeners - onHistoryEvent##HistoryEvent##Event end triggered. Is process Instance Resource?: true
[http-nio-8086-exec-7] INFO c.b.c.e.CamundaEventListeners - onHistoryEvent##HistoryEvent##Event null triggered. Is process Instance Resource?: false