Class ReactorClientHttpRequestFactory
- All Implemented Interfaces:
- Lifecycle,- Phased,- SmartLifecycle,- ClientHttpRequestFactory
- Direct Known Subclasses:
- ReactorNettyClientRequestFactory
ClientHttpRequestFactory.
 This class implements SmartLifecycle and can be optionally declared
 as a Spring-managed bean in order to support JVM Checkpoint Restore.
- Since:
- 6.2
- Author:
- Arjen Poutsma, Juergen Hoeller, Sebastien Deleuze
- 
Field SummaryFields inherited from interface org.springframework.context.SmartLifecycleDEFAULT_PHASE
- 
Constructor SummaryConstructorsConstructorDescriptionConstructor with default client, created viaHttpClient.create(), and withcompressionenabled.ReactorClientHttpRequestFactory(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 connection pooling.ReactorClientHttpRequestFactory(reactor.netty.http.client.HttpClient client) Constructor with a givenHttpClientinstance.
- 
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.booleanCheck whether this component is currently running.voidsetConnectTimeout(int connectTimeout) Set the connect timeout value on the underlying client.voidsetConnectTimeout(Duration connectTimeout) Variant ofsetConnectTimeout(int)with aDurationvalue.voidsetExchangeTimeout(long exchangeTimeout) Deprecated, for removal: This API element is subject to removal in a future version.as of 6.2 and no longer set by default (previously 5 seconds) in favor of using Reactor Netty HttpClient timeout configuration.voidsetExchangeTimeout(Duration exchangeTimeout) Deprecated, for removal: This API element is subject to removal in a future version.as of 6.2 and no longer set by default (previously 5 seconds) in favor of using Reactor Netty HttpClient timeout configuration.voidsetReadTimeout(long readTimeout) Variant ofsetReadTimeout(Duration)with a long value.voidsetReadTimeout(Duration timeout) Set the read timeout value on the underlying client.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 java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.SmartLifecycleisAutoStartup, stop
- 
Constructor Details- 
ReactorClientHttpRequestFactorypublic ReactorClientHttpRequestFactory()Constructor with default client, created viaHttpClient.create(), and withcompressionenabled.
- 
ReactorClientHttpRequestFactorypublic ReactorClientHttpRequestFactory(reactor.netty.http.client.HttpClient client) Constructor with a givenHttpClientinstance.- Parameters:
- client- the client to use
 
- 
ReactorClientHttpRequestFactorypublic ReactorClientHttpRequestFactory(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 connection pooling.Generally, it is recommended to share resources for event loop concurrency. This can be achieved either by participating in the JVM-wide, global resources held in HttpResources, or by using a specific, shared set of resources through aReactorResourceFactorybean. The latter can ensure that resources are shut down when the Spring ApplicationContext is stopped/closed and restarted again (e.g. JVM checkpoint restore).- Parameters:
- resourceFactory- the resource factory to get resources from
- mapper- for further initialization of the client
 
 
- 
- 
Method Details- 
setConnectTimeoutpublic void setConnectTimeout(int connectTimeout) Set the connect timeout value on the underlying client. Effectively, a shortcut forhttpClient.option(CONNECT_TIMEOUT_MILLIS, timeout).By default, set to 30 seconds. - Parameters:
- connectTimeout- the timeout value in millis; use 0 to never time out.
- See Also:
- 
- Transport.option(ChannelOption, Object)
- ChannelOption.CONNECT_TIMEOUT_MILLIS
- Connection Timeout
 
 
- 
setConnectTimeoutVariant ofsetConnectTimeout(int)with aDurationvalue.
- 
setReadTimeoutSet the read timeout value on the underlying client. Effectively, a shortcut forHttpClient.responseTimeout(Duration).By default, set to 10 seconds. - Parameters:
- timeout- the read timeout value in millis; must be > 0.
 
- 
setReadTimeoutpublic void setReadTimeout(long readTimeout) Variant ofsetReadTimeout(Duration)with a long value.
- 
setExchangeTimeoutDeprecated, for removal: This API element is subject to removal in a future version.as of 6.2 and no longer set by default (previously 5 seconds) in favor of using Reactor Netty HttpClient timeout configuration.Set the timeout for the HTTP exchange in milliseconds.By default, as of 6.2 this is no longer set. 
- 
setExchangeTimeoutDeprecated, for removal: This API element is subject to removal in a future version.as of 6.2 and no longer set by default (previously 5 seconds) in favor of using Reactor Netty HttpClient timeout configuration.Variant ofsetExchangeTimeout(long)with a Duration value.By default, as of 6.2 this is no longer set. 
- 
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. 
- 
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:
 
 
-