I have two services:
parentService and childService.
Both the services use exceptionhandling(try/catch).both services’ catch block publishes error to broker.
parentService calls childService.
childService has some logic: say if some value cannot be updated in the database, it exits the flow signalling the “error message”.
My doubt is : if control reaches to “exit flow”, does it exit the flow and do what ever is there in catch block of childService and then return to tha catch block of parentService and execute the steps in that block???
If the exit flow reaches to the catch blocks of child and parent, I think this leads to redundancy of publishing the same error to broker twice!!!
Can anyone clarify my doubt
The child will catch and handle the exception. Keep in mind that if you do an exit $flow and signal failure, getLastError (which is usually the first thing called in the catch block) won’t return anything meaningful.
Whether or not the parent’s catch block is executed depends on what the child’s catch block does. If the child catch block completes without error, then the parent catch block will not be executed.
that clarifies my doubt clearly. thank you Rob
i have one more question regarding EXIT flow signal failure: Is the failure message thrown logged into audit log? if not where is it logged into?
thanks Rob for the answer
Do you need to have exception handling in both the parent and the child services? I normally only try to include a try-catch block in the top-level service. If you must have a try-catch block in both services, then I would suggest only having the parent service do the publishing to the Broker.
As far as auditing is concerned, yes, EXIT and SIGNAL FAILURE will cause the error to be written to the Audit log as long as the service is setup for auditing.
One doubt in this context…when we do audit logging for both parent and child services, what ever may be the settings on the child service, it does not log the pipeline to monitor so that it can be resubmitted…y is this so? It makes sense that only high level services ought to be resumitted because the child service returns the flow/data to parent …but shouldn’t that be left to the developer for configuration…there can be child services which have nothing to do with the flow but still be synchronous…why is it that there is no option for resubmitting them
Please correct me if i am wrong
I think it was done on purpose to not allow resubmitting child services. The reason might be that it can produce unpredictable results as, often, child services only do partial work.
I think each record in WMSERVICE audit table will have a switch(0 or 1) to say if it is resubmittable or not. You might be able to resubmit a service if you flip this switch manually for a child service, ofcource it will be unrecommended.
Also, if you use modeler and if logging is turned on, you can resubmit a process starting from a failed step. Here the process continues from the failed step, not just the step itself is executed.
I’ve ran into the same issue you described in the past. At the time, the issue wasn’t critical to me, so I didn’t spend any time on trying to determine why the pipeline wasn’t getting logged for child services. I was almost sure it was a bug since it doesn’t really make sense to me.
For example, suppose your parent service accepts an XML message or a flat file as input. In either case, your input variables will probably be an object: either a node or an ffdata object. Given this, logging the pipeline at the parent service level doesn’t make too much sense. Converting the object to a string, for example, and then passing it onto a child service which does log the pipeline would seem like a logical approach to me. Nonetheless, this doesn’t seem doable from what you and I have seen. Why is it not doable? I’m not exactly sure, but hopefully someone else can provide a good answer.
I need to have exception handling in both parent and child services.
The parent service just does a call to child service.
the child service uses getLastError and publishes this error to Broker.
The parent service does the same handling of the error+it does exit FLOW and signal FAILURE for audit logging.
here the parent service is set up for audit logging.
i have one doubt in this context. if the child service is handling the error and publishing, what error can the parent service catch??? to publish to broker and audit log???
please clarify my doubt
In this case
"For example, suppose your parent service accepts an XML message or a flat file as input. In either case, your input variables will probably be an object: either a node or an ffdata object. Given this, logging the pipeline at the parent service level doesn’t make too much sense. Converting the object to a string, for example, and then passing it onto a child service which does log the pipeline would seem like a logical approach to me. "
If you want the child service only for resubmision, this does not make sence. This is because the child service is expecting string a input, and when you resubmit only the child service, the service input is null and the child service cannot do any job.
If you want to handle the error in two places (ie. in the child service and in the parent service as well), then you must make sure that once the child service catches and handles the error, the last thing it does is to throw the error up to the parent. One simple way to do this is to use EXIT and SIGNAL FAILULRE with the failure message set to %lastError/error%.