Skip to content

Commit

Permalink
Allow to configure retry policy on a per-task basis // add javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
nishiol committed Jan 29, 2025
1 parent eb1538a commit dc9833d
Showing 1 changed file with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,30 @@

import java.time.Duration;

/**
* Defines a custom retry policy for tasks scheduled in the {@link TransactionOutbox}.
* <p>
* Implement this interface in the class that is passed to
* {@link TransactionOutbox#schedule(Class)} to override the default retry behavior.
* </p>
*/
public interface RetryPolicyAware {
/**
* Determines the wait duration before retrying a failed task.
*
* @param attempt The current retry attempt (starting from 1).
* @param throwable The exception that caused the failure.
* @return The duration to wait before the next retry.
*/
Duration waitDuration(int attempt, Throwable throwable);

/**
* Specifies the maximum number of retry attempts before blocking the task.
*
* @param attempt The current retry attempt (starting from 1).
* @param throwable The exception that caused the failure.
* @return The number of attempts after which the task should be blocked.
* If the returned value is less than or equal to {@code attempt}, the task is blocked immediately.
*/
int blockAfterAttempts(int attempt, Throwable throwable);
}

0 comments on commit dc9833d

Please sign in to comment.