类 ReactorResourceFactory
- java.lang.Object
- org.springframework.http.client.reactive.ReactorResourceFactory
- 所有已实现的接口:
DisposableBean
,InitializingBean
public class ReactorResourceFactory extends Object implements InitializingBean, DisposableBean
Factory to manage Reactor Netty resources, i.e.LoopResources
for event loop threads, andConnectionProvider
for the connection pool, within the lifecycle of a SpringApplicationContext
.This factory implements
InitializingBean
andDisposableBean
and is expected typically to be declared as a Spring-managed bean.- 从以下版本开始:
- 5.1
- 作者:
- Rossen Stoyanchev, Brian Clozel
构造器概要
构造器 构造器 说明 ReactorResourceFactory()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
addGlobalResourcesConsumer(Consumer<reactor.netty.http.HttpResources> consumer)
Add a Consumer for configuring the global Reactor Netty resources on startup.void
afterPropertiesSet()
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.void
destroy()
Invoked by the containingBeanFactory
on destruction of a bean.reactor.netty.resources.ConnectionProvider
getConnectionProvider()
Return the configuredConnectionProvider
.reactor.netty.resources.LoopResources
getLoopResources()
Return the configuredLoopResources
.boolean
isUseGlobalResources()
Whether this factory exposes the globalHttpResources
holder.void
setConnectionProvider(reactor.netty.resources.ConnectionProvider connectionProvider)
Use this when you want to provide an externally managedConnectionProvider
instance.void
setConnectionProviderSupplier(Supplier<reactor.netty.resources.ConnectionProvider> supplier)
Use this when you don't want to participate in global resources and you want to customize the creation of the managedConnectionProvider
.void
setLoopResources(reactor.netty.resources.LoopResources loopResources)
Use this option when you want to provide an externally managedLoopResources
instance.void
setLoopResourcesSupplier(Supplier<reactor.netty.resources.LoopResources> supplier)
Use this when you don't want to participate in global resources and you want to customize the creation of the managedLoopResources
.void
setShutdownQuietPeriod(Duration shutdownQuietPeriod)
Configure the amount of time we'll wait before shutting down resources.void
setShutdownTimeout(Duration shutdownTimeout)
Configure the maximum amount of time to wait until the disposal of the underlying resources regardless if a task was submitted during theshutdownQuietPeriod
.void
setUseGlobalResources(boolean useGlobalResources)
Whether to use global Reactor Netty resources viaHttpResources
.
构造器详细资料
ReactorResourceFactory
public ReactorResourceFactory()
方法详细资料
setUseGlobalResources
public void setUseGlobalResources(boolean useGlobalResources)
Whether to use global Reactor Netty resources viaHttpResources
.Default is "true" in which case this factory initializes and stops the global Reactor Netty resources within Spring's
ApplicationContext
lifecycle. If set to "false" the factory manages its resources independent of the global ones.- 参数:
useGlobalResources
- whether to expose and manage the global resources- 另请参阅:
addGlobalResourcesConsumer(Consumer)
isUseGlobalResources
public boolean isUseGlobalResources()
Whether this factory exposes the globalHttpResources
holder.
addGlobalResourcesConsumer
public void addGlobalResourcesConsumer(Consumer<reactor.netty.http.HttpResources> consumer)
Add a Consumer for configuring the global Reactor Netty resources on startup. When this option is used,setUseGlobalResources(boolean)
is also enabled.- 参数:
consumer
- the consumer to apply- 另请参阅:
setUseGlobalResources(boolean)
setConnectionProviderSupplier
public void setConnectionProviderSupplier(Supplier<reactor.netty.resources.ConnectionProvider> supplier)
Use this when you don't want to participate in global resources and you want to customize the creation of the managedConnectionProvider
.By default,
ConnectionProvider.elastic("http")
is used.Note that this option is ignored if
userGlobalResources=false
orsetConnectionProvider(ConnectionProvider)
is set.- 参数:
supplier
- the supplier to use
setConnectionProvider
public void setConnectionProvider(reactor.netty.resources.ConnectionProvider connectionProvider)
Use this when you want to provide an externally managedConnectionProvider
instance.- 参数:
connectionProvider
- the connection provider to use as is
getConnectionProvider
public reactor.netty.resources.ConnectionProvider getConnectionProvider()
Return the configuredConnectionProvider
.
setLoopResourcesSupplier
public void setLoopResourcesSupplier(Supplier<reactor.netty.resources.LoopResources> supplier)
Use this when you don't want to participate in global resources and you want to customize the creation of the managedLoopResources
.By default,
LoopResources.create("reactor-http")
is used.Note that this option is ignored if
userGlobalResources=false
orsetLoopResources(LoopResources)
is set.- 参数:
supplier
- the supplier to use
setLoopResources
public void setLoopResources(reactor.netty.resources.LoopResources loopResources)
Use this option when you want to provide an externally managedLoopResources
instance.- 参数:
loopResources
- the loop resources to use as is
getLoopResources
public reactor.netty.resources.LoopResources getLoopResources()
Return the configuredLoopResources
.
setShutdownQuietPeriod
public void setShutdownQuietPeriod(Duration shutdownQuietPeriod)
Configure the amount of time we'll wait before shutting down resources. If a task is submitted during theshutdownQuietPeriod
, it is guaranteed to be accepted and theshutdownQuietPeriod
will start over.By default, this is set to
LoopResources.DEFAULT_SHUTDOWN_QUIET_PERIOD
which is 2 seconds but can also be overridden with the system propertyReactorNetty.SHUTDOWN_QUIET_PERIOD
.- 从以下版本开始:
- 5.2.4
- 另请参阅:
setShutdownTimeout(Duration)
setShutdownTimeout
public void setShutdownTimeout(Duration shutdownTimeout)
Configure the maximum amount of time to wait until the disposal of the underlying resources regardless if a task was submitted during theshutdownQuietPeriod
.By default, this is set to
LoopResources.DEFAULT_SHUTDOWN_TIMEOUT
which is 15 seconds but can also be overridden with the system propertyReactorNetty.SHUTDOWN_TIMEOUT
.- 从以下版本开始:
- 5.2.4
- 另请参阅:
setShutdownQuietPeriod(Duration)
afterPropertiesSet
public void afterPropertiesSet()
从接口复制的说明:InitializingBean
Invoked by the containingBeanFactory
after it has set all bean properties and satisfiedBeanFactoryAware
,ApplicationContextAware
etc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- 指定者:
afterPropertiesSet
在接口中InitializingBean
destroy
public void destroy()
从接口复制的说明:DisposableBean
Invoked by the containingBeanFactory
on destruction of a bean.- 指定者:
destroy
在接口中DisposableBean