Interface LifecycleRegistry
- All Known Implementing Classes:
DefaultAxonApplication,HierarchicalConfiguration,SpringLifecycleRegistry
Allows for configuration of Runnables, suppliers of CompletableFutures,
consumers of the AxonConfiguration, and LifecycleHandlers. The
invocation order is defined through the (optional) phase parameter. The
Phase enumeration may be used as a guidance to add operations before/after Axon's
regular steps when stating the phase for the various registration methods.
- Since:
- 4.6.0
- Author:
- Steven van Beelen
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondefault LifecycleRegistryonShutdown(int phase, Runnable shutdownHandler) Registers ashutdownHandlerto be executed in the givenphasewhen the configuration this registry belongs to is shut down.default LifecycleRegistryonShutdown(int phase, Consumer<Configuration> shutdownHandler) Registers ashutdownHandlerto be executed in the givenphasewhen the configuration this registry belongs to is shut down.default LifecycleRegistryonShutdown(int phase, Supplier<CompletableFuture<?>> shutdownHandler) Registers ashutdownHandlerto be executed in the givenphasewhen the configuration this registry belongs to is shut down.onShutdown(int phase, LifecycleHandler shutdownHandler) Registers an asynchronousshutdownHandlerto be executed in the givenphasewhen the configuration this registry belongs to is shut down.default LifecycleRegistryonShutdown(Runnable shutdownHandler) Registers ashutdownHandlerto be executed in the default phase0when the configuration this registry belongs to is shut down.default LifecycleRegistryRegisters astartHandlerto be executed in the givenphasewhen the configuration this registry belongs to is started.default LifecycleRegistryonStart(int phase, Consumer<Configuration> startHandler) Registers astartHandlerto be executed in the givenphasewhen the configuration this registry belongs to is started.default LifecycleRegistryonStart(int phase, Supplier<CompletableFuture<?>> startHandler) Registers astartHandlerto be executed in the givenphasewhen the configuration this registry belongs to is started.onStart(int phase, LifecycleHandler startHandler) Registers an asynchronousstartHandlerto be executed in the givenphasewhen the configuration this registry belongs to is started.default LifecycleRegistryRegisters astartHandlerto be executed in the default phase0when the configuration this registry belongs to is started.registerLifecyclePhaseTimeout(long timeout, TimeUnit timeUnit) Configures the timeout of each lifecycle phase.
-
Method Details
-
registerLifecyclePhaseTimeout
Configures the timeout of each lifecycle phase. TheLifecycleRegistryinvokes lifecycle phases during start-up and shutdown of an application.Note that if a lifecycle phase exceeds the configured
timeoutandtimeUnitcombination, theLifecycleRegistrywill proceed with the following phase. A phase-skip is marked with a warn logging message, as the chances are high this causes undesired side effects.The default lifecycle phase timeout is five seconds.
- Parameters:
timeout- The amount of time to wait for lifecycle phase completion.timeUnit- The unit in which thetimeoutis expressed.- Returns:
- The current instance of the
LifecycleRegistry, for chaining purposes. - See Also:
-
onStart
Registers astartHandlerto be executed in the default phase0when the configuration this registry belongs to is started.Handlers cannot be registered when the configuration has already been created from this registry.
- Parameters:
startHandler- The handler to execute when theAxonConfigurationis started.- Returns:
- The current instance of the
LifecycleRegistryfor a fluent API. - See Also:
-
onStart
Registers astartHandlerto be executed in the givenphasewhen the configuration this registry belongs to is started.Handlers cannot be registered when the configuration has already been created from this registry.
- Parameters:
phase- Defines aphasein which the start handler will be invoked duringAxonConfiguration.start(). When starting the configuration the given handlers are started in ascending order based on theirphase.startHandler- The handler to execute when theAxonConfigurationis started.- Returns:
- The current instance of the
LifecycleRegistryfor a fluent API. - See Also:
-
onStart
Registers astartHandlerto be executed in the givenphasewhen the configuration this registry belongs to is started.Handlers cannot be registered when the configuration has already been created from this registry.
- Parameters:
phase- Defines aphasein which the start handler will be invoked duringAxonConfiguration.start(). When starting the configuration the given handlers are started in ascending order based on theirphase.startHandler- The handler to execute when theAxonConfigurationis started.- Returns:
- The current instance of the
LifecycleRegistryfor a fluent API. - See Also:
-
onStart
Registers astartHandlerto be executed in the givenphasewhen the configuration this registry belongs to is started.Handlers cannot be registered when the configuration has already been created from this registry.
- Parameters:
phase- Defines aphasein which the start handler will be invoked duringAxonConfiguration.start(). When starting the configuration the given handlers are started in ascending order based on theirphase.startHandler- The handler to execute when theAxonConfigurationis started.- Returns:
- The current instance of the
LifecycleRegistryfor a fluent API. - See Also:
-
onStart
Registers an asynchronousstartHandlerto be executed in the givenphasewhen the configuration this registry belongs to is started.Handlers cannot be registered when the configuration has already been created from this registry.
- Parameters:
phase- Defines aphasein which the start handler will be invoked duringAxonConfiguration.start(). When starting the configuration the given handlers are started in ascending order based on theirphase.startHandler- The handler to be executed asynchronously when theAxonConfigurationis started.- Returns:
- The current instance of the
LifecycleRegistryfor a fluent API. - See Also:
-
onShutdown
Registers ashutdownHandlerto be executed in the default phase0when the configuration this registry belongs to is shut down.Handlers cannot be registered when the configuration has already been created from this registry.
- Parameters:
shutdownHandler- The handler to execute when theAxonConfigurationis shut down.- Returns:
- The current instance of the
LifecycleRegistryfor a fluent API. - See Also:
-
onShutdown
Registers ashutdownHandlerto be executed in the givenphasewhen the configuration this registry belongs to is shut down.Handlers cannot be registered when the configuration has already been created from this registry.
- Parameters:
phase- Defines a phase in which the shutdown handler will be invoked duringAxonConfiguration.shutdown(). When shutting down the configuration the given handlers are executing in descending order based on theirphase.shutdownHandler- The handler to execute when theAxonConfigurationis shut down.- Returns:
- The current instance of the
LifecycleRegistryfor a fluent API. - See Also:
-
onShutdown
default LifecycleRegistry onShutdown(int phase, @Nonnull Supplier<CompletableFuture<?>> shutdownHandler) Registers ashutdownHandlerto be executed in the givenphasewhen the configuration this registry belongs to is shut down.The behavior for handlers that are registered when the configuration is already shut down is undefined.
- Parameters:
phase- Defines a phase in which the shutdown handler will be invoked duringAxonConfiguration.shutdown(). When shutting down the configuration the given handlers are executing in descending order based on theirphase.shutdownHandler- The handler to execute when theAxonConfigurationis shut down.- Returns:
- The current instance of the
LifecycleRegistryfor a fluent API. - See Also:
-
onShutdown
Registers ashutdownHandlerto be executed in the givenphasewhen the configuration this registry belongs to is shut down.The behavior for handlers that are registered when the configuration is already shut down is undefined.
- Parameters:
phase- Defines a phase in which the shutdown handler will be invoked duringAxonConfiguration.shutdown(). When shutting down the configuration the given handlers are executing in descending order based on theirphase.shutdownHandler- The handler to execute when theAxonConfigurationis shut down.- Returns:
- The current instance of the
LifecycleRegistryfor a fluent API. - See Also:
-
onShutdown
Registers an asynchronousshutdownHandlerto be executed in the givenphasewhen the configuration this registry belongs to is shut down.The behavior for handlers that are registered when the configuration is already shut down is undefined.
- Parameters:
phase- Defines a phase in which the shutdown handler will be invoked duringAxonConfiguration.shutdown(). When shutting down the configuration the given handlers are executing in descending order based on theirphase.shutdownHandler- The handler to be executed asynchronously when theAxonConfigurationis shut down.- Returns:
- The current instance of the
LifecycleRegistryfor a fluent API. - See Also:
-