I have defined a custom incident at Camunda as follows:
var IncidentEntity = Java.type('org.camunda.bpm.engine.impl.persistence.entity.IncidentEntity');
var IncidentContext = Java.type('org.camunda.bpm.engine.impl.incident.IncidentContext');
var context = new IncidentContext();
var newIncident = IncidentEntity.createAndInsertIncident("incidentType", context, "This is an incident.");
I want to add custom actions (such as retry) for specific custom incidents, is it possible? How can I do it?
Hello @deniz ,
this depends on what you are actually doing.
Looking at your Java class names, you are working with Platform 7.
Now, Platform 7 offers 2 ways of handling service tasks (that could possibly cause incidents):
Internal: Java Delegates or expressions that handle your service task. If they throw an exception, the retry behaviour is controlled in the diagram. If you want a special behaviour depending on the incident, you will have to modify engine internals (something like FailedJobHandler or similar).
External: Code running in another environment that handles your service task. Here, it is a bit easier. The implementation needs to invoke a method to return the failed state of a task. There, you can specify how often a task should be retried and how long it will not be retried.
I hope this helps.
Hello @jonathan.lukas ,
Thank you for your fast and detailed reply. Unfortunately your suggestions don’t exactly match my needs. In order to call Java APIs we use inline script tasks with the following method.
Ways of handling tasks you have mentioned don’t appear on script tasks.
As you know when an error occurs you can increase the number of retries on Camunda Cockpit. I want to be able to add custom actions like this when an incident occurs at a script task. When I create a custom incident it looks as follows at Camunda Cockpit but Action field is empty.
Any further help would be appreciated.
Hello @deniz ,
the incident handling mechanism of the engine is meant to handle all kinds of thrown exceptions.
I would assume that you could throw something like a
RuntimeException from inside your script. The retry behaviour can be configured inside the process model.
I hope this helps