Hi,
I’m attempting to trigger an event when an incident happens and resolves and when a user task is created and completed.
To achieve this I have created a custom incident handler
@Component
public class UpdateStatusIncidentHandler extends DefaultIncidentHandler {
public UpdateStatusIncidentHandler() {
super("failedJob");
}
public Incident handleIncident(IncidentContext context, String message) {
// custom code
return super.handleIncident(context, message);
}
public void resolveIncident(IncidentContext context) {
// custom code
super.resolveIncident(context);
}
}
and a event listener for the user task
@Component
public class UserTaskListener {
@EventListener
public void onTaskEvent(DelegateTask taskDelegate) {
if (isUserTask(taskDelegate.getExecution())) {
if ("create".equals(taskDelegate.getEventName())) {
// custom code
} else if ("complete".equals(taskDelegate.getEventName())) {
// custom code
}
}
}
}
The issue I am having is that on creation of the user task the resolveIncident method is also triggered. Is it possible to filter out those? or is there a better solution to what I am trying to achieve? Essentially I would like to be able to record a failed state when an incident / user task occurs and then reset this state after the incident / user task has been resolved.
Thanks,
matt