1. Event Listeners

Timeouts allow you to fail an execution with TimeoutExceededException if it takes too long to complete:

Timeout<Object> timeout = Timeout.of(Duration.ofSeconds(10));

You can also cancel an execution and perform an optional interrupt if it times out:


If a cancellation is triggered by a Timeout, the execution is still completed with TimeoutExceededException. See the execution cancellation section for more on cancellation.

Event Listeners

Timeouts support the standard policy listeners which can notify you when a timeout is exceeded:

timeout.onFailure(e -> log.error("Connection attempt timed out", e.getFailure()));

Or when an execution completes and the timeout is not exceeded:

timeout.onSuccess(e -> log.info("Execution completed on time"));