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.x
and1.x
series. - The main highlight of Mutiny 2 is that it is now based on top of the
java.util.concurrent.Flow
APIs instead of the legacy Reactive Streams APIs. - The
Flow
APIs 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
Flow
variant of the Reactive Streams TCK. - Deprecated APIs in Mutiny
1.x
have been removed, and experimental APIs have been promoted.
Impact of the switch from legacy Reactive Streams APIs to JDK Flow#
- The
Flow
types are isomorphic to the legacy Reactive Streams API types. - We recommend that you migrate to
Flow
in 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
Flow
and legacy Reactive Streams types.
General guidelines#
- If your code only uses
Uni
andMulti
(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
Multi
as aorg.reactivestreams.Publisher
then you will either need an adapter (see below) or migrate tojava.util.concurrent.Flow.Publisher
. - If you interact with
org.reactivestreams.Publisher
publishers 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
AdaptersToFlow
to convert from Reactive Streams types toFlow
types, and - Use
AdaptersToReactiveStreams
to convertFlow
types to Reactive Streams types.
- The Maven coordinates are
- The Mutiny Zero adapters have virtually zero overhead.
Other API changes#
Deprecated API removals#
Uni
andMulti
onSubscribe()
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#
Uni
andMulti
subscription-bound contexts.Uni.join()
publisher..ifNoItem()
timeout operators.Uni
andMulti
spies.capDemandsUsing()
andpaceDemand()
request management operators.Multi
replay()
operator.