Micronaut Reactor

Integration between Micronaut and Reactor

Version: 3.6.0

1 Introduction

Micronaut Reactor adds support for Project Reactor to a Micronaut 2.x application. If you are using Micronaut 1.x you do not need this module.

  • Converters for Reactor types so that Reactor types can be used in controllers and clients

  • Instrumentation for Reactor types so that tracing works with Reactor types

  • A version of the Http client that supports Reactor

2 Release History

For this project, you can find a list of releases (with release notes) here:

3 Breaking Changes

3.0.0

Reactor Http Client

The Reactor Http client has changed to return Mono<HttpResponse<O>> instead of Flux<HttpResponse<O>>. This is semantically more correct as there can only be a single response per request.

4 Quick Start

Add the following dependency to your Micronaut application:

implementation("io.micronaut.reactor:micronaut-reactor")
<dependency>
    <groupId>io.micronaut.reactor</groupId>
    <artifactId>micronaut-reactor</artifactId>
</dependency>

To use the HTTP client add the following dependency:

implementation("io.micronaut.reactor:micronaut-reactor-http-client")
<dependency>
    <groupId>io.micronaut.reactor</groupId>
    <artifactId>micronaut-reactor-http-client</artifactId>
</dependency>

To use the Reactor variation of the Micronaut HTTP client inject the ReactorHttpClient interface (or one the other variants). For example:

import io.micronaut.reactor.http.client.*;

@Inject ReactorHttpClient httpClient; // regular client
@Inject ReactorSseClient sseClient; // server sent events
@Inject ReactorStreamingHttpClient streamingClient; // streaming

5 Reactor context propagation

When using Micronaut Reactor within a reactive chain, add the following dependency to handle the Reactor Context Propagation.

implementation("io.micrometer:context-propagation")
<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>context-propagation</artifactId>
</dependency>

6 Repository

You can find the source code of this project in this repository: