0

I am trying to work on poc using resilience4j retry libs to replace spring retry. I have a question if someone can help point me to right direction:

spring retry has listener support which has open(RetryContext rtx, ..) method, which is called before start of retries. I am using this method to do one time operation (pre-requisite) before any retries. Also I am setting the actual method args in RetryContext and retrieve them in listener methods like below:

Sample dummy code ->

retryTemplate.execute(context -> {
            context.setAttribute("attr1", "attr1_value");
            service.call( arg1, arg2 ) 
            return null;
 });


public class ListenerSupportImpl extends RetryListenerSupport {
    @Override
    public <T, E extends Throwable> boolean open(RetryContext context,
      RetryCallback<T, E> callback) {
        logger.info("onOpen");
        Object value = retryContext.getAttribute("attr1")
        ...
        return super.open(context, callback);
    }
}

Question:

In resilience4j i can see there is EventPublisher and we can add callbacks on onError, onSuccess, but don't see any such spring retry equivalent (open(RetryContext). Also how can we pass the actual method args in resilience4j context?

    Retry.EventPublisher publisher = retry.getEventPublisher();
   publisher.onRetry(event -> System.out.println(event.toString())); --> how to get method args here
Kiras
  • 69
  • 6

0 Answers0