Class ReactorResourceFactory

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      voidaddGlobalResourcesConsumer​(Consumer<reactor.netty.http.HttpResources> consumer)
      Add a Consumer for configuring the global Reactor Netty resources on startup.
      voidafterPropertiesSet()
      Invoked by the containing BeanFactory after it has set all bean properties and satisfied BeanFactoryAware, ApplicationContextAware etc.
      voiddestroy()
      Invoked by the containing BeanFactory on destruction of a bean.
      reactor.netty.resources.ConnectionProvidergetConnectionProvider()
      Return the configured ConnectionProvider.
      reactor.netty.resources.LoopResourcesgetLoopResources()
      Return the configured LoopResources.
      booleanisUseGlobalResources()
      Whether this factory exposes the global HttpResources holder.
      voidsetConnectionProvider​(reactor.netty.resources.ConnectionProvider connectionProvider)
      Use this when you want to provide an externally managed ConnectionProvider instance.
      voidsetConnectionProviderSupplier​(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 managed ConnectionProvider.
      voidsetLoopResources​(reactor.netty.resources.LoopResources loopResources)
      Use this option when you want to provide an externally managed LoopResources instance.
      voidsetLoopResourcesSupplier​(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 managed LoopResources.
      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 the shutdownQuietPeriod.
      voidsetUseGlobalResources​(boolean useGlobalResources)
      Whether to use global Reactor Netty resources via HttpResources.
    • Method Detail

      • setUseGlobalResources

        public void setUseGlobalResources​(boolean useGlobalResources)
        Whether to use global Reactor Netty resources via HttpResources.

        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.

        Parameters:
        useGlobalResources - whether to expose and manage the global resources
        See Also:
        addGlobalResourcesConsumer(Consumer)
      • isUseGlobalResources

        public boolean isUseGlobalResources()
        Whether this factory exposes the global HttpResources holder.
      • 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 managed ConnectionProvider.

        By default, ConnectionProvider.elastic("http") is used.

        Note that this option is ignored if userGlobalResources=false or setConnectionProvider(ConnectionProvider) is set.

        Parameters:
        supplier - the supplier to use
      • setConnectionProvider

        public void setConnectionProvider​(reactor.netty.resources.ConnectionProvider connectionProvider)
        Use this when you want to provide an externally managed ConnectionProvider instance.
        Parameters:
        connectionProvider - the connection provider to use as is
      • getConnectionProvider

        public reactor.netty.resources.ConnectionProvider getConnectionProvider()
        Return the configured ConnectionProvider.
      • 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 managed LoopResources.

        By default, LoopResources.create("reactor-http") is used.

        Note that this option is ignored if userGlobalResources=false or setLoopResources(LoopResources) is set.

        Parameters:
        supplier - the supplier to use
      • setLoopResources

        public void setLoopResources​(reactor.netty.resources.LoopResources loopResources)
        Use this option when you want to provide an externally managed LoopResources instance.
        Parameters:
        loopResources - the loop resources to use as is
      • getLoopResources

        public reactor.netty.resources.LoopResources getLoopResources()
        Return the configured LoopResources.
      • setShutdownQuietPeriod

        public void setShutdownQuietPeriod​(Duration shutdownQuietPeriod)
        Configure the amount of time we'll wait before shutting down resources. If a task is submitted during the shutdownQuietPeriod, it is guaranteed to be accepted and the shutdownQuietPeriod 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 property ReactorNetty.SHUTDOWN_QUIET_PERIOD.

        Since:
        5.2.4
        See Also:
        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 the shutdownQuietPeriod.

        By default, this is set to LoopResources.DEFAULT_SHUTDOWN_TIMEOUT which is 15 seconds but can also be overridden with the system property ReactorNetty.SHUTDOWN_TIMEOUT.

        Since:
        5.2.4
        See Also:
        setShutdownQuietPeriod(Duration)
      • afterPropertiesSet

        public void afterPropertiesSet()
        Description copied from interface: InitializingBean
        Invoked by the containing BeanFactory after it has set all bean properties and satisfied BeanFactoryAware, 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.

        Specified by:
        afterPropertiesSet in interface InitializingBean