Giter Site home page Giter Site logo

Comments (4)

jhalterman avatar jhalterman commented on August 19, 2024

That's an interesting scenario. Basically, we would need to modify the arguments passed to JavaMailSenderImpl.send (or whatever) for each retry based on the contents of MailSendException. There's currently no way to do this with Recurrent since Recurrent just re-runs a Callable or Runnable. It could be possible to swap in a new Callable or Runnable, but modifying the actual arguments would require a different approach, more along the lines of another library, Sarge, which captures (and could potentially manipulate) invocation arguments passed to a proxy.

What I'd like to do instead is support this sort of use case via Recurrent's retry tracking, where you can manually perform retries within a loop but still use Recurrent to manage the policy and track retries for you. Ex:

Collection<Object> messages = ....
RetryStats stats = new RetryStats(retryPolicy);
while (stats.canRetry() && !messages.isEmpty()) {
  try {
    mailSender.send(messages);
  } catch (MailSendException e) {
    messages = e.getFailedMessages().values();
  }
}

This sort of thing isn't possible right now, but I could add it easily and wanted to give you an idea of what I'm thinking. Thoughts?

from failsafe.

derylspielman avatar derylspielman commented on August 19, 2024

I am able to achieve this through nurkiewicz async retry framework https://github.com/nurkiewicz/async-retry as you get the last Throwable inside a context object provided to you in the block of code retrying. I haven't tested this yet though.

from failsafe.

jhalterman avatar jhalterman commented on August 19, 2024

What does the approach look like with async-retry? What do you think of the suggested API?

from failsafe.

jhalterman avatar jhalterman commented on August 19, 2024

I just pushed an approach for this. https://github.com/jhalterman/recurrent#invocation-tracking

The Invocation also makes the last failure available.

from failsafe.

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.