Hello,
in our application we are handling failed jobs. We can also retry a failed Job by setting the number of retries left to a value >0 via the management service. This works fine through our own interface. But: The restart of a failed job is influencing the behaviour in one of our delegates. The delegate should do some preparation before it executes other stuff. To specify it: Whenever a user has clicked on “retry job”, the delegate should delete something in our database before it continues with the other stuff. If it is not a failed job retry, just a normal execution inside the workflow, it should behave as normal. So i need in our delegate the information like:
if(<this execution is a failed-job retry, caused by a user>){
// prepare something that needs to be done, when it is a job retry
}
// do what you are allways doing
What would be a good approach to do that? I have also written and registered an Incident Handler like this:
public class CustomIncidentHandler extends org.camunda.bpm.engine.impl.incident.DefaultIncidentHandler {
public RequestIncidentHandler(String type) {
super(type);
}
@Override
public void handleIncident(IncidentContext context, String message) {
Incident incident = super.createIncident(context, message);
// just a preparation if we want to add function , for instance -> write a mail to an admin if an incident occurs
}
@Override
public void resolveIncident(IncidentContext context) {
super.resolveIncident(context);
System.out.println(context.getConfiguration() + ": resolveIncident called");
}
@Override
protected void removeIncident(IncidentContext context, boolean incidentResolved) {
super.removeIncident(context,incidentResolved);
System.out.println(context.getConfiguration() + ": remove Incident called!");
}
}
Maybe i could use this to pass some information through the engine, but i don’t know how to access the process engine in this handler class. I would be glad if you have some ideas how to handle this situation.
Thanks a lot and best regards,
Andy