Package io.smallrye.mutiny.groups
Class MultiRetry<T>
- java.lang.Object
-
- io.smallrye.mutiny.groups.MultiRetry<T>
-
public class MultiRetry<T> extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description MultiRetry(Multi<T> upstream, java.util.function.Predicate<? super java.lang.Throwable> onFailurePredicate)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Multi<T>
atMost(long numberOfAttempts)
Multi<T>
expireAt(long expireAt)
Multi<T>
expireIn(long expireIn)
Multi<T>
indefinitely()
Multi<T>
until(java.util.function.Predicate<? super java.lang.Throwable> predicate)
Multi<T>
when(java.util.function.Function<Multi<java.lang.Throwable>,? extends org.reactivestreams.Publisher<?>> whenStreamFactory)
MultiRetry<T>
withBackOff(java.time.Duration initialBackOff)
Configures a back-off delay between to attempt to re-subscribe.MultiRetry<T>
withBackOff(java.time.Duration initialBackOff, java.time.Duration maxBackOff)
Configures a back-off delay between to attempt to re-subscribe.MultiRetry<T>
withJitter(double jitter)
Configures the random factor when using back-off.
-
-
-
Method Detail
-
indefinitely
@CheckReturnValue public Multi<T> indefinitely()
Produces aMulti
resubscribing to the currentMulti
until it gets a items followed by a completion events.On every failure, it re-subscribes, indefinitely.
- Returns:
- the
Multi
-
expireAt
@CheckReturnValue public Multi<T> expireAt(long expireAt)
Produces aMulti
resubscribing to the currentMulti
untilexpireAt
time or until it gets items followed by the completion event. On every failure, it re-subscribes.If expiration time is passed, the last failure is propagated. Backoff must be configured.
- Parameters:
expireAt
- absolute time in millis that specifies when to give up- Returns:
- a new
Multi
retrying to subscribe to the currentMulti
until it gets an item or until expirationexpireAt
. When the expiration is reached, the last failure is propagated. - Throws:
java.lang.IllegalArgumentException
- if back off not configured,
-
expireIn
@CheckReturnValue public Multi<T> expireIn(long expireIn)
Produces aMulti
resubscribing to the currentMulti
untilexpireIn
time or until it gets items followed by the completion event. On every failure, it re-subscribes.If expiration time is passed, the last failure is propagated. Backoff must be configured.
- Parameters:
expireIn
- relative time in millis that specifies when to give up- Returns:
- a new
Multi
retrying to subscribe to the currentMulti
until it gets an item or until expirationexpireIn
. When the expiration is reached, the last failure is propagated. - Throws:
java.lang.IllegalArgumentException
- if back off not configured,
-
until
@CheckReturnValue public Multi<T> until(java.util.function.Predicate<? super java.lang.Throwable> predicate)
Produces aMulti
resubscribing to the currentMulti
until the given predicate returnsfalse
. The predicate is called with the failure emitted by the currentMulti
.- Parameters:
predicate
- the predicate that determines if a re-subscription may happen in case of a specific failure, must not benull
. If the predicate returnstrue
for the given failure, a re-subscription is attempted.- Returns:
- the new
Multi
instance
-
when
@CheckReturnValue public Multi<T> when(java.util.function.Function<Multi<java.lang.Throwable>,? extends org.reactivestreams.Publisher<?>> whenStreamFactory)
Produces aMulti
resubscribing to the currentMulti
when thePublisher
produced by the given method emits an item. AsatMost(long)
, on every failure, it re-subscribes. However, a delay is introduced before re-subscribing. The re-subscription happens when the produced streams emits an item. If this stream fails, the downstream gets a failure. It the streams completes, the downstream completes.
-
withBackOff
@CheckReturnValue public MultiRetry<T> withBackOff(java.time.Duration initialBackOff)
Configures a back-off delay between to attempt to re-subscribe. A random factor (jitter) is applied to increase the delay when several failures happen.- Parameters:
initialBackOff
- the initial back-off duration, must not benull
, must not be negative.- Returns:
- this object to configure the retry policy.
-
withBackOff
@CheckReturnValue public MultiRetry<T> withBackOff(java.time.Duration initialBackOff, java.time.Duration maxBackOff)
Configures a back-off delay between to attempt to re-subscribe. A random factor (jitter) is applied to increase he delay when several failures happen. The max delays ismaxBackOff
.- Parameters:
initialBackOff
- the initial back-off duration, must not benull
, must not be negative.maxBackOff
- the max back-off duration, must not benull
, must not be negative.- Returns:
- this object to configure the retry policy.
-
withJitter
@CheckReturnValue public MultiRetry<T> withJitter(double jitter)
Configures the random factor when using back-off. By default, it's set to 0.5.- Parameters:
jitter
- the jitter. Must be in [0.0, 1.0]- Returns:
- this object to configure the retry policy.
-
-