Class ReactorNettyClientRequestFactory
- All Implemented Interfaces:
- Lifecycle,- Phased,- SmartLifecycle,- ClientHttpRequestFactory
ClientHttpRequestFactory.
 This class implements SmartLifecycle and can be optionally declared
 as a Spring-managed bean in order to support JVM Checkpoint Restore.
- Since:
- 6.1
- Author:
- Arjen Poutsma, Sebastien Deleuze
- 
Field SummaryFields inherited from interface org.springframework.context.SmartLifecycleDEFAULT_PHASE
- 
Constructor SummaryConstructorsConstructorDescriptionCreate a new instance of theReactorNettyClientRequestFactorywith a defaultHttpClientthat has compression enabled.ReactorNettyClientRequestFactory(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.ReactorNettyClientRequestFactory(reactor.netty.http.client.HttpClient httpClient) Create a new instance of theReactorNettyClientRequestFactorybased on the givenHttpClient.
- 
Method SummaryModifier and TypeMethodDescriptioncreateRequest(URI uri, HttpMethod httpMethod) Create a newClientHttpRequestfor the specified URI and HTTP method.intgetPhase()Return the phase that this lifecycle object is supposed to run in.booleanReturnstrueif thisLifecyclecomponent should get started automatically by the container at the time that the containingApplicationContextgets refreshed.booleanCheck whether this component is currently running.voidsetConnectTimeout(int connectTimeout) Set the underlying connect timeout in milliseconds.voidsetConnectTimeout(Duration connectTimeout) Set the underlying connect timeout in milliseconds.voidsetExchangeTimeout(long exchangeTimeout) Set the timeout for the HTTP exchange in milliseconds.voidsetExchangeTimeout(Duration exchangeTimeout) Set the timeout for the HTTP exchange.voidsetReadTimeout(long readTimeout) Set the underlying read timeout in milliseconds.voidsetReadTimeout(Duration readTimeout) Set the underlying read timeout asDuration.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.final voidIndicates that a Lifecycle component must stop if it is currently running.
- 
Constructor Details- 
ReactorNettyClientRequestFactorypublic ReactorNettyClientRequestFactory()Create a new instance of theReactorNettyClientRequestFactorywith a defaultHttpClientthat has compression enabled.
- 
ReactorNettyClientRequestFactorypublic ReactorNettyClientRequestFactory(reactor.netty.http.client.HttpClient httpClient) Create a new instance of theReactorNettyClientRequestFactorybased on the givenHttpClient.- Parameters:
- httpClient- the client to base on
 
- 
ReactorNettyClientRequestFactorypublic ReactorNettyClientRequestFactory(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
 
 
- 
- 
Method Details- 
setConnectTimeoutpublic void setConnectTimeout(int connectTimeout) Set the underlying connect timeout in milliseconds. A value of 0 specifies an infinite timeout.Default is 30 seconds. - See Also:
- 
- Transport.option(ChannelOption, Object)
- ChannelOption.CONNECT_TIMEOUT_MILLIS
 
 
- 
setConnectTimeoutSet the underlying connect timeout in milliseconds. A value of 0 specifies an infinite timeout.Default is 30 seconds. - See Also:
- 
- Transport.option(ChannelOption, Object)
- ChannelOption.CONNECT_TIMEOUT_MILLIS
 
 
- 
setReadTimeoutpublic void setReadTimeout(long readTimeout) Set the underlying read timeout in milliseconds.Default is 10 seconds. 
- 
setReadTimeoutSet the underlying read timeout asDuration.Default is 10 seconds. 
- 
setExchangeTimeoutpublic void setExchangeTimeout(long exchangeTimeout) Set the timeout for the HTTP exchange in milliseconds.Default is 5 seconds. 
- 
setExchangeTimeoutSet the timeout for the HTTP exchange.Default is 5 seconds. 
- 
createRequestDescription copied from interface:ClientHttpRequestFactoryCreate a newClientHttpRequestfor the specified URI and HTTP method.The returned request can be written to, and then executed by calling ClientHttpRequest.execute().- Specified by:
- createRequestin interface- ClientHttpRequestFactory
- Parameters:
- uri- the URI to create a request for
- httpMethod- the HTTP method to execute
- Returns:
- the created request
- Throws:
- IOException- in case of I/O errors
 
- 
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 the start signal to all components that apply. 
- 
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. 
- 
stopDescription copied from interface:SmartLifecycleIndicates that a Lifecycle component must stop if it is currently running.The provided callback is used by the LifecycleProcessorto support an ordered, and potentially concurrent, shutdown of all components having a common shutdown order value. The callback must be executed after theSmartLifecyclecomponent does indeed stop.The LifecycleProcessorwill call only this variant of thestopmethod; i.e.Lifecycle.stop()will not be called forSmartLifecycleimplementations unless explicitly delegated to within the implementation of this method.The default implementation delegates to Lifecycle.stop()and immediately triggers the given callback in the calling thread. Note that there is no synchronization between the two, so custom implementations may at least want to put the same steps within their common lifecycle monitor (if any).- Specified by:
- stopin interface- SmartLifecycle
- See Also:
 
- 
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.
- 
isAutoStartuppublic boolean isAutoStartup()Description copied from interface:SmartLifecycleReturnstrueif thisLifecyclecomponent should get started automatically by the container at the time that the containingApplicationContextgets refreshed.A value of falseindicates that the component is intended to be started through an explicitLifecycle.start()call instead, analogous to a plainLifecycleimplementation.The default implementation returns true.- Specified by:
- isAutoStartupin interface- SmartLifecycle
- See Also:
 
- 
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:
 
 
-