Skip to content

Why is it allowed for @Retryable and @Recover to be used only within the same class? #444

Answered by yongsk0066
solomon-maeng asked this question in Q&A
Discussion options

You must be logged in to vote

I think the main reason for restricting @Retryable and @Recover to the same class lies in how Spring Retry implements its functionality using proxy-based AOP.

Spring Retry uses AOP proxies to intercept method calls annotated with @Retryable and apply the retry logic. For the proxy to handle both the retry and recovery logic effectively, it is essential to have @Retryable and @Recover within the same class. This allows the proxy to manage both methods and delegate the recovery process to the @Recover method when retries exhaust.
If @Recover were allowed in a separate class, it would complicate the proxy's ability to locate and invoke the appropriate recovery method, leading to a more compl…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by artembilan
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #443 on June 20, 2024 15:23.