Class ReactorClientHttpConnector
- All Implemented Interfaces:
- Lifecycle, Phased, SmartLifecycle, ClientHttpConnector
ClientHttpConnector.
This class implements SmartLifecycle and can be optionally declared
as a Spring-managed bean.
- Since:
- 5.0
- Author:
- Brian Clozel, Rossen Stoyanchev, Sebastien Deleuze, Juergen Hoeller
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionChannel attribute key under whichWebClientrequest attributes are stored as a Map.Fields inherited from interface SmartLifecycleDEFAULT_PHASE
- 
Constructor SummaryConstructorsConstructorDescriptionDefault constructor.ReactorClientHttpConnector(ReactorResourceFactory resourceFactory, Function<reactor.netty.http.client.HttpClient, reactor.netty.http.client.HttpClient> mapper) Constructor with externally managed Reactor Netty resources, includingLoopResourcesfor event loop threads, andConnectionProviderfor the connection pool.ReactorClientHttpConnector(reactor.netty.http.client.HttpClient httpClient) Constructor with a pre-configuredHttpClientinstance.
- 
Method SummaryModifier and TypeMethodDescriptionreactor.core.publisher.Mono<ClientHttpResponse> connect(HttpMethod method, URI uri, Function<? super ClientHttpRequest, reactor.core.publisher.Mono<Void>> requestCallback) Connect to the origin server using the givenHttpMethodandURIand apply the givenrequestCallbackwhen the HTTP request of the underlying API can be initialized and written to.intgetPhase()Return the phase that this lifecycle object is supposed to run in.booleanCheck whether this component is currently running.voidstart()Start this component.voidstop()Stop this component, typically in a synchronous fashion, such that the component is fully stopped upon return of this method.Methods inherited from class Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface SmartLifecycleisAutoStartup, isPauseable, stop
- 
Field Details- 
ATTRIBUTES_KEY
 
- 
- 
Constructor Details- 
ReactorClientHttpConnectorpublic ReactorClientHttpConnector()Default constructor. InitializesHttpClientvia:HttpClient.create().compress(true) 
- 
ReactorClientHttpConnectorpublic ReactorClientHttpConnector(reactor.netty.http.client.HttpClient httpClient) Constructor with a pre-configuredHttpClientinstance.- Parameters:
- httpClient- the client to use
- Since:
- 5.1
 
- 
ReactorClientHttpConnectorpublic ReactorClientHttpConnector(ReactorResourceFactory resourceFactory, Function<reactor.netty.http.client.HttpClient, reactor.netty.http.client.HttpClient> mapper) Constructor with externally managed Reactor Netty resources, includingLoopResourcesfor event loop threads, andConnectionProviderfor 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 HttpResources, which is recommended since fixed, shared resources are favored for event loop concurrency. However, consider declaring aReactorResourceFactorybean withglobalResources=truein order to ensure the Reactor Netty global resources are shut down when the Spring ApplicationContext is stopped or closed and restarted properly when the Spring ApplicationContext is (with JVM Checkpoint Restore for example).- Parameters:
- resourceFactory- the resource factory to obtain the resources from
- mapper- a mapper for further initialization of the created client
- Since:
- 5.1
 
 
- 
- 
Method Details- 
connectpublic reactor.core.publisher.Mono<ClientHttpResponse> connect(HttpMethod method, URI uri, Function<? super ClientHttpRequest, reactor.core.publisher.Mono<Void>> requestCallback) Description copied from interface:ClientHttpConnectorConnect to the origin server using the givenHttpMethodandURIand apply the givenrequestCallbackwhen the HTTP request of the underlying API can be initialized and written to.- Specified by:
- connectin interface- ClientHttpConnector
- Parameters:
- method- the HTTP request method
- uri- the HTTP request URI
- requestCallback- 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- ReactiveHttpOutputMessage.writeWith(Publisher)or- ReactiveHttpOutputMessage.setComplete().
- Returns:
- publisher for the ClientHttpResponse
 
- 
startpublic void start()Description copied from interface:LifecycleStart this component.Should not throw an exception if the component is already running. In the case of a container, this will propagate a hard start signal to all components that apply, even to non-auto-startup components. 
- 
stoppublic void stop()Description copied from interface:LifecycleStop this component, typically in a synchronous fashion, such that the component is fully stopped upon return of this method. Consider implementingSmartLifecycleand itsstop(Runnable)variant when asynchronous stop behavior is necessary.Note that this stop notification is not guaranteed to come before destruction: On regular shutdown, Lifecyclebeans will first receive a stop notification before the general destruction callbacks are being propagated; however, on hot refresh during a context's lifetime or on aborted refresh attempts, a given bean's destroy method will be called without any consideration of stop signals upfront.Should not throw an exception if the component is not running (not started yet). In the case of a container, this will propagate the stop signal to all components that apply. 
- 
isRunningpublic boolean isRunning()Description copied from interface:LifecycleCheck whether this component is currently running.In the case of a container, this will return trueonly if all components that apply are currently running.
- 
getPhasepublic int getPhase()Description copied from interface:SmartLifecycleReturn the phase that this lifecycle object is supposed to run in.The default implementation returns SmartLifecycle.DEFAULT_PHASEin order to letstop()callbacks execute before regularLifecycleimplementations.- Specified by:
- getPhasein interface- Phased
- Specified by:
- getPhasein interface- SmartLifecycle
- See Also:
 
 
-