Timeout
For introduction, see How to Watch for Timeouts.
Description
If a guarded method takes too long, the caller will get a TimeoutException
.
If the gaurded method is not @Asynchronous
or @AsynchronousNonBlocking
, the thread executing the method is interrupted.
Note that interruption requires cooperation from the executing code.
In other words, it is not guaranteed that interrupting the method will actually make it stop.
Metrics
Timeout exposes the following metrics:
Name |
|
Type |
|
Unit |
None |
Description |
The number of times the timeout logic was run. This is usually once per method call, but may be zero times if the circuit breaker or rate limit prevents execution or more than once if the method is retried. |
Tags |
|
Name |
|
Type |
|
Unit |
Nanoseconds |
Description |
Histogram of execution times for the method |
Tags |
|
See the Metrics reference guide for general metrics information.
Interactions with Other Strategies
See How to Use Multiple Strategies for an overview of how fault tolerance strategies are nested.
If @Fallback
is used with @Timeout
, the fallback method or handler may be invoked if a TimeoutException
is thrown, depending on the fallback configuration.
If @Retry
is used with @Timeout
, each retry attempt is processed by the timeout as an independent invocation.
If TimeoutException
is thrown, the execution may be retried, depending on how retry is configured.
If @CircuitBreaker
is used with @Timeout
, the circuit breaker is checked before enforcing the timeout.
If enforcing the timeout results in TimeoutException
, this may be counted as a failure, depending on how the circuit breaker is configured.
If @RateLimit
is used with @Timeout
, the rate limit is enforced before enforcing the timeout.