Our system need data sync with each sub system, because data transfer is bidirectional, so can't use mysql master and slave, at present I use two way to solve this problem.
With other system, I use hibernate interceptor to intercept the changed data, and write a log to record which table which data at which time changed, and when time arrive, I searche the latest data, then generate an xml document and transfer this document to other system. XML maybe like this
I use mysql master idea, not use slave idea as the way between our parent system an sub system data sync.
At every night, Out service call a bat file to execute some command and generate the update sql from mysqlbinlog, then according this sql, we can know which data changed, according requirement to analysis the update sql, and update data to each sub system and parent system.
With other system, I use hibernate interceptor to intercept the changed data, and write a log to record which table which data at which time changed, and when time arrive, I searche the latest data, then generate an xml document and transfer this document to other system. XML maybe like this
<?xml version="1.0" encoding="UTF-8"?>
<datasync name="employee" site="A">
<syncdata name="id">12345</syncdata >
<syncdata name="employee name">*******</syncdata >
</datasync>
<datasync name="employee" site="B">
<syncdata name="id">2345</syncdata >
<syncdata name="email">*******</syncdata >
</datasync>
I use mysql master idea, not use slave idea as the way between our parent system an sub system data sync.
At every night, Out service call a bat file to execute some command and generate the update sql from mysqlbinlog, then according this sql, we can know which data changed, according requirement to analysis the update sql, and update data to each sub system and parent system.