Migrating to Mutiny 2#
The upgrade is transparent for most code bases that use Mutiny in applications (e.g., Quarkus applications).
Highlights#
- Mutiny 2 is a major release with source and binary incompatible changes to the Mutiny
0.xand1.xseries. - The main highlight of Mutiny 2 is that it is now based on top of the
java.util.concurrent.FlowAPIs instead of the legacy Reactive Streams APIs. - The
FlowAPIs have been part of the JDK since Java 9, and they are the modern Reactive Streams APIs. - Mutiny remains a faithful implementation of the Reactive Streams specification and passes the
Flowvariant of the Reactive Streams TCK. - Deprecated APIs in Mutiny
1.xhave been removed, and experimental APIs have been promoted.
Impact of the switch from legacy Reactive Streams APIs to JDK Flow#
- The
Flowtypes are isomorphic to the legacy Reactive Streams API types. - We recommend that you migrate to
Flowin your own code bases. - You should encourage third-party libraries to migrate to
Flow. - You can always use adapters to go back and forth between
Flowand legacy Reactive Streams types.
General guidelines#
- If your code only uses
UniandMulti(i.e., notorg.reactivestreams.Publisher), then you will be source-compatible with Mutiny 2. You should still recompile and check that your test suites pass. - If you expose
Multias aorg.reactivestreams.Publisherthen you will either need an adapter (see below) or migrate tojava.util.concurrent.Flow.Publisher. - If you interact with
org.reactivestreams.Publisherpublishers and you can’t migrate them tojava.util.concurrent.Flow.Publisher(e.g., because it is a third-party library), then you will need an adapter. Please encourage third-party libraries to migrate toFlow.
Adapters between Flow and legacy Reactive Streams APIs#
- We recommend using the adapters from the Mutiny Zero project.
- The Maven coordinates are
groupId: io.smallrye.reactive,artifactId: mutiny-zero-flow-adapters - Use
AdaptersToFlowto convert from Reactive Streams types toFlowtypes, and - Use
AdaptersToReactiveStreamsto convertFlowtypes to Reactive Streams types.
- The Maven coordinates are
- The Mutiny Zero adapters have virtually zero overhead.
Other API changes#
Deprecated API removals#
UniandMultionSubscribe()group is nowonSubscription().AssertSubscriber.await()has been replaced by event-specific methods (items, failure, completion, etc).- The RxJava 2 integration module has been discarded (only RxJava 3 is now supported).
Experimental API promotions#
UniandMultisubscription-bound contexts.Uni.join()publisher..ifNoItem()timeout operators.UniandMultispies.capDemandsUsing()andpaceDemand()request management operators.Multireplay()operator.