- java.lang.Object
-
- io.smallrye.mutiny.groups.MultiBroadcast<T>
-
- Type Parameters:
T- the type of item
public class MultiBroadcast<T> extends java.lang.ObjectMakes the upstreamMultibe able to broadcast its events (items,failure, andcompletion) to multiple subscribers.Broadcast transforms the upstream into a hot streams meaning that late subscriber won't see all the events.
-
-
Constructor Summary
Constructors Constructor Description MultiBroadcast(Multi<T> upstream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Multi<T>toAllSubscribers()Broadcasts the events of the upstreamMultito all the subscribers.Multi<T>toAtLeast(int numberOfSubscribers)Broadcasts the events of the upstreamMultito several subscribers.MultiBroadcast<T>withCancellationAfterLastSubscriberDeparture()Indicates that the subscription to the upstreamMultiis cancelled once all the subscribers have cancelled their subscription.MultiBroadcast<T>withCancellationAfterLastSubscriberDeparture(java.time.Duration delay)Indicates that the subscription to the upstreamMultiis cancelled once all the subscribers have cancelled their subscription.
-
-
-
Method Detail
-
toAllSubscribers
@CheckReturnValue public Multi<T> toAllSubscribers()
Broadcasts the events of the upstreamMultito all the subscribers. Subscribers start receiving the events as soon as they subscribe.- Returns:
- the
Multiaccepting several subscribers
-
toAtLeast
@CheckReturnValue public Multi<T> toAtLeast(int numberOfSubscribers)
Broadcasts the events of the upstreamMultito several subscribers. Subscribers start receiving the events when at leastnumberOfSubscriberssubscribes to the producedMulti.- Parameters:
numberOfSubscribers- the number of subscriber requires before subscribing to the upstream multi and start dispatching the events. Must be strictly positive.- Returns:
- the
Multiaccepting several subscribers
-
withCancellationAfterLastSubscriberDeparture
@CheckReturnValue public MultiBroadcast<T> withCancellationAfterLastSubscriberDeparture()
Indicates that the subscription to the upstreamMultiis cancelled once all the subscribers have cancelled their subscription.- Returns:
- this
MultiBroadcast.
-
withCancellationAfterLastSubscriberDeparture
@CheckReturnValue public MultiBroadcast<T> withCancellationAfterLastSubscriberDeparture(java.time.Duration delay)
Indicates that the subscription to the upstreamMultiis cancelled once all the subscribers have cancelled their subscription. Before cancelling it wait for a grace period ofdelay. If any subscriber subscribes during this period, the cancellation will not happen.- Parameters:
delay- the delay, must not benull, must be positive- Returns:
- this
MultiBroadcast.
-
-