timeout for asynchronous response

  • I need to implement timeout response to API consumers for an Asynchronous callback response.
  • For example, Consumer C make a call to API provider P. After receiving the request P send an acknowledgement to C. After that P start 5 requests to Downstream systems D1 to D5 with asynchronous message pattern. Each system respond back & P consolidate their response & send back response (via callback) to C. If any of the downstream system timed out or not sending response then P will not send any response to C.
  • I need to implement best approach to clean up any pending requests on P. If C send a request to P & P do not receive response from D4, then P can't send response to C. In this case, I need API Proxy to automatically trigger an error message on callback
0 2 988
2 REPLIES 2

@Ashwani Jain

Easiest way is to maintain delay equal to timeout to be specified at level P, Consolidate all responses till the time out to send the response, neglecting the late responses.

I prefer this since there wont be any additional communication overhead

Not applicable

I would suggest to go with Node.js implementation for the same. Here are the sequence of steps that would be useful :

-> Get the request in Node.js and validate

-> Respond back to the user the result of validation, success or failure ( with reason )

-> If the validation is successful, send the request back D1-D5 and aggregate all in the node code itself.

Using node will give you very good control over how you want to deal with the code and how to handle for errors for each of the system. Being non-blocking also gives an edge over performance vs doing the same in JS.