Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to resume back-off try at numOfAttempts that want to configure #2158

Open
trunghoangminh opened this issue May 11, 2024 · 1 comment
Open

Comments

@trunghoangminh
Copy link

trunghoangminh commented May 11, 2024

Resilience4j version:
2.2.0
Java version:
OpenJDK 17.0.6
My application configures back-off retry as below:

long maxAttempts = 9999;
long initInterval = 5; // second
double multiplier = 1.1;
long maxInterval = 30; // second

Assume that my application will run into maxAttempts times.
Here is the scenario: My application runs on retry 10 times then my application is restarted. Assume that all configurations are saved into the database before restarting. So, when the application is started again the configurations are loaded into the back-off retry config. There is any way to make the back-off retry function continue on the 11th with the wait duration at the 11th(already ran 10 times as before) instead of beginning at the 1st
Here is the library code, the wait duration time based on numOfAttempts(ContextImpl):

        private void waitIntervalAfterRuntimeException(int currentNumOfAttempts, Either<Throwable, T> either) {
            // wait interval until the next attempt should start
            long interval = intervalBiFunction.apply(numOfAttempts.get(), either);

            if (interval < 0) {
                publishRetryEvent(() -> new RetryOnErrorEvent(getName(), currentNumOfAttempts, either.swap().getOrNull()));
            } else {
                publishRetryEvent(() -> new RetryOnRetryEvent(getName(), currentNumOfAttempts, either.swap().getOrNull(), interval));
            }

            try {
                sleepFunction.accept(interval);
            } catch (Throwable ex) {
                throw lastRuntimeException.get();
            }
        }

Hope that your side can help me on this.

@RobWin
Copy link
Member

RobWin commented Jun 6, 2024

Hi,
unfortunately there is currently no way to boostrap the state of the Resilience4j components from a DB.
Would be a nice new feature, if you want to contribute it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants