How to close a Failed Job Type Incident Manually?

I try to close a Failed Job Type Incident Manually and I use the codes below to skip the activity and the process manage to skip the failed task and proceed to complete.

runtimeService.createProcessInstanceModification(processInstanceId)
                .startAfterActivity(activityId)
                .execute();

However, I can see the incident still hangs in the Cockpit even the process completed.

So, How can we close the incident after we skip it?

I also followed the question below. but none of this works.

  1. Cannot resolve an incident of type failedExternalTask - Camunda Platform 7 Topics / Camunda Platform 7 Process Engine - Camunda Platform Forum

  2. Resolve Incident Manually - Camunda Platform 7 Topics / Camunda Platform 7 Process Engine - Camunda Platform Forum

  3. How to delete Camunda Incident - Camunda Platform 7 Topics / Cockpit / Tasklist / Admin & Web C7 - Camunda Platform Forum

  4. Resolving incidents after execution - Camunda Platform 7 Topics / Camunda Platform 7 Process Engine - Camunda Platform Forum

I finally find a solution from Cannot resolve an incident of type failedExternalTask - #2 by dylan.hamilton

In my case, my failed job is a service task which call a subprocess.

The solution is below:

ActivityInstance activityInstance = runtimeService.getActivityInstance(processInstanceId);

// get the Transition instance of the subprocess
String childTransitionInstanceId = activityInstance.getChildTransitionInstances()[0].getId();

// skip the task
runtimeService.createProcessInstanceModification(processInstanceId)
                .startAfterActivity(activityId)
                .cancelTransitionInstance(childTransitionInstanceId) // << we need to cancel TransitionInstance here
                .execute(false, false);

Explanation:

From the Process Instance Modification | docs.camunda.org

Compared to activity instances, transition instances do not represent active activities but activities that are about to be entered or about to be left. This is the case when jobs for asynchronous continuations exist but have not been executed yet. For an activity instance, child transition instances can be retrieved with the method getChildTransitionInstances and the API for transition instances is similar to that for activity instances.

Hence, the reason is the activity in the subprocess is not active anymore and it is move the Transition state , so it is a Transition Instance instead of a activity instance. Therefore, we need to cancel the related Transition Instance. After we cancel the transition state, the related incident would be resolved as well.

Edit: The reason we use this approach because we cannot resolve failed job using the API RuntimeService#resolveIncident from the doc Incidents | docs.camunda.org

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.