0

I have an scenario,
I have two DB server running on two different machines.
I have to build an automated process by which the data will replicate from one DB to another DB server on every insertion happens in first one.
My application using spring- hibernate and mysql DB.
I can go for DB side or spring-hibernate side approach.
Is it possible to do this with rabbitMQ?
I have an option to call automated process on each insertion or as a batch process or using queue.Some of the answers mention in the following link, but it is not clear to me
1. https://stackoverflow.com/questions/33130260/transforming-data-from-one-sql-server-db-to-another
2. https://stackoverflow.com/questions/3821897/replicating-data-from-one-db-to-another
Any help would be greatly appreciated

migrated from stackoverflow.com Apr 7 '16 at 21:25

This question came from our site for professional and enthusiast programmers.

  • Best choice is solution 2. Just configure and use. Tested and checked already. – simar Apr 5 '16 at 6:57
  • Another case is to use ESB – simar Apr 5 '16 at 6:57
1

Do not try to make it harder than it actually is. Replication mechanism build-in mySQL will be the best for that. There is a ton of tutorials in google, ex.:

https://fromdual.com/how_to_setup_mysql_master-slave_replication

Basically, You need master-slave configuration.

1

Here are my thoughts on this,

1. Via DB Side,

If you don't want to mesh the deployment aspects with your application then this is best one. The system admin people will take care of these burden from you. They will setup the master-slave setup and your application will seamlessly access the db.

2. Spring - Hibernate

In this way you can use interceptors and send all your queries to the replication machine as well. But this is will decrease your application's performance as well so you have to thing a lot on this before getting into this and also it if anything goes wrong during replication then your application transaction as well will get affected. So need more caution on this while designing.

3. Separate External job with Hibernate interceptors combination:

You can design some external worker manager kind of async tasks and dispatch your replication job over to these workers. some kind of batch also you have to maintain for better performane, maintainability and control. So you can maintain the modified entities into separate queue (It may be redis / rappitMQ ) from there your external job will take care the replication process. So your application is released from the burden.

  • The interceptor solution will also have issues with transactional controls as it requires code to deal with multiphase commit kinds of issues. Elegant answer, Maria. +1 – T Gray Oct 26 '16 at 20:27
0

Yep. Setting up a master-slave is the easiest way to do this. If you need update or insert capability on both, that can be a bit tricky. In any case, if you do go master-slave, be aware that during the copy process the master DB will be lock

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy