Top Description Fields Constructors Methods
org.springframework.http.client.reactive

public Class ReactorNetty2ClientHttpConnector

extends Object
implements ClientHttpConnector
Class Inheritance
All Implemented Interfaces
org.springframework.http.client.reactive.ClientHttpConnector
Imports
java.net.URI, java.util.concurrent.atomic.AtomicReference, java.util.function.Function, reactor.core.publisher.Mono, reactor.netty5.NettyOutbound, reactor.netty5.http.client.HttpClient, .HttpClientRequest, reactor.netty5.resources.ConnectionProvider, .LoopResources, org.springframework.http.HttpMethod, org.springframework.util.Assert

Reactor Netty 2 (Netty 5) implementation of ClientHttpConnector.

This class is based on ReactorClientHttpConnector.

Author
Violeta Georgieva
Since
6.0
See Also
HttpClient

Field Summary

Modifier and TypeField and Description
private static final Function<HttpClient, HttpClient>
private final HttpClient

Constructor Summary

AccessConstructor and Description
public
ReactorNetty2ClientHttpConnector()

Default constructor.

public
ReactorNetty2ClientHttpConnector(ReactorNetty2ResourceFactory
the resource factory to obtain the resources from
factory
,
Function<HttpClient, HttpClient>
a mapper for further initialization of the created client
mapper
)

Constructor with externally managed Reactor Netty resources, including LoopResources for event loop threads, and ConnectionProvider for the connection pool.

public
ReactorNetty2ClientHttpConnector(HttpClient
the client to use
httpClient
)

Constructor with a pre-configured HttpClient instance.

Method Summary

Modifier and TypeMethod and Description
private ReactorNetty2ClientHttpRequest
adaptRequest(HttpMethod method, URI uri, HttpClientRequest request, NettyOutbound nettyOutbound)

private static Function<HttpClient, HttpClient>
public Mono<ClientHttpResponse>
connect(HttpMethod
the HTTP request method
method
,
URI
the HTTP request URI
uri
,
Function<? super ClientHttpRequest, Mono<Void>>
a function that prepares and writes to the request, returning a publisher that signals when it's done writing. Implementations can return a Mono<Void> by calling ClientHttpRequest#writeWith or ClientHttpRequest#setComplete.
requestCallback
)

Implements org.springframework.http.client.reactive.ClientHttpConnector.connect.

Connect to the origin server using the given HttpMethod and URI and apply the given requestCallback when the HTTP request of the underlying API can be initialized and written to.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultInitializerback to summary
private static final Function<HttpClient, HttpClient> defaultInitializer
httpClientback to summary
private final HttpClient httpClient

Constructor Detail

ReactorNetty2ClientHttpConnectorback to summary
public ReactorNetty2ClientHttpConnector()

Default constructor. Initializes HttpClient via:

HttpClient.create().compress()
ReactorNetty2ClientHttpConnectorback to summary
public ReactorNetty2ClientHttpConnector(ReactorNetty2ResourceFactory factory, Function<HttpClient, HttpClient> mapper)

Constructor with externally managed Reactor Netty resources, including LoopResources for event loop threads, and ConnectionProvider for the connection pool.

This constructor should be used only when you don't want the client to participate in the Reactor Netty global resources. By default, the client participates in the Reactor Netty global resources held in reactor.netty5.http.HttpResources, which is recommended since fixed, shared resources are favored for event loop concurrency. However, consider declaring a ReactorNetty2ResourceFactory bean with globalResources=true in order to ensure the Reactor Netty global resources are shut down when the Spring ApplicationContext is closed.

Parameters
factory:ReactorNetty2ResourceFactory

the resource factory to obtain the resources from

mapper:Function<HttpClient, HttpClient>

a mapper for further initialization of the created client

Since
5.1
ReactorNetty2ClientHttpConnectorback to summary
public ReactorNetty2ClientHttpConnector(HttpClient httpClient)

Constructor with a pre-configured HttpClient instance.

Parameters
httpClient:HttpClient

the client to use

Since
5.1

Method Detail

adaptRequestback to summary
private ReactorNetty2ClientHttpRequest adaptRequest(HttpMethod method, URI uri, HttpClientRequest request, NettyOutbound nettyOutbound)
applyLoopResourcesback to summary
private static Function<HttpClient, HttpClient> applyLoopResources(ReactorNetty2ResourceFactory factory)
connectback to summary
public Mono<ClientHttpResponse> connect(HttpMethod method, URI uri, Function<? super ClientHttpRequest, Mono<Void>> requestCallback)

Implements org.springframework.http.client.reactive.ClientHttpConnector.connect.

Doc from org.springframework.http.client.reactive.ClientHttpConnector.connect.

Connect to the origin server using the given HttpMethod and URI and apply the given requestCallback when the HTTP request of the underlying API can be initialized and written to.

Parameters
method:HttpMethod

the HTTP request method

uri:URI

the HTTP request URI

requestCallback:Function<? super ClientHttpRequest, Mono<Void>>

a function that prepares and writes to the request, returning a publisher that signals when it's done writing. Implementations can return a Mono<Void> by calling ClientHttpRequest#writeWith or ClientHttpRequest#setComplete.

Returns:Mono<ClientHttpResponse>

publisher for the ClientHttpResponse

Annotations
@Override