Notification when liquidbase executes insert

Just FYI, it is Liquibase without the d in the middle - makes for better searchability if everyone uses the correct name,

I am not familiar with elasticsearch, but it seems to me that if it is dependent on the data in another database, you should come up with a solution that periodically scans the database and updates elasticsearch rather than tying your application code to two different data sources. 

If you want to alter how Liquibase works, you would need to write custom code to do that. You would probably want to look at creating your own change type that is similar to the LoadDataChange class, but that also updates elasticSearch. 

Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/

Hi there,

I just started using liquidbase with elasticsearch in a product. 

For base data like country data hard coded in xml change files, liquidbase connects to database and puts them in place using jdbc. This solution makes it impossible to index those items in elasticsearch. In application logic, whenever a new record is being inserted, I add it to elasticsearch manually too. Because liquidbase make the inserts automatic and transparent, I can’t add those items to elasticsearch. 

What I basically need is either intercepting the liquidbase so whenever an insert happens I know about it, or a notification service, or using some kind of API.

To put it together, I need to know when liquidbase executes an insert and do something at that time. What is the best and standard solution for this scenario?

Best regards 

Thanks for your response.

Indeed the big problem is how to sync the database with elasticsearch. 

Considering that data is small and liquibase may or may not do the insert based on database state, in any case I will update the elasticsearch at startup. 

But it would have been great if liquibase had offered some kind of solution for intercepting the basic operation on database.

You may be one of the first people to ask for that feature. That’s how open source (and indeed, just about any software) works - if no one needs a feature, it doesn’t get written. The cool thing about open source is that if you see a need, you can implement it. 

Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/

There are few listener-style APIs in liquibase. The main one you would probably be interested in is liquibase.changelog.visitor.ChangeExecListener. You can set that on the liquibase.Liquibase object or other ways, depending on how you are interacting with Liquibase.

Nathan