Full-stack dev quiz question #34

Full-stack dev quiz question #34

quiz

Spring libraries are back at dba-presents.com. Thirty fourth question is about Spring Retry.

 

 

 

What will happen if you run doSomething() method of this class:

@Service
public class MyService {
   
private static final int MAX_FAILURES = 2;
   
private int numberOfExecutions = 0;

   
@Retryable (
            maxAttempts =
2,
            backoff =
@Backoff(delay = 200),
            include = SQLException.
class
   
)
   
public String doSomething() {
       
numberOfExecutions++;
       
// succeed after MAX_FAILURES times in a row
       
if (numberOfExecutions > MAX_FAILURES) {
           
return "success";
        }
       
throw new RuntimeException();
    }
}

Choose the correct option:

  1. It will succeed.
  2. It will fail with RuntimeException.
  3. It will fail with SQLException.

For the correct answer scroll down

.

.

.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

.

.

.

The correct answer is: b. For more information read Repeating actions with Spring Retry.

We use cookies

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.