Code Monkey home page Code Monkey logo

Comments (12)

garyrussell avatar garyrussell commented on May 22, 2024

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.

scottmf avatar scottmf commented on May 22, 2024

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.

garyrussell avatar garyrussell commented on May 22, 2024

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.

scottmf avatar scottmf commented on May 22, 2024

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.

garyrussell avatar garyrussell commented on May 22, 2024

I just hacked together a quick PoC garyrussell@f2c98b7

Let's see what @dsyer thinks about whether it's worth pursuing.

from spring-retry.

shollander avatar shollander commented on May 22, 2024

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.

dsyer avatar dsyer commented on May 22, 2024

I didn't see this until now. Maybe a PR would help?

from spring-retry.

richiep33 avatar richiep33 commented on May 22, 2024

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.

garyrussell avatar garyrussell commented on May 22, 2024

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.

garyrussell avatar garyrussell commented on May 22, 2024

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.

shollander avatar shollander commented on May 22, 2024

Thanks for the quick action on this. I tried out the snapshot build and it works perfectly - just what we needed!

from spring-retry.

garyrussell avatar garyrussell commented on May 22, 2024

@dsyer Please note I submitted another PR.

from spring-retry.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.