-
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
Add a possibility to use listener per @Retryable method instead of global listeners #485
Comments
By @artembilan we can solve this in the future: |
Thank you, Yuriy! I mean that gas to be like:
|
@artembilan sure, corrected, thx |
It doesn’t matter now in this post: a notification has already been sent to that GH user 😅. |
Good for that user : ), if such user exists then will learn about this issue 😅 |
In my project I wanted to add a listener and use it along with
@Retryable
annotation.But when I add a listener, it's automatically considered by Spring Retry as global one, meaning it will be applied at least to every method marked with
@Retryable
annotation, which prevents me from creating listener, because I don't want to impact an existing code.Example:
@Retryable(retryFor = SomeException.class, maxAttempts = 5, listeners = "myListenerBean")
When I create myListenerBean, it will be automatically applied to all existing methods with
@Retryable
annotation, which is not desired behavior.The only way to prevent this is to either specify an empty string on existing code, which is not always possible to modify an existing code
@Retryable(listeners = "")
or use interceptor attribute which cannot be used with any other attributes and which requires interceptor bean along with all retry configurations code:
@Retryable(interceptor = "myInterceptorBean")
As a result instead of using neat single line:
@Retryable(retryFor = SomeException.class, maxAttempts = 5, listeners = "myListenerBean")
I'm forced to use:
@Retryable(interceptor = "myInterceptorBean")
along with whole retry configuration, for example:
As it's been already discussed here, we could think of any alternative, for example deprecating existing listeners attribute and/or providing some other attribute(s) etc. in order to not use global listeners.
Thanks.
The text was updated successfully, but these errors were encountered: