Get the Information of an Incident Message from ProcessEngine


The Message which is given in the IncidentHandler.handleIncident(IncidentContext context, String message) Method contains, depending on where an Incident happens, several Information about what happens.

I don’t want to make String operations with regex matching to get these information, cause the Message-pattern/template is very different for each Incident-Cause.

What do i have to do, to get the values which are within such a Message.
An Incident-Message which is given when an Incident happens within a CompensationServiceTask contains the information i’m looking for.

E. g.:

Error while handling compensation event EventSubscriptionEntity[id=8093b168-521e-11e9-af31-0242dc4520e1, eventType=compensate, eventName=null, executionId=8082252d-521e-11e9-af31-0242dc4520e1, processInstanceId=8082252d-521e-11e9-af31-0242dc4520e1, activityId=Task_0lrgnhh, tenantId=null, configuration=ad5f48ae-521e-11e9-af31-0242dc4520e1, revision=1, created=Fri Mar 29 13:30:57 CET 2019]

In such a Case, the activityId in the Message is not the same as the activityId from the IncidentContext.
The IncidentContext.getActivityId() Method returns the activityId of the ActivityToken and the IncidentToken within the Cockpit (which is the CompensationThrowEvent which triggers all Compensations)
The Message contains the activityId of the Compensation-Activity where the Incident realy appears.
Is there another Way to get on the activityId where the Incident realy happens?


When you create a incident, can you store your extra info in something like the configuration property? And store as a Stringified JSON? Then just parse the JSON.

Thanks for your response Stephen, but that’s not what i asked for.

You are asking for the data in the String. The String is just a print of the error occurring:

If you cannot store your data manually for your incidents, and you want to grab is from the existing error, there is a method that the cockpit uses to get the stack trace of a incident when it occurred. Does this stack trace have the data? (check cockpit and select the incident and should bring up a new window with the error). If it matches, then look up the code that generates this, and you can likely get the stack trace of the same info.

@Niels_Hufschmidt so looked at the code a little further:

This looks to be the problem:

The Exception is never persisted in the Job Entity as a Object.

and if you look in the ExceptionUtil.getExceptionStacktrace(.. you can see they truncate the exception length. So likely its being stored as a string deeper into the db mapping layer.

If it was stored as a blob you could override the Failed Job Factory such as in this test:

and implement your own FailedJobCommandFactory and set it as part of the engine config as a Plugin. Then you could extend the DefaultJobRetryCmd with your own overrides, so the getExceptionStacktrace would save the exception as a serialized entity and thus you could bring it back into a proper structure later on… But there are a of spots for stuff to break.

If you dont want to String parse, then a possible fix here would be to Write your entire Delegate in your compensation task with a “global” try/catch. On Catch, you generate a custom Incident through the Java API and you the Incident’s Configuration field to store your custom data. This way you can capture where the actual error occurred.

FYI i recreated, your process and tested the error with a outcome to follow the trail of classes used to generate the Job entity and where the Inner Stacktrace content was actually coming from. the JobRetryCmd class and its Default implementation being used by the failedJobfactory.