Java同步不同服务器中的两个表的有效方法 [英] efficient method to sync up two tables in different servers with java

查看:395
本文介绍了Java同步不同服务器中的两个表的有效方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个源表,该表是从各种外部系统更新的.我要求目标表(在其他服务器中)与此源表同步.目标表不是源表的精确副本,在将数据插入/更新到目标表之前必须进行一些数据处理.

we have a source table which is updated from various external systems. i require the destination table (in different server) to be in sync with this source table. the destination table is not an exact replica of the source table, some data processing has to be done before the data is inserted/updated into destination table.

我想到了以下逻辑

每隔15分钟,我们运行一次Java消费者代码,该代码将获取创建时间戳的记录,而不是先前更新的记录并将其存储在CachedRowSet中.并以CachedRowSet作为参数调用存储过程,在此过程中完成数据处理并将数据插入/更新到目标表中.

every 15min we run this java consumer code which fetches the records where the timestamp is created than that of previous update and stored in a CachedRowSet. and call a stored procedure with CachedRowSet as parameter, where the data processing is done and the data is inserted/updated into the destination table.

您认为上面提到的方法是一种有效的方法,因为我们每次更新都会处理超过一百万条记录吗?

do you believe above mentioned is an efficient way as we are dealing over a million records every update ?

当在源表中删除记录时,也不会以上述方法复制!你能建议在这种情况下怎么做

also when a record is deleted in the source table in would not be replicated in the above method ! can you suggest what to do in such scenario

推荐答案

类似于数据库用于保存点和回滚的技术. 每当源表中有任何更改时,例如CRUD.保持更改脚本符合目标表所需的格式.您可以定期将这些更改推送到目标服务器.由于您的源表已由各种外部系统更新,因此您需要在源表上具有触发器以保存脚本日志.

Something similar to technique used by database for save point and rollback. Whenever there is some change in the source table e.g. CRUD. keep the scripts of change as per format required to the target table. periodically you can push those changes to the target server. As your source table is updated by various external system, you'll need to have trigger on your source table for keeping script logs.

这篇关于Java同步不同服务器中的两个表的有效方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆