Class BackoffPolicy
java.lang.Object
org.apache.pulsar.client.api.v5.config.BackoffPolicy
Backoff configuration for broker reconnection attempts.
The base delay for attempt n is min(initialInterval * multiplier^(n-1), maxInterval).
A symmetric random jitter of ±jitterPercent/2 is applied to each delay (including the
first one) to spread out concurrent retries.
Use fixed(Duration, Duration) or exponential(Duration, Duration) for
the common cases, or builder() to configure all knobs explicitly.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleDefault jitter percentage applied when not explicitly specified. -
Method Summary
Modifier and TypeMethodDescriptionstatic BackoffPolicy.Builderbuilder()static BackoffPolicyexponential(Duration initialInterval, Duration maxInterval) Create an exponential backoff with the given bounds, a default multiplier of 2 and the default jitter.static BackoffPolicyCreate a fixed backoff (no increase between retries) with the default jitter.doubledouble
-
Field Details
-
DEFAULT_JITTER_PERCENT
public static final double DEFAULT_JITTER_PERCENTDefault jitter percentage applied when not explicitly specified.- See Also:
-
-
Method Details
-
initialInterval
- Returns:
- the base delay before the first reconnection attempt
-
maxInterval
- Returns:
- the maximum delay between reconnection attempts
-
multiplier
public double multiplier()- Returns:
- the multiplier applied after each attempt
-
jitterPercent
public double jitterPercent()- Returns:
- the symmetric jitter percentage applied to each delay;
0means no jitter
-
fixed
Create a fixed backoff (no increase between retries) with the default jitter.- Parameters:
initialInterval- the constant base delay between reconnection attemptsmaxInterval- the maximum delay between reconnection attempts- Returns:
- a
BackoffPolicywith a multiplier of 1.0 and the default jitter
-
exponential
Create an exponential backoff with the given bounds, a default multiplier of 2 and the default jitter.- Parameters:
initialInterval- the base delay before the first reconnection attemptmaxInterval- the maximum delay between reconnection attempts- Returns:
- a
BackoffPolicywith a multiplier of 2.0 and the default jitter
-
builder
- Returns:
- a new builder for constructing a
BackoffPolicy
-