I'm wondering : is it a non-sense to put a timeout on a synchronous web-service call ? I mean, if there is a risk that the server does not respond, I should use an asynchronous call instead, doesn't it ?

(I'm using Jersey)

Thanks !

有帮助吗?

解决方案

I'd always advise to set a connection and read timeout on any and all outbound network requests as indefinitely waiting for an answer could eventually consume all your threads and make your app server unresponsive.

In my experience it's no unusual at all to have partners' WS requests not respond withing 60s (which is quite generous).

Handling read timeouts can be tricky for write operations though as you can't tell whether the other system eventually recorded the request or not. In such situation, your partner hopefully provides an idempotent API allowing you to retry at a later time without risk of duplicate execution. Otherwise it may require manual communication with your partner.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top