I have a legacy grails based system with a MySQL database. I rewrite incrementally the system in a modern Spring Boot 3 and MongoDB Atlas database. I can't just shutdown the legacy system and replace it and I want to rewrite only the write operations (create, update and delete) in the legacy system. So, I write a synchronization mechanism between the legacy system and the new system. To do this, I write a sync project and I use MongoDB Atlas triggers + functions.
For now, the process is as follow:
With this mechanism I don't need to update any read operations in the legacy system because the legacy database is updated by the sync project. All the system works as expected but I must do a Thread.sleep in the legacy controller in order to wait the MongoDB Atlas trigger + function execution and the legacy database update.
This waiting is not really acceptable but I don't see what I can do to resolve the problem.
Do you have any idea?
I have resolved my problem with AOP instead of MongoDB Atlas function.