Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Is there a way to set a timeout on the ProxyEndpoint (not the target)?

I am developing an API proxy that makes several service call-outs to various targets. Each service call-out has its own timeout set within the Service Call-Out policy, however I would also like to define a timeout for the whole API itself. I assumed I would be able to define a io.timeout.millis setting on the ProxyEndpoint, similar to the TargetEndpoint, but this setting does not exist. Is there another way to accomplish this?

Solved Solved
0 8 2,340
1 ACCEPTED SOLUTION

I agree to what @Mukundha Madhavan said.

But is the reasoning for timeout that if a client made a call and it is taking lets say 15 seconds to finish then the backend should timeout? Now normally the backend is represented by TargetConnection and hence it is simple. But in your case backend consists of multiple calls via service callouts. So you need a different way to do the timeout.

If that is true, then I think there may be a way to do it.

The answer is Proxy Chaining.

Chain two proxies. Your calls come to Proxy1 which then sends the calls to Proxy2. Proxy1 does not have any business logic apart from io.timeout.millis set in Target Connection.

Proxy2 has all the service callouts.

So if Proxy2's work is not finished in time then Proxy1 will timeout and send a custom error message to the client.

You can see details here: http://docs.apigee.com/api-services/content/connecting-proxies-other-proxies.

Does this work?

View solution in original post

8 REPLIES 8