I have a requirement which I want to solve using Mule. My flow design follows like:
- A main-flow with request-response HTTP inbound endpoint. After applying couple of transformations on the current payload this main flow invokes two private flows namely private-flow1 and private-flow2, which are mule private flows whose processing strategy is synchronous.
- The private-flow1 invokes an external service using request-response HTTP outbound endpoint.
- The private-flow2 places the response from the external service on Database using Database Connector.
If there is any exception in each of the private flows, I want to handle them in the corresponding private flow itself using Catch Exception Strategy.
I have this design to separate the concerns, so that each flow performs a single responsibility.
Suppose there is an exception like IOException, SQLException or any, in any one of the private flows, how can I re-throw my custom exception, for example, org.mycompany.CustomException including the underlying cause. So main-flow will have to handle only org.mycompany.CustomException and build the related exception response.
Say for example, if private-flow1 throws org.mycompany.CustomException which is caused by IOException, the realted exception response would be:
{"exceptionMessage" : External Service unavailable, "exceptionCode" : 101}
and, if private-flow2 throws org.mycompany.CustomException which is caused by SQLException, the realted exception response would be
{"exceptionMessage" : Database unavailable, "exceptionCode" : 102}