mysqlgrails3

How to update offline mysql data to online mysql data in application using grails


I have developed a billing application using grails3. Requirement is to use this application both online and offline, when internet facility interrupted, While using offline data is being stored in local Mysql db and when I switch to online, the offline Mysql data should be updated to my remote Mysql db. What is the best strategy to implement this use-case. Is there any grails-plugin available for this scenario.


Solution

  • One of my friends suggested the following use-cases to consider:

    1. If you assume the amount of time the system is going to be offline is fairly low, you can hold the data in-memory and push when the system is back online.

    2. If you think the data can get large with offline storage, you can use a FLAT File to store your data and then read that file and do the writes in your remote mysql db.

    3. You can also use mysql replication capabilities to replicate your data and have both local and remote mysql instances. You will have to invest some time on how to do this.

    4. Use a message queue mechanism to queue your queries when offline and then write to remote db in same sequence when online.

    5. Use a in-memory or local h2 database If your sql queries are not too complex. Write a job that periodically writes to your remote instance.