Custom IncidentHandler issues

Currently running:

  • Camunda 7.7.2-ee
  • Tomcat 8.0.43, shared process engine

I have a custom ProcessEnginePlugin, one of the things it does is to register a custom IncidentHandler to send notifications on incident creation. However, I’m currently seeing two issues

  • The handleIncident method of the custom handler is not being invoked on external task incident when using a shared engine and tomcat. It appears to be invoked using an embedded engine.
  • The resolveIncident method seems to be invoked even though nothing has been “resolve” e.g. when the incident is created. It is also invoked when I take a “resolve” type action such as incrementing retries. I am expecting that when an incident is first created only handleIncident is invoked, perhaps I am misunderstanding?

I’ve looked at some similar issues such as #3747 , though I believe this is not the issue I am seeing. Perhaps I’m missing something obvious.

The relevant bits of code:

Custom ProcessEnginePlugin

public class CustomCamundaPlugin extends AbstractProcessEnginePlugin {
    private static final Logger logger = LoggerFactory.getLogger(CustomCamundaPlugin.class);

    public void preInit(ProcessEngineConfigurationImpl processEngineConfiguration) {
        // IncidentHandlers
        List<IncidentHandler> incidentHandlers = processEngineConfiguration.getCustomIncidentHandlers();
        if (incidentHandlers==null) {
            incidentHandlers=new ArrayList<>();

        IncidentHandler extHandler = new CustomIncidentHandler(
                new DefaultIncidentHandler(Incident.EXTERNAL_TASK_HANDLER_TYPE),

        IncidentHandler jobHandler = new CustomIncidentHandler(
                new DefaultIncidentHandler(Incident.FAILED_JOB_HANDLER_TYPE),



package com.ajmanlove.camunda.plugin;

import com.ajmanlove.camunda.plugin.messages.Message;
import org.camunda.bpm.engine.RuntimeService;
import org.camunda.bpm.engine.impl.incident.IncidentContext;
import org.camunda.bpm.engine.impl.incident.IncidentHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class CustomIncidentHandler implements IncidentHandler {

    private static final Logger logger = LoggerFactory.getLogger(CustomIncidentHandler.class);

    private final String type;
    private final IncidentHandler defaultHandler;
    private final RuntimeService runtimeService;

    public CustomIncidentHandler(IncidentHandler defaultHandler, String type, RuntimeService runtimeService) {

    public String getIncidentHandlerType() {
        return type;

    public void handleIncident(IncidentContext context, String message) {"Handling incident, {}", message);
        // Do notification stuff...


    public void resolveIncident(IncidentContext context) {"Resolving incident");
        // Do notification stuff...

    public void deleteIncident(IncidentContext context) {"Deleting incident");
        // Do notification stuff...


I have unit and integrations test showing these here :

Unit: com.ajmanlove.test.IncidentHandlerTest
Integration : com.ajmanlove.test.IncidentHandlerIT

Thanks in advance!

Discussed this with Camunda support and posting back here for community knowledge.

The first issue with handleIncident is the same as #5458. Underlying issue being that the custom plugin was not enabled in the process engine completing the external task.

The second issue with resolveIncident is expected behavior. Implementations of IncidentHandler can expect resolveIncident to occur at any point where an incident may need to be resolved. In this case, this at the post execution of a job, where an incident may or may not have been created.

For this use case, which is essentially notifications when incidents are created and resolved, this can still be done by mimicking the behavior of org.camunda.bpm.engine.impl.incident.DefaultIncididentHandler and querying for incidents which may exist, or by implementing a Historical Event Handler (CompositeHistoryEventHandler) which is probably more appropriate.

1 Like