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.
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?
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.
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.