Eclipse Vert.x is the leading toolkit for writing reactive applications on the JVM.
While the Vert.x core APIs expose asynchronous programming through callbacks and promise / future, code generators offer bindings to other asynchronous programming models, including: Kotlin coroutines, and RxJava 1, 2 and 3.
This project offers Vert.x binding for Mutiny, an intuitive event-driven reactive programming library for Java.
Getting the bindings
The bindings can be accessed from the following Maven coordinates:
MODULErefers to a Vert.x module, such as
The Mutiny bindings are modular
If you are familiar with other Vert.x bindings such as those for RxJava then you need to be aware that the Mutiny bindings are offered on a per-module basis.
For instance the RxJava 3 bindings are exposed through the
io.vertx:vertx-rx-java3 dependency, and that
vertx-rx-java3 has optional dependencies on the whole Vert.x stack.
We think that it is cleaner to offer bindings on a per-module basis, so your project does not have optional dependencies on modules of the Vert.x stack that you don't consume.
The full list of supported modules from the Vert.x stack is available at https://github.com/smallrye/smallrye-mutiny-vertx-bindings/tree/main/vertx-mutiny-clients
A short example
The following self-contained JBang script shows some of the features of the Vert.x Mutiny bindings (see the highlights):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
This script can be run with
jbang run hello.java, and exposes a HTTP server on port 8080:
$ ./hello.java [jbang] Building jar... Deployment Starting See http://127.0.0.1:8080 Deployment completed
The HTTP server responds to any HTTP request with the current value of a counter that is incremented every 2 seconds:
$ http :8080 HTTP/1.1 200 OK content-length: 2 @1 $ http :8080 HTTP/1.1 200 OK content-length: 2 @2
The deployed verticle uses the Mutiny API, where the
start(Promise<Void>) method is replaced by
asyncStart() method that returns a
The code also shows how to convert Vert.x streams into Mutiny
Multi streams, and how to await for the verticle deployment to complete.