December 2019
Intermediate to advanced
314 pages
6h 51m
English
In simple terms, the @org.eclipse.microprofile.faulttolerance.Timeout annotation can be used to specify the maximum time (in ms) allowed for returning a response in a method. Here is an example findAll method that times out after 250 ms:
@Timeout(250)public List<Customer> findAll() { randomSleep(); return entityManager.createNamedQuery("Customers.findAll", Customer.class) .getResultList();}private void randomSleep() { try { Thread.sleep(new Random().nextInt(400)); } catch (java.lang.InterruptedException e) { e.printStackTrace(); }}
The random sleep that's triggered by the finder method can be used to allow some occasional execution failures.
In order to mitigate time-outs or ...
Read now
Unlock full access