My 2 cents:
If you re-throw error from service flow - default retry API (and button retry in Process Inspector) works as you described. It basically retries returning error from service to main process.
This is not what you probably expect :)
My workaround for that is to first reset token on last failed activity (place where you invoked service).
This needs 2 REST API calls:
- Get execution tree (GET /rest/bpm/wle/v1/process/<pid>?parts=executionTree)
Find token for failed activity (tokenId, flowObjectId – first children under root)
- Set token in the same place (PUT /rest/bpm/wle/v1/process/<pid>?action=moveToken&tokenId=< tokenId>&target=< flowObjectId>&resume=true)
After that standard retry (e.g PUT /rest/bpm/wle/v1/process/<pid>?action=retry or pressing retry button in Process Inspector) will re-execute whole service (from the beginning of failed service).
To be honest I frequently re-implement functionality of Process Inspector to have more admins friendly tool. It requires some efforts but BAW API is much more powerful than UI of Process Inspector.
E.g. initial problem in this thread of getting (modeled) error can be easily solved using that call:
GET /rest/bpm/wle/v1/process/errors?instanceIds=<pid>
You will find there errorData attribute which contains (serialized as XML) error object.
It is not available in Process Inspector, though.
Retry functionality is mostly useful for system tasks – so documentation update done in this APAR https://www.ibm.com/support/pages/apar/JR61296 is indeed rather misleading.
------------------------------
Sebastian Tylko
------------------------------
Original Message:
Sent: Wed March 02, 2022 03:31 PM
From: Mattias Edling
Subject: IBM BAW: How can I get Process Inspector to display my process error message?
I think I am ready to continue the discussion and must admit some statements came out of my long-term memory. It was a while since I last did these things until just recently. I think I remember using 1. for system tasks in processes that mostly contained human tasks. If data or network problems caused error the instance would fail and we could then retry-revive it. Skipping or terminating is generally not an option. My current application under development is like this.
There are some strange behaviours when retrying failed steps.
Catching and rethrowing in the service flow seems to make the error end event the new failed step or something. The same error occurs again even after correcting the root cause. Also, process inspector is not displaying the correct details.
If I don't catch anything, retry works. However it reruns the whole task service (the topmost service flow) even when the error occured halfway in, say at the third step which is nested service. This is apparent from log entries in each step. I vaguely recall that retry, at least in 8.0.x, started after the last successful step or at least at the beginning of the affected service.
Next strange things is that the product documentation states that retry does not work for system tasks:
https://www.ibm.com/docs/en/baw/20.x?topic=inspector-actions-in-process
But it does now and I am sure it did before. It would be unreasonable if one could not.
I did these tests in BAW 20.0.2 Process Center, where I triggered the error by a script null pointer assignment. Upon error I commented it away, saved and retried failed steps.
------------------------------
Mattias Edling
Original Message:
Sent: Fri January 28, 2022 12:17 PM
From: Gregor Schikorski
Subject: IBM BAW: How can I get Process Inspector to display my process error message?
Thanks for your comments, Mattias.
If you are at the process layer, I think there are basically three options how you can deal with an exception thrown in an executed service:
- You do not catch the exception at all or you catch it at the service layer, do something (e.g. log output) and re-throw it without catching anything at the process layer. Either way, the exception will interrupt the processing and the process instance will be set to status 'Failed'. No further steps in the process are taken. If the exception is a custom one, Process Inspector will not reveal much about the cause of the encountered failure.
- You catch the service exception at the process layer and let the process continue. That way, further required process steps can be taken and the process can still end gracefully with status 'Completed'. However, if you check your instances in Process Inspector later on, it will probably be difficult to tell which instances had problems as they are all completed.
- You catch the service exception at the process layer and let the process continue (down the designated error path). That way, further required process steps can be taken. However, you do not want the process instance to show as completed because it actually failed, so you let the process run into an Error End Event. The instance status is set to 'Failed'. Process Inspector should tell you which exception was encountered. Unfortunately, it does not.
Personally, I do not like option 1 because I am keen on taking a few more process steps before I let the exception kill the flow. Moving tokens can be helpful sometimes but it should be the last resort in my opinion.
Option 2 leads to completed instances but I would like to have failed ones to get proper statistics, so I don't like this option, either.
Option 3 is my favorite and it actually works as expected - well, except for Process Inspector's incapability of displaying the error message handed over via the final Error End Event.
As mentioned in my comments to Atanu, I do not understand why Process Inspector cannot consume the error message. Any other process can. I think the fact that Process Designer enables you to use Error End Events at the process layer means that it is supposed to work. That's why I believe this is nothing but a deficiency in Process Inspector.
------------------------------
Gregor Schikorski
Original Message:
Sent: Fri January 28, 2022 10:17 AM
From: Mattias Edling
Subject: IBM BAW: How can I get Process Inspector to display my process error message?
I found this interesting, but it actually took a few visits before I realized that you are catching technical errors (as opposed to business exceptions) in the business process layer. Normally I catch, log and re-throw in the service layer. Is that not an option? The bonus of doing so is being able to retry failed step within the service, in addition to the option of moving the token. Stupid question: Is there even a token if the process ends by an error event?
------------------------------
Mattias Edling
Original Message:
Sent: Fri January 07, 2022 10:11 AM
From: Gregor Schikorski
Subject: IBM BAW: How can I get Process Inspector to display my process error message?
I am trying to build a simple process in BAW that is supposed to work as follows:
The process calls a service flow. When an error is detected in the service flow, the error is caught by the process, printed to the logs and then the process ends on an Error End Event so that the process instance status is set to 'Failed'. Here is how it looks like:
Catching the error and printing it to the logs works as expected but when the process reaches the Error End Event and the process instance is set to failed, the instance error details shown in Process Inspector always say "No error message". Only the error code specified for the Error End Event is correctly reflected in the details:
No matter what data or data type I hand over as Error Data in the Error Mapping section of the Error End Event properties, the output in Process Inspector is always the same: "No error message".
Can anyone tell me how I could get the error message contained in my Error Data object into the instance error details displayed in Process Inspector?
If it is not possible at all, I would like to understand why. Thanks in advance for your help!
------------------------------
Gregor Schikorski
------------------------------