《无线互联科技》杂志社 ›› 2025, Vol. 22 ›› Issue (1): 102-107.

• 研究创新 • 上一篇    下一篇

高实时国产数据库数据同步共享

崔宇, 何伟, 栗高尚, 姚万华, 姚克   

  1. 中国电子科技集团公司第二十八研究所,江苏 南京 210028
  • 出版日期:2025-01-10 发布日期:2025-03-21
  • 作者简介:崔宇(1991— ),男,工程师,硕士;研究方向:软件工程。

High real-time data synchronization sharing scheme of domestic database

CUI Yu, HE Wei, LI Gaoshang, YAO Wanhua, YAO Ke   

  1. The 28th Research Institute of China Electronics Technology Group Corporation, Nanjing 210028, China
  • Online:2025-01-10 Published:2025-03-21

摘要: 面对部分国产非公开数据库日志格式的数据库数据高实时共享同步问题,文章设计了一种基于ThreadLocal和双切面的数据同步共享方案。通过在Dao层切面采集Web请求响应过程中对数据库的所有变更记录,暂存在ThreadLocal中;在Controller层切面拦截响应,从ThreadLocal提取出所有变更记录,最后通过传输管理模块将变更记录共享发送给其他系统,实现数据库数据的增量共享。实验对比发现方案采集时间、发送时间相对于业务操作时间占比极低,这是因为数据采集、发送等操作均在本地内存中进行,而业务操作依赖于数据库网络IO,所以该方案能够实现国产数据库数据同步共享,具备较高的实时性和较低的侵入性。

关键词: 数据共享, 切面, ThreadLocal, 国产数据库, 高实时

Abstract: Faced with the problem of high real-time sharing and synchronization of database data in log format of some domestic non-public databases, a data synchronization sharing scheme based on ThreadLocal and dual aspects was designed. Collect all change records to the database in the process of Web request response in the Dao layer aspect, and temporarily store them in ThreadLocal; Intercept the response at the Controller layer, extract all change records from ThreadLocal, and finally share the change records to other systems through the transmission management module to achieve incremental sharing of database data. Through experimental comparison, it is found that the acquisition time and transmission time of the scheme account for a very low proportion compared with the business operation time. This is because the data acquisition and transmission operations are carried out in the local memory, and the business operation depends on the database network IO. Therefore, the scheme can realize the synchronous sharing of data in the domestic database, with high real-time and low intrusion.

Key words: data sharing, aspect, ThreadLocal, domestic database, high real-time

中图分类号: