How to ResolveIncident

I saw the tutorial from here Zeebe | Camunda Cloud Docs I don’t konw where to get param(key)

client.newResolveIncidentCommand(incident.getKey())
.send()
.join();

once there hava a error,how to retry use command

Hi,

I tried to find incident ID under handle job response, but there is not matching ID for incident record.

For testing I’m using simple setup with Zeebe broker, Elasticsearch, Kibana and Operate.

Under operate when incident triggers you can find data:

{
  "activityInstanceId": "2251799813685880",
  "incidentErrorType": "JOB_NO_RETRIES",
  "incidentErrorMessage": "Missing parameter",
  "jobId": "2251799813685881",
  "startDate": "2020-11-12 12:25:13",
  "endDate": "--"
}

But job ID not related with incident record. Also, you can get same data during hanging job process.

Accordingly, to example you can update data:

client.newSetVariablesCommand(2251799813685880)
    .variables(NEW_PAYLOAD)
    .send()
    .join();

client.newUpdateRetriesCommand(2251799813685881)
    .retries(3)
    .send()
.join();

http://elasticsearch:9200/zeebe-record-incident/_search

Incident key found under Elasticsearch:

{
  "_index": "zeebe-record_incident_0.25.0_2020-11-12",
  "_type": "_doc",
  "_id": "1-1368",
  "_score": 1.0,
  "_routing": "1",
  "_source": {
    "partitionId": 1,
    "value": {
      "errorMessage": "Missing parameter",
      "bpmnProcessId": "bpmnProcess",
      "workflowKey": 2251799813685249,
      "elementId": "process1",
      "elementInstanceKey": 2251799813685880,
      "workflowInstanceKey": 2251799813685870,
      "errorType": "JOB_NO_RETRIES",
      "jobKey": 2251799813685881,
      "variableScopeKey": 2251799813685880
    },
    "position": 1368,
    "key": 2251799813685888,
    "timestamp": 1605176713725,
    "valueType": "INCIDENT",
    "recordType": "EVENT",
    "intent": "CREATED",
    "rejectionType": "NULL_VAL",
    "rejectionReason": "",
    "brokerVersion": "0.25.0",
    "sourceRecordPosition": 1367
  }
}
client.newResolveIncidentCommand(2251799813685888)
    .send()
    .join();   

You can write your custom exporter to get incident records from brokers.

My answer is not a complete solution.

1 Like

An incident is raised by the engine, either:

(a) in response to some internal processing error (like missing required variables in a FEEL expression), or
(b) in response to a FailJob command when the retries is set to 0.

In the case of (a), there is no surface area to get an incident key, because it is “inside the black box”.

In the case of (b), it might be possible to implement returning the incidentKey when an incident is created in the FailJobResponse.

Right now that doesn’t happen, but feel free to open an issue to request it, if this is what you want.

That still wouldn’t solve the case of (a), though.

The only way to reliably get incidentKeys from the system is via an exporter. This is an example of an exporter that acts on incident records only.

Josh