CA API Gateway Control the total time limit for multiple calls in policy in APIM
search cancel

CA API Gateway Control the total time limit for multiple calls in policy in APIM


Article ID: 107777


Updated On:


STARTER PACK-7 CA Rapid App Security CA API Gateway


Customer's use case:
Customer has a requirement for the CA API gateway to return a HTTP 504 (Timeout) after 2 seconds. A client (an IVR) will be calling the gateway and the gateway calling a number of back end services (via Route assertions). If all of these assertions (combined time) is more than 2 seconds the gateway service should return a HTTP 504 back to the client (an IVR). It's known the Route assertion has a Connection Timeout and a Read Timeout but that is for the Route assertion, not the api service as a whole. If there are two Route assertions each with a 2 second timeout that would be a 4 second timeout for the service as a whole, assuming each of the 2 routes are called exactly once, which is not the case.


Component: APIGTW


Using ${request.elapsedTime} to calculate the dynamic timeout for next route via http(s) assertion.

${request.elapsedTime} : Returns the amount of time, in milliseconds, between receiving the request and the time the assertion that uses the variable is executed. 

The attached sample policy (dynamicTimeout.xml) will use the time limit (2 seconds) to minus the ${request.elapsedTime} to get the rest of the time, and set it as the timeout for next api call. 
That should ensure the next call will not exceed the total time limit. (It might exceed a little bit, consider the error handling after route timeout) 


1558536627737dynamicTimeout.xml get_app