-
Notifications
You must be signed in to change notification settings - Fork 519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using @Retryable in @Service at method level not working with @Scheduled method in another class #243
Comments
You need to show code, configuration and version information or, preferably, a small, complete, example that exhibits the behavior. |
Ok. Give me sometime, will get back to you on this with artifact's n sample code, |
@Service
public class MigrationStepOne {
@Autowired
private Service1 Service1;
@Retryable(backoff = @Backoff(5000), value = {Exception.class})
public String stepOneProcessing(CustomerMigrationStep cms){
try{
String str = "Hello" + 4/0;
return "successful";
}catch(Exception e){
throw e;
}
}
@Recover
public String recover(Exception e, CustomerMigrationStep cms){
CustomerMigrationStep cmss = null;
cmss.setFailureCount(cms.getFailedCount() + 3);
cms = cmss;
service1.saveFailedCount(cms);
}
} @Component
@EnableScheduling
public class Retry scheduler {
@Autowired
private CustomerMigrationStepRepo repo;
@scheduled(cron = "0 0 4,8 0 0 0)
public void retryingMethod(){
List<CustomerMigrationStep> list = repo.findAllFailedCountCases();
for ( CustomerMigrationStep step: list){
CallClassXyz method which internally calls the method retryingMethod() of service class MigrationStepOne
}
}
} |
org.springframework.boot spring-boot-starter-parent 2.5.0 pom org.springframework.retry spring-retry 1.3.1 |
public class Service1{ @Autowired public void saveFailedCount(CustomerMigrationStep cms){ |
Table entry |
Do we expecting any other information ?? |
Please learn how to use GItHub markdown to format code. This code makes no sense to me CustomerMigrationStep cmss = null;
cmss.setFailureCount(cms.getFailedCount() + 3); The second line will throw a |
Spring Boot Starter - 2.1.7.RELEASE, Spring-aop - 5.1.9.RELEASE, spring-retry -1.2.4.RELEASE, @EnableRetry in SpringBootApplication class My Business Logic class is annotated with @component And one of the method annotated with @scheduled(cron="") & @retryable(value = Exception.class, maxAttempts = 3, backoff= @backoff(delay = 1000)) Here Scheduling is working But Retryable is not working. Could you please help on this ? |
same issue here |
@samirm , |
It's likely due to wrong order of AOP advices, see #22. |
Well, according to the issue description this is not the case. |
Using @retryable in @service at method level which is going to retry 3 times by default if get any exception and @recover responsible to sa error count in postgres database table.
I have seperate class for @EnableScheduling with scheduled cron run every four hours which will going to process these failed cases by querying this postgres table.
When aplication starts and failed for the service class within the method annotated with @retryable able to save record in db but when trying through scheduler it's not updating the failure count in database
Originally posted by @amolkumar18 in #94 (comment)
The text was updated successfully, but these errors were encountered: