I am new to spring, as part of my project implementation, I am supposed to add a spring retry on a service method that invokes JPA repository. Code looks something like below
@Retryable(value = {Exception.class},maxAttempts = 1,backoff = @Backoff(300))
public Page findAllAccounts(AccountSearchRequest account, Pageable pageable) {
try {
return map(accountSearchRepository.findAll(account, pageable));
}catch (Exception e){
System.out.println("SQL EXCEPTION CAUGTH!!!!!!!!!");
}
return null;
}
@Recover
public void recover(Exception e){
System.out.println("!!!!!!!!!!!Failed to get connection!!!!!!");
}
Database : Postgresql,
Application : Java Spring Boot (Exposed Rest API to get all accounts)
HikariPool MaximumPoolSize ** : **1
Hikari ConnectionTimeout ** : **1000
JMeter is used to send 10,000 API requests.
Problem : I am able to see SQL EXCEPTION CAUGTH!!!!!!!!! prints but i think retry is not working since I am not seeing the recover method's print. am i missing something?
Below is the gradle dependencies
//
https://mvnrepository.com/artifact/org.springframework.retry/spring-retry
compile group: 'org.springframework.retry', name: 'spring-retry', version: '1.2.4.RELEASE'
//
https://mvnrepository.com/artifact/org.springframework/spring-aspects
compile group: 'org.springframework', name: 'spring-aspects', version: '3.2.4.RELEASE'
//
https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-aop
compile group: 'org.springframework.boot', name: 'spring-boot-starter-aop', version: '2.1.3.RELEASE'
//
https://mvnrepository.com/artifact/org.springframework/spring-aop
compile group: 'org.springframework', name: 'spring-aop', version: '5.1.5.RELEASE'
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)