liveBook · Manning

@Retry

As explained in Quarkus in Action

@Retry is a MicroProfile Fault Tolerance annotation that configures repeated execution of a failed method invocation.

@Retry is a declarative MicroProfile Fault Tolerance annotation for repeating a failed method invocation before returning the failure. In Quarkus, the SmallRye Fault Tolerance extension supplies the implementation, keeping resilience behavior outside business logic. section 10.5

Use retry as one part of a broader fault-tolerance strategy:

  • Retry failed operations for a configured number of attempts before propagating the failure. section 10.5
  • Combine retry with fallback when eventual recovery is preferable but continued failure should produce an alternative result. section 10.5.1
  • Apply the policy on the client side of a remote call, where the calling service must tolerate another service becoming unavailable. section 10.5.1

For the car-rental availability request, annotate the Reservation service method that calls Inventory. A configuration of maxRetries = 25 and delay = 1000 retries the method up to 25 times with a one-second delay between attempts. If every attempt fails, the request can wait up to 25 seconds before the failure reaches the client. section 10.5.1

$ quarkus extension add smallrye-fault-tolerance

Add the SmallRye Fault Tolerance extension to the Reservation service before using the annotation. section 10.5.1

@Retry(maxRetries = 25, delay = 1000)

Configure the availability method with 25 retries and a 1,000-millisecond delay between attempts. section 10.5.1

Availability during an Inventory outage

When Inventory is temporarily unavailable, Reservation re-executes its availability method instead of failing immediately. If Inventory remains down, retry eventually gives up; a separate fallback can return an empty car list rather than throw an exception. section 10.5.1

How Quarkus in Action covers it

How deep it goes
Explains annotation placement, retry count, delay, timing, and idempotency, while deferring programmatic fault-tolerance APIs.
Examples
Demonstrates Reservation availability calls, an unavailable Inventory service, 25 attempts, one-second delays, and an empty-list fallback.
What it assumes
Assumes a Quarkus service and remote call, while introducing fault-tolerance patterns and client-side policy placement.
What you can do after
Apply it via @Retry and the SmallRye extension to tolerate transient service failures in an idempotent method.
How it connects
Connects retries with fault tolerance, fallback, REST clients, idempotency, and service-to-service failure handling.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quarkus in Action. The section links point to the parts of the book it draws on.