Code Monkey home page Code Monkey logo

Comments (4)

jhalterman avatar jhalterman commented on May 20, 2024

Your listener should only get called if doAnything throws an exception. I just pushed a test to verify this behavior and things seem to be working as expected. Two things to note:

The current API in master is a bit different than from the last release. The listener now accepts a result and a failure since failure could indicate an exception being thrown or a bad result being returned. That said, the listener is called as expected in the test.

Let me know what you think.

from failsafe.

Haardt avatar Haardt commented on May 20, 2024

I assumed that a exceeded retry policy would trigger the failure event. I use your library on a udp protocol, since there is not always a result. My solution at the moment is that I check the result to be present. If there no result, it must be a timeout. A "retryExceeded"-Handler would be nice.

Thank you!

from failsafe.

jhalterman avatar jhalterman commented on May 20, 2024

@Haardt I know this is an old issue, but I wanted to dig it back up again to make sure I understand your use case. Basically, you'd like your failure handler to be called if retries are exceeded and some unexpected result occurred? The unexpected result bit is important because that's how Recurrent knows to keep trying. Maybe an example policy:

retryPolicy = new RetryPolicy()
         .withDelay(100, TimeUnit.MILLISECONDS)
         .withMaxDuration(2, TimeUnit.SECONDS)
         .withMaxRetries(3)
         .whenResult(null);

This would perform retries so long as the result is null and the whenFailure handler would be called if a non-null result is never returned. Does this work for you?

from failsafe.

jhalterman avatar jhalterman commented on May 20, 2024

Also - See the new event listeners API that allows you to listen specifically for onCompleted, onFailed, etc. events:

https://github.com/jhalterman/recurrent#event-listeners

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.