Class ReactorNetty2ResourceFactory
- All Implemented Interfaces:
- DisposableBean,- InitializingBean
LoopResources for
 event loop threads, and ConnectionProvider for the connection pool,
 within the lifecycle of a Spring ApplicationContext.
 This factory implements InitializingBean and DisposableBean
 and is expected typically to be declared as a Spring-managed bean.
 
This class is based on ReactorResourceFactory.
- Since:
- 6.0
- Author:
- Violeta Georgieva
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddGlobalResourcesConsumer(Consumer<reactor.netty5.http.HttpResources> consumer) Add a Consumer for configuring the global Reactor Netty resources on startup.voidInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.voiddestroy()Invoked by the containingBeanFactoryon destruction of a bean.reactor.netty5.resources.ConnectionProviderReturn the configuredConnectionProvider.reactor.netty5.resources.LoopResourcesReturn the configuredLoopResources.booleanWhether this factory exposes the globalHttpResourcesholder.voidsetConnectionProvider(reactor.netty5.resources.ConnectionProvider connectionProvider) Use this when you want to provide an externally managedConnectionProviderinstance.voidsetConnectionProviderSupplier(Supplier<reactor.netty5.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.voidsetLoopResources(reactor.netty5.resources.LoopResources loopResources) Use this option when you want to provide an externally managedLoopResourcesinstance.voidsetLoopResourcesSupplier(Supplier<reactor.netty5.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.voidsetShutdownQuietPeriod(Duration shutdownQuietPeriod) Configure the amount of time we'll wait before shutting down resources.voidsetShutdownTimeout(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.voidsetUseGlobalResources(boolean useGlobalResources) Whether to use global Reactor Netty resources viaHttpResources.
- 
Constructor Details- 
ReactorNetty2ResourceFactorypublic ReactorNetty2ResourceFactory()
 
- 
- 
Method Details- 
setUseGlobalResourcespublic 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 ApplicationContextlifecycle. If set to "false" the factory manages its resources independent of the global ones.- Parameters:
- useGlobalResources- whether to expose and manage the global resources
- See Also:
 
- 
isUseGlobalResourcespublic boolean isUseGlobalResources()Whether this factory exposes the globalHttpResourcesholder.
- 
addGlobalResourcesConsumerAdd a Consumer for configuring the global Reactor Netty resources on startup. When this option is used,setUseGlobalResources(boolean)is also enabled.- Parameters:
- consumer- the consumer to apply
- See Also:
 
- 
setConnectionProviderSupplierpublic void setConnectionProviderSupplier(Supplier<reactor.netty5.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 supplier is ignored if isUseGlobalResources()istrueor once theConnectionProvideris set.- Parameters:
- supplier- the supplier to use
 
- 
setConnectionProviderpublic void setConnectionProvider(reactor.netty5.resources.ConnectionProvider connectionProvider) Use this when you want to provide an externally managedConnectionProviderinstance.- Parameters:
- connectionProvider- the connection provider to use as is
 
- 
getConnectionProviderpublic reactor.netty5.resources.ConnectionProvider getConnectionProvider()Return the configuredConnectionProvider.
- 
setLoopResourcesSupplierUse 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("webflux-http")is used.Note that this supplier is ignored if isUseGlobalResources()istrueor once theLoopResourcesis set.- Parameters:
- supplier- the supplier to use
 
- 
setLoopResourcespublic void setLoopResources(reactor.netty5.resources.LoopResources loopResources) Use this option when you want to provide an externally managedLoopResourcesinstance.- Parameters:
- loopResources- the loop resources to use as is
 
- 
getLoopResourcespublic reactor.netty5.resources.LoopResources getLoopResources()Return the configuredLoopResources.
- 
setShutdownQuietPeriodConfigure 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 theshutdownQuietPeriodwill start over.By default, this is set to LoopResources.DEFAULT_SHUTDOWN_QUIET_PERIODwhich is 2 seconds but can also be overridden with the system propertyReactorNetty.SHUTDOWN_QUIET_PERIOD.- See Also:
 
- 
setShutdownTimeoutConfigure 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_TIMEOUTwhich is 15 seconds but can also be overridden with the system propertyReactorNetty.SHUTDOWN_TIMEOUT.- See Also:
 
- 
afterPropertiesSetpublic void afterPropertiesSet()Description copied from interface:InitializingBeanInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set. - Specified by:
- afterPropertiesSetin interface- InitializingBean
 
- 
destroypublic void destroy()Description copied from interface:DisposableBeanInvoked by the containingBeanFactoryon destruction of a bean.- Specified by:
- destroyin interface- DisposableBean
 
 
-