Skip to content

Commit dc9833d

Browse files
committed
Allow to configure retry policy on a per-task basis // add javadoc
1 parent eb1538a commit dc9833d

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

transactionoutbox-core/src/main/java/com/gruelbox/transactionoutbox/RetryPolicyAware.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,30 @@
22

33
import java.time.Duration;
44

5+
/**
6+
* Defines a custom retry policy for tasks scheduled in the {@link TransactionOutbox}.
7+
* <p>
8+
* Implement this interface in the class that is passed to
9+
* {@link TransactionOutbox#schedule(Class)} to override the default retry behavior.
10+
* </p>
11+
*/
512
public interface RetryPolicyAware {
13+
/**
14+
* Determines the wait duration before retrying a failed task.
15+
*
16+
* @param attempt The current retry attempt (starting from 1).
17+
* @param throwable The exception that caused the failure.
18+
* @return The duration to wait before the next retry.
19+
*/
620
Duration waitDuration(int attempt, Throwable throwable);
721

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

0 commit comments

Comments
 (0)