I need to implement the following flow:
Back-end makes HTTP request to Service A, waits for a response from Service A,
then makes HTTP request to Service B, waits for a response,
then makes concurrent HTTP requests to Service C, waits for responses.
if the response from Service A does not contain specific info required for the next request, break the flow and return an empty response.
the same is true for the response from Service B.
Services A, B, and C are different external APIs.
Question: Could you suggest a design pattern for this flow? My goal is to make the project maintainable. In case if tomorrow we'll need to replace Service C with Service D, or add new Service E to the flow.
I'm sure failures are inevitable... So my second question is how to handle network errors which may occur during any of the mentioned requests? Should it be a single try-catch block wrapping the flow, or separate try-catch blocks for each request?
I'm using Java/Kotlin with Spring framework if this is important.
I'll handle response caching, authentication, token refresh, logging, and configuration in separate classes. This question is specifically about the flow design.