Package io.smallrye.mutiny.groups
Class MultiBroadcast<T>
- java.lang.Object
-
- io.smallrye.mutiny.groups.MultiBroadcast<T>
-
- Type Parameters:
T
- the type of item
public class MultiBroadcast<T> extends java.lang.Object
Makes the upstreamMulti
be 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 upstreamMulti
to all the subscribers.Multi<T>
toAtLeast(int numberOfSubscribers)
Broadcasts the events of the upstreamMulti
to several subscribers.MultiBroadcast<T>
withCancellationAfterLastSubscriberDeparture()
Indicates that the subscription to the upstreamMulti
is cancelled once all the subscribers have cancelled their subscription.MultiBroadcast<T>
withCancellationAfterLastSubscriberDeparture(java.time.Duration delay)
Indicates that the subscription to the upstreamMulti
is cancelled once all the subscribers have cancelled their subscription.
-
-
-
Method Detail
-
toAllSubscribers
public Multi<T> toAllSubscribers()
Broadcasts the events of the upstreamMulti
to all the subscribers. Subscribers start receiving the events as soon as they subscribe.- Returns:
- the
Multi
accepting several subscribers
-
toAtLeast
public Multi<T> toAtLeast(int numberOfSubscribers)
Broadcasts the events of the upstreamMulti
to several subscribers. Subscribers start receiving the events when at leastnumberOfSubscribers
subscribes 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
Multi
accepting several subscribers
-
withCancellationAfterLastSubscriberDeparture
public MultiBroadcast<T> withCancellationAfterLastSubscriberDeparture()
Indicates that the subscription to the upstreamMulti
is cancelled once all the subscribers have cancelled their subscription.- Returns:
- this
MultiBroadcast
.
-
withCancellationAfterLastSubscriberDeparture
public MultiBroadcast<T> withCancellationAfterLastSubscriberDeparture(java.time.Duration delay)
Indicates that the subscription to the upstreamMulti
is 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
.
-
-