Package org.axonframework.messaging.core
Class FluxUtils
java.lang.Object
org.axonframework.messaging.core.FluxUtils
Utility methods to work with Project Reactor's
fluxes.- Since:
- 5.0.0
- Author:
- John Hendrikx
-
Method Summary
Modifier and TypeMethodDescriptionstatic <M extends Message>
MessageStream<M> asMessageStream(reactor.core.publisher.Flux<M> flux) Create a stream that provides theMessagesreturned by the givenflux, automatically wrapped in anMessageStream.Entry.static <M extends Message>
MessageStream<M> asMessageStream(reactor.core.publisher.Flux<M> flux, Function<M, Context> contextSupplier) Create a stream that provides theMessagesreturned by the givenflux, automatically wrapped in anMessageStream.Entrywith the resultingContextfrom thecontextSupplier.static <M extends Message>
reactor.core.publisher.Flux<MessageStream.Entry<M>> of(MessageStream<M> source) Creates a Flux containing theentriesprovided by the givensource.static <M extends Message>
org.reactivestreams.Publisher<M> streamToPublisher(Supplier<MessageStream<M>> stream)
-
Method Details
-
of
public static <M extends Message> reactor.core.publisher.Flux<MessageStream.Entry<M>> of(@Nonnull MessageStream<M> source) Creates a Flux containing theentriesprovided by the givensource. Note that multiple invocations of this method on the samesource, or otherwise any components consuming entries from the givensourcewill cause entries to be consumed by only one of the fluxes or competing consumers.- Type Parameters:
M- The type of Message returned by the source.- Parameters:
source- The MessageStream providing the elements.- Returns:
- A Flux with the elements provided by the source.
-
asMessageStream
public static <M extends Message> MessageStream<M> asMessageStream(@Nonnull reactor.core.publisher.Flux<M> flux) Create a stream that provides theMessagesreturned by the givenflux, automatically wrapped in anMessageStream.Entry. -
asMessageStream
public static <M extends Message> MessageStream<M> asMessageStream(@Nonnull reactor.core.publisher.Flux<M> flux, @Nonnull Function<M, Context> contextSupplier) Create a stream that provides theMessagesreturned by the givenflux, automatically wrapped in anMessageStream.Entrywith the resultingContextfrom thecontextSupplier.- Type Parameters:
M- The type ofMessagecontained in theentriesof this stream.- Parameters:
flux- TheFluxproviding theMessagesto stream.contextSupplier- AFunctioningesting eachMessagefrom the givenfluxreturning theContextto set for theMessageStream.EntrytheMessageis wrapped in.- Returns:
- A stream of
entriesthat returns theMessagesprovided by the givenfluxwith aContextprovided by thecontextSupplier.
-
streamToPublisher
public static <M extends Message> org.reactivestreams.Publisher<M> streamToPublisher(Supplier<MessageStream<M>> stream) Converts aSupplierofMessageStreaminto a reactor-corePublisher. The providedstreamwill supply theMessageStream, and its entries will be transformed into a reactive stream of messages.- Type Parameters:
M- The type ofMessagecontained in theMessageStream.- Parameters:
stream- ASupplierthat provides aMessageStreamof messages to be published as a reactive stream.- Returns:
- A
Publisheremitting the messages from the providedMessageStream.
-