December 2019
Intermediate to advanced
314 pages
6h 51m
English
Sometimes, failures in the execution of your methods are caused by temporary issues such as network congestion. If we are confident that the issue can be resolved in accordance with our business SLA, we can include a @Retry annotation to allow us to reiterate the execution of failed methods a certain number of times.
For example, by adding the @Retry(maxRetries = 3) annotation, we will attempt to load data from the database three more times before using a static list of customers:
@Timeout(250)@Fallback(fallbackMethod = "findAllStatic")@Retry(maxRetries = 3)public List<Customer> findAll() { randomSleep(); return entityManager.createNamedQuery("Customers.findAll", Customer.class) .getResultList()
Read now
Unlock full access