Class AsyncSpringLiquibase

  • All Implemented Interfaces:
    org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ResourceLoaderAware

    public class AsyncSpringLiquibase
    extends liquibase.integration.spring.SpringLiquibase
    Specific liquibase.integration.spring.SpringLiquibase that will update the database asynchronously.

    By default, this asynchronous version only works when using the "dev" profile.

    The standard liquibase.integration.spring.SpringLiquibase starts Liquibase in the current thread:

    • This is needed if you want to do some database requests at startup
    • This ensure that the database is ready when the application starts
    But as this is a rather slow process, we use this asynchronous version to speed up our start-up time:
    • On a recent MacBook Pro, start-up time is down from 14 seconds to 8 seconds
    • In production, this can help your application run on platforms like Heroku, where it must start/restart very quickly
    • Nested Class Summary

      • Nested classes/interfaces inherited from class liquibase.integration.spring.SpringLiquibase

        liquibase.integration.spring.SpringLiquibase.SpringResourceOpener
    • Constructor Summary

      Constructors 
      Constructor Description
      AsyncSpringLiquibase​(Executor executor, org.springframework.core.env.Environment env)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void afterPropertiesSet()  
      protected void initDb()  
      • Methods inherited from class liquibase.integration.spring.SpringLiquibase

        createDatabase, createLiquibase, createResourceOpener, getBeanName, getChangeLog, getContexts, getDatabaseChangeLogLockTable, getDatabaseChangeLogTable, getDatabaseProductName, getDataSource, getDefaultSchema, getLabels, getLiquibaseSchema, getLiquibaseTablespace, getResourceLoader, getTag, isDropFirst, isIgnoreClasspathPrefix, isTestRollbackOnUpdate, performUpdate, setBeanName, setChangeLog, setChangeLogParameters, setContexts, setDatabaseChangeLogLockTable, setDatabaseChangeLogTable, setDataSource, setDefaultSchema, setDropFirst, setIgnoreClasspathPrefix, setLabels, setLiquibaseSchema, setLiquibaseTablespace, setResourceLoader, setRollbackFile, setShouldRun, setTag, setTestRollbackOnUpdate, toString
    • Constructor Detail

      • AsyncSpringLiquibase

        public AsyncSpringLiquibase​(Executor executor,
                                    org.springframework.core.env.Environment env)
    • Method Detail

      • afterPropertiesSet

        public void afterPropertiesSet()
                                throws liquibase.exception.LiquibaseException
        Specified by:
        afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
        Overrides:
        afterPropertiesSet in class liquibase.integration.spring.SpringLiquibase
        Throws:
        liquibase.exception.LiquibaseException
      • initDb

        protected void initDb()
                       throws liquibase.exception.LiquibaseException
        Throws:
        liquibase.exception.LiquibaseException