I am using a Service task + Java delegate approach to call my web service.
When my web service returns some failure response, I am trying to set the data returned by the web service using:
execution.setVariable("status", "FAILED");
execution.setVariable("error", "error from service XX");
And then I also want to stop the execution and create an incident at this step of the process. So, I simply throw Exception with appropriate message e.g. throw new Exception(“my service returned failure response”).
After this I can see the Incident in the Cockpit but there are two issues:
I do not see the exception message “my service returned failure response”, instead I see “Message is null” for the incident
None of the variables I set are seen on Cockpit.
How can I make sure the message that used to throw the Exception with is shown for the Incident and also any variables I set are visible in Cockpit?
Hi,
I am just throwing Exception from my Java delegate. That automatically creates incident. The problem is that the message is null in that incident.
Another strange thing is that, if I retry that failed task, which throws same exception, then this time it shows exception message in incident correctly. Not sure why it shows no message when the exception is thrown first time.
@Yana
Can you please help with this question?
I am simply throwing Exception from Java Delegate and it is creating the incident automatically but without any message.
This is happening only when I am using “R0/PT10M” in “Retry Time Cycle” for my service task. I cannot increase the retry count. I want retries to be zero for all my service tasks.
This works as designed. If a service throws an exception then the process is rolled back to the last async point. I.e. all variables set in the step get lost. To retain them you could e.g. throw a BpmnError and then in that process path execute a service (with async before = true!) which will throw an exception.
async before = true ==> the state will be committed before entering the step
throw exception ==> an incident will be created