Record Class RetryPolicy
java.lang.Object
java.lang.Record
io.axoniq.framework.workflow.dsl.api.retry.RetryPolicy
- Record Components:
maxRetries- maximum number of retry attempts.onRetryHandler- handler invoked before each retry event is published.backoffStrategy- backoff strategy between retry attempts.retryPredicate- predicate evaluated on each retry; returnstrueto continue retrying,falseto stop. Checked in addition tomaxRetries.
public record RetryPolicy(int maxRetries, RetryHandler onRetryHandler, BackoffStrategy backoffStrategy, Predicate<RetryContext> retryPredicate)
extends Record
Retry policy for execute steps.
maxRetries is the number of retry attempts (not counting the initial
attempt). maxRetries=3 means up to 4 total executions.- Since:
- 5.4.0
- Author:
- Stefan Dragisic
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final RetryPolicyConstant retry policy that disables retries entirely. -
Constructor Summary
ConstructorsConstructorDescriptionRetryPolicy(int maxRetries, RetryHandler onRetryHandler) Creates a retry policy with explicit retry count and retry hook, using no backoff.RetryPolicy(int maxRetries, RetryHandler onRetryHandler, BackoffStrategy backoffStrategy) Creates a retry policy with explicit retry count, retry hook, and backoff strategy.RetryPolicy(int maxRetries, RetryHandler onRetryHandler, BackoffStrategy backoffStrategy, Predicate<RetryContext> retryPredicate) Creates an instance of aRetryPolicyrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thebackoffStrategyrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intReturns the value of themaxRetriesrecord component.static RetryPolicymaxRetries(int maxRetries) Creates a retry policy with the provided retry count and no-op retry handling.onRetry(RetryHandler handler) Returns a copy of this retry policy with the provided retry handler.Returns the value of theonRetryHandlerrecord component.Returns the value of theretryPredicaterecord component.retryWhile(Predicate<RetryContext> predicate) Returns a copy of this retry policy with the provided retry predicate.booleanshouldRetry(RetryContext context) Evaluates whether the supplied retry context permits another retry attempt.final StringtoString()Returns a string representation of this record class.withBackoff(BackoffStrategy strategy) Returns a copy of this retry policy with the provided backoff strategy.
-
Field Details
-
NONE
Constant retry policy that disables retries entirely.
-
-
Constructor Details
-
RetryPolicy
Creates a retry policy with explicit retry count, retry hook, and backoff strategy.- Parameters:
maxRetries- maximum number of retry attemptsonRetryHandler- handler invoked before each retry event is publishedbackoffStrategy- backoff strategy between retry attempts
-
RetryPolicy
Creates a retry policy with explicit retry count and retry hook, using no backoff.- Parameters:
maxRetries- maximum number of retry attemptsonRetryHandler- handler invoked before each retry event is published
-
RetryPolicy
public RetryPolicy(int maxRetries, RetryHandler onRetryHandler, BackoffStrategy backoffStrategy, Predicate<RetryContext> retryPredicate) Creates an instance of aRetryPolicyrecord class.- Parameters:
maxRetries- the value for themaxRetriesrecord componentonRetryHandler- the value for theonRetryHandlerrecord componentbackoffStrategy- the value for thebackoffStrategyrecord componentretryPredicate- the value for theretryPredicaterecord component
-
-
Method Details
-
maxRetries
Creates a retry policy with the provided retry count and no-op retry handling.- Parameters:
maxRetries- maximum number of retry attempts- Returns:
- retry policy with the provided retry count
-
onRetry
Returns a copy of this retry policy with the provided retry handler.- Parameters:
handler- handler invoked before each retry event is published- Returns:
- copied retry policy with updated retry handler
-
withBackoff
Returns a copy of this retry policy with the provided backoff strategy.- Parameters:
strategy- backoff strategy between retry attempts- Returns:
- copied retry policy with updated backoff strategy
-
retryWhile
Returns a copy of this retry policy with the provided retry predicate.- Parameters:
predicate- predicate controlling whether retrying may continue- Returns:
- copied retry policy with updated retry predicate
-
shouldRetry
Evaluates whether the supplied retry context permits another retry attempt.- Parameters:
context- retry context for the current failure- Returns:
truewhen retrying should continue, otherwisefalse
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
maxRetries
public int maxRetries()Returns the value of themaxRetriesrecord component.- Returns:
- the value of the
maxRetriesrecord component
-
onRetryHandler
Returns the value of theonRetryHandlerrecord component.- Returns:
- the value of the
onRetryHandlerrecord component
-
backoffStrategy
Returns the value of thebackoffStrategyrecord component.- Returns:
- the value of the
backoffStrategyrecord component
-
retryPredicate
Returns the value of theretryPredicaterecord component.- Returns:
- the value of the
retryPredicaterecord component
-