How can I retrieve the name of the implementation method from the RetryContext in the onError method of my RetryListener
<code>import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable;
public abstract class ServiceBase {
@Retryable(value = ServiceException.class, maxAttempts = 3, backoff = @Backoff(delay = 5000), listeners = {"myRetryListener"})
public void start() throws ServiceException {
fireServiceStarted("Service started");
}
}
public class MyRetryListener implements RetryListener {
@Override
public <T, E extends Throwable> boolean open(RetryContext context, RetryCallback<T, E> callback) {
// Log when retry operation starts
return true; // proceed with retry
}
@Override
public <T, E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
// Log when retry operation ends
}
@Override
public <T, E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
// Log each error during retry
}
}
</code>
<code>import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable;
public abstract class ServiceBase {
@Retryable(value = ServiceException.class, maxAttempts = 3, backoff = @Backoff(delay = 5000), listeners = {"myRetryListener"})
public void start() throws ServiceException {
fireServiceStarted("Service started");
}
}
public class MyRetryListener implements RetryListener {
@Override
public <T, E extends Throwable> boolean open(RetryContext context, RetryCallback<T, E> callback) {
// Log when retry operation starts
return true; // proceed with retry
}
@Override
public <T, E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
// Log when retry operation ends
}
@Override
public <T, E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
// Log each error during retry
}
}
</code>
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable;
public abstract class ServiceBase {
@Retryable(value = ServiceException.class, maxAttempts = 3, backoff = @Backoff(delay = 5000), listeners = {"myRetryListener"})
public void start() throws ServiceException {
fireServiceStarted("Service started");
}
}
public class MyRetryListener implements RetryListener {
@Override
public <T, E extends Throwable> boolean open(RetryContext context, RetryCallback<T, E> callback) {
// Log when retry operation starts
return true; // proceed with retry
}
@Override
public <T, E extends Throwable> void close(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
// Log when retry operation ends
}
@Override
public <T, E extends Throwable> void onError(RetryContext context, RetryCallback<T, E> callback, Throwable throwable) {
// Log each error during retry
}
}
I am trying to get the name of the implementation method from the RetryContext in the onError method of your RetryListener implementation. However, I am getting the name of the abstract method instead.