liveBook · Manning

Time limiter

As explained in Microservices Patterns, Second Edition

A resiliency pattern that bounds how long an operation may wait for completion before it is treated as failed.

A time limiter caps how long a client waits for a remote response. When the timeout is exceeded, the call fails, helping protect latency SLOs and limiting time spent waiting. section 8.2.4

Use it for synchronous provider calls, including those made during API composition. A timeout enables fail-fast behavior; returning a useful response when a provider is unavailable requires a separate fallback strategy. section 12.3.3

Listing 8.2 In a Spring Boot application, Resilience4j can be used by annotating client proxy methods. Method calls are intercepted by Spring AOP and wrapped with resiliency logic.
class OsoAuthorizer {

  @CircuitBreaker(name = "osoAuthorizer")
  @TimeLimiter(name = "osoAuthorizer")
  @Retry(name = "osoAuthorizer", fallbackMethod = "isAuthorizedFallback")
  public CompletableFuture<Boolean> isAuthorized(String user, String action, String securitySystem) {
    ...
  }

  private CompletableFuture<Boolean> isAuthorizedFallback(String user, String action, String securitySystem, Exception exception) {
    return CompletableFuture.completedFuture(false);
  }

See a Spring Boot client proxy annotated with Resilience4j’s @TimeLimiter alongside circuit-breaker and retry annotations. section 8.2.4

How Microservices Patterns, Second Edition covers it

How deep it goes
Defines timeout-based failure and its purpose, without specifying timeout values or detailed failure handling.
Examples
Shows a Spring Boot client proxy using Resilience4j’s @TimeLimiter with circuit-breaker and retry annotations.
What you can do after
Apply it via Resilience4j’s @TimeLimiter annotation on a client proxy to bound remote-call waiting.
How it connects
Pairs with circuit breaker, bulkhead, retry, rate limiter, fallback, and API composition for resilient synchronous calls.

This explainer was generated by Manning's knowledge graph from the text of Microservices Patterns, Second Edition. The section links point to the parts of the book it draws on.