Class LiquibaseStatusProvider
- All Implemented Interfaces:
StatusProvider,BeanPostProcessor
StatusProvider that provides the progress of the Liquibase database migrations run on startup, such as
Liquibase: applying changeset 042-add-index (41 applied).
The migrations are run by the SpringLiquibase beans, such as the one Spring Boot sets up, while they are created. This provider is a bean post
processor that follows their creation, and makes the Liquibase instance they run report each changeset it applies, with the customizer of the
bean. Each changeset also extends the startup timeout, as a migration with many changesets can take longer than the TimeoutStartSec of the service
unit; a single changeset that takes longer than the timeout extension still exceeds it, in which case TimeoutStartSec must be raised.
The progress is reported through a PhaseStatusProvider of its own, sent to systemd right away on every change, and cleared once the
migrations complete.
When they fail, the changeset that failed is still reported, while the application fails to start.
The changesets are reported with a ChangeExecListener that is set before the customizer the bean already has, if
any: a customizer that sets a listener of its own replaces it, in which case the changesets are not reported.
- Author:
- Joao Silva
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance, which sends the status to systemd on every change, and extends the startup timeout on every changeset. -
Method Summary
Modifier and TypeMethodDescriptionpostProcessAfterInitialization(Object bean, String beanName) Clears the progress once aSpringLiquibasebean ran the migrations.postProcessBeforeInitialization(Object bean, String beanName) Makes theLiquibaseinstance run by aSpringLiquibasebean report each changeset it applies, before the bean runs the migrations.status()Exposes status information to send to systemd.
-
Constructor Details
-
LiquibaseStatusProvider
public LiquibaseStatusProvider()Creates a new instance, which sends the status to systemd on every change, and extends the startup timeout on every changeset.The created instance is not registered as a status provider of
Systemd.instance(): that is up to the caller.
-
-
Method Details
-
postProcessBeforeInitialization
Makes theLiquibaseinstance run by aSpringLiquibasebean report each changeset it applies, before the bean runs the migrations.- Specified by:
postProcessBeforeInitializationin interfaceBeanPostProcessor- Parameters:
bean- the bean being createdbeanName- the name of the bean- Returns:
- the bean
-
postProcessAfterInitialization
Clears the progress once aSpringLiquibasebean ran the migrations.- Specified by:
postProcessAfterInitializationin interfaceBeanPostProcessor- Parameters:
bean- the bean being createdbeanName- the name of the bean- Returns:
- the bean
-
status
Description copied from interface:StatusProviderExposes status information to send to systemd.- Specified by:
statusin interfaceStatusProvider- Returns:
- the string message to add to the service status
-