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.