How spring-projects/spring-retry works
Main Components
• RetryCallback and RecoveryCallback: These encapsulate the business logic to be retried and alternative recovery logic when retries are exhausted.
• RetryContext: Show it as a component that holds retry-specific state (such as retry count and any other custom state data) used by the RetryTemplate.
• BackoffPolicy Implementations: Illustrate the different strategies used to delay between retries (for example, ExponentialBackOffPolicy, FixedBackOffPolicy, UniformRandomBackOffPolicy). Again, group these as a “backoff” layer.
• AOP Integration using the RetryOperationsInterceptor (in conjunction with @Retryable and @Recover annotations): For declarative retry, demonstrate how the interceptor wraps target service methods and delegates to the RetryTemplate.
• Supporting Utilities: Also include auxiliary packages such as “org.springframework.retry.classify” (for classifying exceptions), “org.springframework.retry.support” (for helper classes and fluent configuration builders), and “org.springframework.retry.stats” (for metrics and statistics).
• Infrastructure & Build/CI Components: Optionally include an inset depicting the GitHub Actions workflows, Maven configuration (pom.xml, mvnw, etc.) and file organization, showing that these support the build, test, and release process although they are not part of the runtime system.
Relationships and Interactions
– RetryPolicy: where the decision to continue or abort is made.
– BackoffPolicy: that introduces delays between re-executions.
– RetryCallback/RecoveryCallback: showing the business or fallback logic.
• RetryContext being created and updated with every attempt.
Architectural Patterns and Design Principles
• Template Method design pattern as used by RetryTemplate.
• Use of Strategy pattern: the interchangeable use of different RetryPolicy and BackoffPolicy implementations.
• How listeners are used as a plug-in mechanism for cross-cutting concerns (e.g., metrics collection, logging, and exception handling).
• Use of AOP for declarative retry support with annotations (@Retryable and @Recover).
Relevant Technologies and Frameworks
• That this library is built to integrate with Spring, referencing Spring AOP for proxy-based retry handling.
• Support for Micrometer metrics via the MetricsRetryListener.
Specific Elements to be Included
• Clearly labeled components:
– “Client / Service Layer” (where the retry-enabled method is defined; note if using @Retryable)
– “AOP Proxy / RetryOperationsInterceptor” (for declarative usage)
– “RetryTemplate” (core operation execution)
– “RetryPolicy (Simple, Timeout, etc.)”
– “BackoffPolicy (Exponential, Fixed, etc.)”
– “RetryContext” (manages state; show how it is passed among components)
– “RetryCallback & RecoveryCallback”
– “Listeners” (with an example such as MetricsRetryListener)
– Flow of method invocation
– Decision points (retry policy checking conditions)
– Data/exception flow and subsequent backoff delay actions.
• Optionally, a separate section for build and CI details (GitHub Actions workflows, Maven wrapper, etc.) to provide context on how the library is maintained and built.