Comments (12)
You could do that relatively easily today with
@Retryable(interceptor="myInterceptor")
Where myInterceptor
is a RetryOperationsInterceptor
bean with a custom retry policy that looks at the exception to decide in canRetry()
.
from spring-retry.
thanks Gary. I know the interceptor is available but in the spirit of conciseness it would be nice to have a spel expression
from spring-retry.
It's probably not too hard for a single exception, but the include
attribute is an array, and no include
means retry for all exceptions. The expression might get unruly very quickly...
"#this instanceof T(com.Foo) ? #this.somCondition() : #this instanceof T(com.Bar) ? #this.someOtherCondition() : false"
I am happy to discuss further, though.
from spring-retry.
Understood. I would think that for more complex situations a developer would create an interceptor and for simple situations like mine it would be nice not to have to add all the extra boiler plate. I see a lot of annotations using spel like this and situations can occur like you suggested, but for ~ 80% of the scenarios it is very clean.
I have need for the interceptor right now so that's what I am going to use. If you strongly feel that the expression is the wrong thing to do then that's fine. As a consumer of the api, who uses it a lot, it would be a nice feature to add.
from spring-retry.
I just hacked together a quick PoC garyrussell@f2c98b7
Let's see what @dsyer thinks about whether it's worth pursuing.
from spring-retry.
Hi,
This feature would be very useful for me as well. Any word on getting the fix by @garyrussell incorporated into a release?
What I am really looking for is a way to configure the maxAttempts
and Backoff
parameters so that they are configurable and not hard-coded at compile time.
from spring-retry.
I didn't see this until now. Maybe a PR would help?
from spring-retry.
I am very interested in this feature as well. I have considered writing my own due to this limitation. Otherwise, spring-retry appears very useful.
from spring-retry.
The PoC just evaluates an expression against the exception to decide whether it was retryable or not (which is the original request in this issue).
It does not address evaluating the maxAttempts
and backOff
attributes as expressions; that's really a separate issue and would take a bit more work.
I am offsite all next week so I don't think I could look at this before Dec 12 which might be too late for spring-retry 1.2. I'll see if I can spring free some time tomorrow, but no promises.
from spring-retry.
I went ahead and issued a PR; not sure if we feel it's too big to add to 1.2 after the RC.
I went with discrete attributes to avoid breaking changes.
from spring-retry.
Thanks for the quick action on this. I tried out the snapshot build and it works perfectly - just what we needed!
from spring-retry.
@dsyer Please note I submitted another PR.
from spring-retry.
Related Issues (20)
- NPE in CircuitBreaker, wrong null check HOT 2
- Unexpected exception type thrown instead of actual CHECKED exception when noRetryFor is used HOT 3
- Upgrade to AspectJ 1.9.20.1 HOT 1
- Upgrade to Spring Framework 6.0.15
- Upgrade to JUnit 5.10.1
- Upgrade to Log4J 2.21.1
- Upgrade to Mockito 5.7.0
- Upgrade to Spring Javaformat 0.0.40
- Upgrade to Maven Javadoc Plugin 3.6.3
- Upgrade to Maven Surefire Plugin 3.2.2
- Upgrade to Maven Wrapper 3.9.6
- A little idea about result filtering HOT 1
- backOffContext.getSleepAndIncrement() not using this.interval correctly when using supplier HOT 1
- put GAV in docs HOT 4
- Does it support springboot3? It seems that it cannot be used under springboot3. HOT 2
- `ExponentialBackOffContext` not considering the interval set by `application.properties` HOT 3
- No distinction in the logs between different retried methods HOT 2
- Wrong method recommended for build.gradle? HOT 2
- Exponential backoff stops being exponential after few iterations. HOT 4
- @Retryable annotation retrying with ExponentialBackOff instead of ExponentialRandomBackOff when randomExpression provided HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-retry.