Im trying to implement the Resilience logic inside an aspect class similar to how it has been done for logging. Below is a snippet of code that I have been trying but it doesnt work.
@Pointcut("within(com.example.demo.*)")
public void myPointCut() {
}
@Around("myPointCut()")
public String addfaultToleranceRateLimiter(ProceedingJoinPoint pj) throws
Throwable,IllegalAccessException,InvocationTargetException {
String result = applyRLtolerance(pj);
return result;
}
@RateLimiter(name="service1",fallbackMethod = "fallbackRL")
private String applyRLtolerance(ProceedingJoinPoint pj) throws Throwable {
String result = (String) pj.proceed();
return result;
}
public String fallbackRL(Throwable t) {
System.out.println("in fallback" + new Date());
return "bye";
}
When pj.proceed() is called the actual logic is executed but the @ratelimiter annotation does not seem to be working as the number of calls getting excuted is not getting limited as per the config given in the application.yml file.