CN118842807A - Data synchronization module, data synchronization system and data synchronization method - Google Patents
Data synchronization module, data synchronization system and data synchronization method Download PDFInfo
- Publication number
- CN118842807A CN118842807A CN202411015981.7A CN202411015981A CN118842807A CN 118842807 A CN118842807 A CN 118842807A CN 202411015981 A CN202411015981 A CN 202411015981A CN 118842807 A CN118842807 A CN 118842807A
- Authority
- CN
- China
- Prior art keywords
- data
- data synchronization
- communication middleware
- synchronization module
- unit
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/01—Protocols
- H04L67/10—Protocols in which an application is distributed across nodes in the network
- H04L67/1095—Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/2866—Architectures; Arrangements
- H04L67/288—Distributed intermediate devices, i.e. intermediate devices for interaction with other intermediate devices on the same level
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L67/00—Network arrangements or protocols for supporting network services or applications
- H04L67/50—Network services
- H04L67/75—Indicating network or usage conditions on the user display
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Multi Processors (AREA)
Abstract
本申请提供了一种数据同步模块、数据同步系统和数据同步方法,数据同步模块包括通信中间件、视图更新单元以及视图单元;其中:通信中间件用于向其他通信中间件订阅第一目标数据;视图单元用于显示用户界面;视图更新单元用于向通信中间件订阅第二目标数据,并根据第二目标数据更新视图单元显示的用户界面,第二目标数据包括第一目标数据。该数据同步模块基于通信中间件至少能够实现跨应用的分布式MVVM,可以把一个分布式系统基本开发完成,在一个应用上的数据可以同步更新到其他应用,解决了现有技术只能实现同一应用不同界面之间的数据同步,不可以实现不同应用的数据同步的问题,极大的缩减了分布式架构的开发成本。
The present application provides a data synchronization module, a data synchronization system and a data synchronization method, wherein the data synchronization module includes a communication middleware, a view update unit and a view unit; wherein: the communication middleware is used to subscribe to first target data from other communication middleware; the view unit is used to display a user interface; the view update unit is used to subscribe to second target data from the communication middleware, and update the user interface displayed by the view unit according to the second target data, and the second target data includes the first target data. The data synchronization module can at least realize distributed MVVM across applications based on the communication middleware, and can basically complete the development of a distributed system. The data on one application can be synchronized and updated to other applications, which solves the problem that the prior art can only realize data synchronization between different interfaces of the same application, but cannot realize data synchronization between different applications, and greatly reduces the development cost of the distributed architecture.
Description
技术领域Technical Field
本申请涉及数据传输领域,具体而言,涉及一种数据同步模块、数据同步系统、数据同步方法、计算机可读存储介质和电子设备。The present application relates to the field of data transmission, and in particular, to a data synchronization module, a data synchronization system, a data synchronization method, a computer-readable storage medium, and an electronic device.
背景技术Background Art
在UI(User Interface,用户界面)开发相关的架构中,MVC(Model-View-Controller,模型-视图-控制器)、MVP(Model-View-Presenter,模型-视图-协调器)、MVVM(Model-View-ViewModel,模型-视图-视图模型)是常用的三种架构模式,这三种模式都将视图和业务分离,有效的提高了开发效率。这三种架构模式有较强的相关性,又有显著的不同。In the architecture related to UI (User Interface) development, MVC (Model-View-Controller), MVP (Model-View-Presenter), and MVVM (Model-View-ViewModel) are three commonly used architecture patterns. These three patterns separate the view and the business, effectively improving the development efficiency. These three architecture patterns are highly related, but also significantly different.
其中,MVP模式将MVC模式中的Controller改成Presenter,同时改变了通信的方向,使得业务耦合性进一步降低,但是Presenter会变得比较厚重,所有业务逻辑都需要经过Presenter。MVVM模式进一步将MVP模式中的Presenter改成ViewModel,降低了开发使用控制模块的复杂性,从面向控制的开发转到面向数据开发,使得UI开发和业务逻辑开发彻底解耦,极大的提高了开发效率。Among them, the MVP mode changes the Controller in the MVC mode to the Presenter, and changes the direction of communication, which further reduces business coupling, but the Presenter becomes heavier, and all business logic needs to go through the Presenter. The MVVM mode further changes the Presenter in the MVP mode to the ViewModel, reducing the complexity of developing and using control modules, and shifting from control-oriented development to data-oriented development, which completely decouples UI development and business logic development, greatly improving development efficiency.
但是现有的MVVM框架只能实现在一个进程内,无法实现多进程或跨终端的MVVM框架。举例来说,现有的MVVM框架只能实现同一应用不同界面之间的数据同步,无法实现界面不同应用不同甚至时分布式应用的数据同步问题,并且现有的MVVM框架的订阅/发布及Watcher机制都是各种MVVM私有实现,和编程语言强相关,不同的编程语言之间无法交互。However, the existing MVVM framework can only be implemented within one process, and cannot be implemented in multiple processes or across terminals. For example, the existing MVVM framework can only synchronize data between different interfaces of the same application, and cannot synchronize data between different interfaces and different applications or even distributed applications. In addition, the subscription/publishing and Watcher mechanisms of the existing MVVM framework are all private implementations of various MVVMs, which are strongly related to the programming language, and different programming languages cannot interact with each other.
发明内容Summary of the invention
本申请的主要目的在于提供一种数据同步模块、数据同步系统、数据同步方法、计算机可读存储介质和电子设备,以至少解决现有技术只能实现同一应用不同界面之间的数据同步,不可以实现不同应用的数据同步的问题。The main purpose of the present application is to provide a data synchronization module, a data synchronization system, a data synchronization method, a computer-readable storage medium and an electronic device, so as to at least solve the problem that the prior art can only realize data synchronization between different interfaces of the same application, but cannot realize data synchronization between different applications.
为了实现上述目的,根据本申请的一个方面,提供了一种数据同步模块,包括通信中间件、视图更新单元以及视图单元;其中:所述通信中间件用于向其他通信中间件订阅第一目标数据;所述视图单元用于显示用户界面;所述视图更新单元用于向所述通信中间件订阅第二目标数据,并根据所述第二目标数据更新所述视图单元显示的所述用户界面,所述第二目标数据包括所述第一目标数据。In order to achieve the above-mentioned purpose, according to one aspect of the present application, a data synchronization module is provided, including a communication middleware, a view update unit and a view unit; wherein: the communication middleware is used to subscribe to first target data from other communication middleware; the view unit is used to display a user interface; the view update unit is used to subscribe to second target data from the communication middleware, and update the user interface displayed by the view unit according to the second target data, and the second target data includes the first target data.
可选地,所述数据同步模块还包括监听单元和模型单元;其中:所述视图单元还用于接收基于所述用户界面的交互数据;所述监听单元用于监听所述交互数据,并在监听到所述交互数据时将所述交互数据更新至所述模型单元;所述模型单元用于处理所述交互数据得到处理数据;所述通信中间件还用于监听所述处理数据,并在监听到所述处理数据时发布所述处理数据。Optionally, the data synchronization module also includes a monitoring unit and a model unit; wherein: the view unit is also used to receive interaction data based on the user interface; the monitoring unit is used to monitor the interaction data, and update the interaction data to the model unit when the interaction data is monitored; the model unit is used to process the interaction data to obtain processed data; the communication middleware is also used to monitor the processed data, and publish the processed data when the processed data is monitored.
可选地,所述通信中间件具体用于向所述视图更新单元发布所述处理数据,所述第二目标数据还包括所述处理数据,和/或,所述通信中间件具体用于向订阅所述处理数据的其他所述通信中间件发布所述处理数据;和/或,所述通信中间件采用DDS协议。Optionally, the communication middleware is specifically used to publish the processed data to the view update unit, the second target data also includes the processed data, and/or the communication middleware is specifically used to publish the processed data to other communication middleware that subscribes to the processed data; and/or the communication middleware adopts the DDS protocol.
根据本申请的另一方面,提供了一种数据同步系统,包括第一数据同步模块和第二数据同步模块,所述第一数据同步模块和所述第二数据同步模块为根据任意一种所述的数据同步模块;其中:所述第一数据同步模块包括的第一通信中间件用于向所述第二数据同步模块包括的第二通信中间件订阅第一目标数据;所述第二通信中间件用于向所述第一通信中间件发布所述第一目标数据。According to another aspect of the present application, a data synchronization system is provided, comprising a first data synchronization module and a second data synchronization module, wherein the first data synchronization module and the second data synchronization module are data synchronization modules according to any one of the above; wherein: the first communication middleware included in the first data synchronization module is used to subscribe to first target data to the second communication middleware included in the second data synchronization module; and the second communication middleware is used to publish the first target data to the first communication middleware.
可选地,所述第一数据同步模块和所述第二数据同步模块为同一应用中的不同模块;或者,所述第一数据同步模块和所述第二数据同步模块为同一设备中的不同进程;或者,所述第一数据同步模块和所述第二数据同步模块为同一分布式系统中的不同设备。Optionally, the first data synchronization module and the second data synchronization module are different modules in the same application; or, the first data synchronization module and the second data synchronization module are different processes in the same device; or, the first data synchronization module and the second data synchronization module are different devices in the same distributed system.
根据本申请的另一方面,提供了一种数据同步方法,所述数据同步方法基于根据任意一种所述的数据同步模块实现,所述数据同步方法包括:通信中间件向其他通信中间件订阅第一目标数据;视图更新单元向所述通信中间件订阅第二目标数据,并根据所述第二目标数据更新视图单元显示的所述用户界面,所述第二目标数据包括所述第一目标数据。According to another aspect of the present application, a data synchronization method is provided, and the data synchronization method is implemented based on the data synchronization module according to any one of the above, and the data synchronization method includes: a communication middleware subscribes to first target data from other communication middleware; a view update unit subscribes to second target data from the communication middleware, and updates the user interface displayed by the view unit according to the second target data, and the second target data includes the first target data.
可选地,所述数据同步模块还包括监听单元和模型单元;所述数据同步方法包括:所述视图单元接收基于所述用户界面的交互数据;所述监听单元监听所述交互数据,并在监听到所述交互数据时将所述交互数据更新至所述模型单元;所述模型单元处理所述交互数据得到处理数据;所述通信中间件监听所述处理数据,并在监听到所述处理数据时发布所述处理数据。Optionally, the data synchronization module also includes a monitoring unit and a model unit; the data synchronization method includes: the view unit receives interaction data based on the user interface; the monitoring unit monitors the interaction data and updates the interaction data to the model unit when the interaction data is monitored; the model unit processes the interaction data to obtain processed data; the communication middleware monitors the processed data and publishes the processed data when the processed data is monitored.
可选地,所述并在监听到所述处理数据时发布所述处理数据,包括:所述通信中间件向所述视图更新单元发布所述处理数据,所述第二目标数据还包括所述处理数据,和/或,所述通信中间件向订阅所述处理数据的其他所述通信中间件发布所述处理数据;和/或,所述通信中间件采用DDS协议。Optionally, the processing data is published when the processing data is monitored, including: the communication middleware publishes the processing data to the view update unit, the second target data also includes the processing data, and/or the communication middleware publishes the processing data to other communication middleware that subscribes to the processing data; and/or the communication middleware adopts the DDS protocol.
根据本申请的另一方面,提供了一种计算机可读存储介质,所述计算机可读存储介质包括存储的程序,其中,在所述程序运行时控制所述计算机可读存储介质所在设备执行任意一种所述的数据同步方法。According to another aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute any one of the data synchronization methods.
根据本申请的另一方面,提供了一种电子设备,包括:一个或多个处理器,存储器,以及一个或多个程序,其中,所述一个或多个程序被存储在所述存储器中,并且被配置为由所述一个或多个处理器执行,所述一个或多个程序包括用于执行任意一种所述的数据同步方法。According to another aspect of the present application, an electronic device is provided, comprising: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include means for executing any one of the data synchronization methods.
应用本申请的技术方案,上述数据同步模块,包括通信中间件、视图更新单元以及视图单元;其中:通信中间件用于向其他通信中间件订阅第一目标数据;视图单元用于显示用户界面;视图更新单元用于向通信中间件订阅第二目标数据,并根据第二目标数据更新视图单元显示的用户界面,第二目标数据包括第一目标数据。该数据同步模块基于通信中间件至少能够实现跨应用的分布式MVVM,可以把一个分布式系统基本开发完成,在一个应用上的数据可以同步更新到其他应用,解决了现有技术只能实现同一应用不同界面之间的数据同步,不可以实现不同应用的数据同步的问题,极大的缩减了分布式架构的开发成本。Applying the technical solution of the present application, the above-mentioned data synchronization module includes a communication middleware, a view update unit and a view unit; wherein: the communication middleware is used to subscribe to the first target data from other communication middleware; the view unit is used to display the user interface; the view update unit is used to subscribe to the second target data from the communication middleware, and update the user interface displayed by the view unit according to the second target data, and the second target data includes the first target data. The data synchronization module can at least realize distributed MVVM across applications based on the communication middleware, and can basically complete the development of a distributed system. The data on one application can be synchronized and updated to other applications, which solves the problem that the prior art can only realize data synchronization between different interfaces of the same application, but cannot realize data synchronization between different applications, and greatly reduces the development cost of the distributed architecture.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
构成本申请的一部分的说明书附图用来提供对本申请的进一步理解,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。在附图中:The drawings constituting part of the present application are used to provide a further understanding of the present application. The exemplary embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
图1示出了根据本申请的实施例提供的一种数据同步模块的结构示意图;FIG1 shows a schematic diagram of the structure of a data synchronization module provided according to an embodiment of the present application;
图2示出了根据本申请的实施例提供的另一种数据同步模块的结构示意图;FIG2 shows a schematic diagram of the structure of another data synchronization module provided according to an embodiment of the present application;
图3示出了根据本申请的实施例提供的一种数据同步系统的结构示意图;FIG3 shows a schematic diagram of the structure of a data synchronization system provided according to an embodiment of the present application;
图4示出了根据本申请的实施例提供的另一种数据同步系统的结构示意图;FIG4 shows a schematic diagram of the structure of another data synchronization system provided according to an embodiment of the present application;
图5示出了根据本申请的实施例提供的一种数据同步方法的流程示意图。FIG5 shows a schematic flow chart of a data synchronization method provided according to an embodiment of the present application.
其中,上述附图包括以下附图标记:The above drawings include the following reference numerals:
01、第一数据同步模块;02、第二数据同步模块;10、通信中间件;11、第一通信中间件;12、第二通信中间件;20、视图更新单元;21、第一视图更新单元;22、第二视图更新单元;30、视图单元;31、第一视图单元;32、第二视图单元;40、监听单元;41、第一监听单元;42、第二监听单元;50、模型单元;51、第一模型单元;52、第二模型单元。01. First data synchronization module; 02. Second data synchronization module; 10. Communication middleware; 11. First communication middleware; 12. Second communication middleware; 20. View update unit; 21. First view update unit; 22. Second view update unit; 30. View unit; 31. First view unit; 32. Second view unit; 40. Listening unit; 41. First listening unit; 42. Second listening unit; 50. Model unit; 51. First model unit; 52. Second model unit.
具体实施方式DETAILED DESCRIPTION
需要说明的是,在不冲突的情况下,本申请中的实施例及实施例中的特征可以相互组合。下面将参考附图并结合实施例来详细说明本申请。It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
为了使本技术领域的人员更好地理解本申请方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分的实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本申请保护的范围。In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
需要说明的是,本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本申请的实施例。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
为了便于描述,以下对本申请实施例涉及的部分名词或术语进行说明:For the convenience of description, some nouns or terms involved in the embodiments of the present application are explained below:
MVC:Model-View-Controller,模型-视图-控制器,其中,View(视图)为用户提供使用界面,与用户直接进行交互;Model(模型)根据业务规则设计的数据模型,承载数据;Controller(控制器)根据用户请求做相应的处理,并根据Model计算的结果返回给View,在传统的MVC架构中,视图层可以和Model相互访问;MVC: Model-View-Controller, Model-View-Controller, in which View provides the user with an interface and interacts directly with the user; Model is a data model designed according to business rules and carries data; Controller processes the user's request accordingly and returns the result calculated by Model to View. In the traditional MVC architecture, the view layer can access the Model.
MVP:Model-View-Presenter,模型-视图-协调器,其中,View和Model不再直接交互,所有业务逻辑都需要经过Presenter;MVP: Model-View-Presenter, Model-View-Coordinator, in which View and Model no longer interact directly, and all business logic needs to go through Presenter;
MVVM:Model-View-ViewModel,模型-视图-视图模型;MVVM: Model-View-ViewModel, Model-View-ViewModel;
DDS:Data Distribution Service,数据分发服务,DDS是由对象管理组织(ObjectManagement Group,简称OMG)发布的中间件标准和应用程序接口(API),采用分布式订阅/发布架构,DDS为分布式系统提供了低延时、高可靠性、可扩展的通信架构标准,DDS目前在工业、医疗、交通、能源、国防等领域都有广泛的应用;DDS: Data Distribution Service, data distribution service, DDS is a middleware standard and application program interface (API) released by the Object Management Group (OMG), using a distributed subscription/publishing architecture. DDS provides a low-latency, high-reliability, and scalable communication architecture standard for distributed systems. DDS is currently widely used in industry, medical care, transportation, energy, national defense, and other fields;
Qos:Quality Of Service,服务质量,Qos是指一个网络能够利用各种基础技术,为指定的网络通信提供更好的服务能力,是网络的一种安全机制,是用来解决网络延迟和阻塞等问题的一种技术,DDS提供了多达22种的Qos,可单独或者组合应用;Qos: Quality Of Service, service quality, Qos refers to a network's ability to use various basic technologies to provide better service capabilities for specified network communications. It is a network security mechanism and a technology used to solve problems such as network delays and congestion. DDS provides up to 22 types of Qos, which can be used individually or in combination;
Vue:一套动态构建用户界面的渐进式JavaScript框架;Vue - a progressive JavaScript framework for dynamically building user interfaces.
Angular:是一款构建用户界面的前端框架;Angular: is a front-end framework for building user interfaces;
WPF:Windows Presentation Foundation,Windows呈现基础,是微软推出的基于Windows的用户界面框架。WPF: Windows Presentation Foundation, Windows Presentation Foundation, is a Windows-based user interface framework launched by Microsoft.
正如背景技术中所介绍的,现有的MVVM框架只能实现在一个进程内,无法实现多进程或跨终端的MVVM框架,为解决现有技术只能实现同一应用不同界面之间的数据同步,不可以实现不同应用的数据同步的问题,本申请的实施例提供了一种数据同步模块、数据同步系统、数据同步方法、计算机可读存储介质和电子设备。As introduced in the background technology, the existing MVVM framework can only be implemented within one process, and cannot implement a multi-process or cross-terminal MVVM framework. In order to solve the problem that the existing technology can only realize data synchronization between different interfaces of the same application, but cannot realize data synchronization between different applications, the embodiments of the present application provide a data synchronization module, a data synchronization system, a data synchronization method, a computer-readable storage medium and an electronic device.
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述。The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention.
本申请实施例提供了一种数据同步模块,如图1所示,包括通信中间件10、视图更新单元20以及视图单元30;其中:上述通信中间件10用于向其他通信中间件订阅第一目标数据;上述视图单元30用于显示用户界面;上述视图更新单元20用于向上述通信中间件10订阅第二目标数据,并根据上述第二目标数据更新上述视图单元30显示的上述用户界面,上述第二目标数据包括上述第一目标数据。An embodiment of the present application provides a data synchronization module, as shown in Figure 1, including a communication middleware 10, a view update unit 20 and a view unit 30; wherein: the above-mentioned communication middleware 10 is used to subscribe to first target data from other communication middleware; the above-mentioned view unit 30 is used to display a user interface; the above-mentioned view update unit 20 is used to subscribe to second target data from the above-mentioned communication middleware 10, and update the above-mentioned user interface displayed by the above-mentioned view unit 30 according to the above-mentioned second target data, and the above-mentioned second target data includes the above-mentioned first target data.
当前使用MVVM架构的有主流的前端框架的Vue、angular、微软的WPF(WindowsPresentation Foundation)等。Mvvm的实现原理大同小异,以Vue为例:MVVM作为数据绑定的入口,整合Observer(观测器)、Compile(编译器)和Watcher(监视器)三者,通过Observer来监听自己的model数据变化,通过Compile来解析编译模板指令,最终利用Watcher搭起Observer和Compile之间的通信桥梁,达到数据变化到视图更新;视图交互变化(input)到数据model变更的双向绑定效果。Currently, mainstream front-end frameworks such as Vue, Angular, and Microsoft's WPF (Windows Presentation Foundation) use the MVVM architecture. The implementation principles of MVVM are similar. Take Vue as an example: MVVM is used as the entry point for data binding, integrating Observer, Compile, and Watcher. Observer is used to monitor changes in model data, Compile is used to parse and compile template instructions, and Watcher is used to build a communication bridge between Observer and Compile, achieving a two-way binding effect from data changes to view updates and from view interaction changes (input) to data model changes.
实现compile:进行模板的编译,包括编译元素(指令)、编译文本等,达到初始化视图的目的,并且还需要绑定好更新函数;Implement compile: compile the template, including compiling elements (instructions), compiling text, etc., to achieve the purpose of initializing the view, and also need to bind the update function;
实现Observer:监听所有的数据,并对变化数据发布通知;Implement Observer: monitor all data and issue notifications for changed data;
实现watcher:作为一个中枢,接收到observer发来的通知,并执行compile中相应的更新方法。Implement watcher: As a hub, it receives notifications from observer and executes the corresponding update method in compile.
但是现有的MVVM框架只能实现在进程内,无法实现多进程或跨主机的MVVM框架。举例来说,现有的MVVM框架只能实现同一应用不同界面之间的数据同步,无法实现不同应用甚至是分布式应用的数据同步。并且现有框架的订阅/发布及Watcher机制都是各种MVVM私有实现,和编程语言强相关,不同的编程语言之间无法交互。However, the existing MVVM framework can only be implemented within the process, and cannot be implemented as a multi-process or cross-host MVVM framework. For example, the existing MVVM framework can only synchronize data between different interfaces of the same application, and cannot synchronize data between different applications or even distributed applications. In addition, the subscription/publishing and Watcher mechanisms of the existing framework are all private implementations of various MVVMs, which are strongly related to the programming language, and different programming languages cannot interact with each other.
本申请的上述数据同步模块,包括通信中间件、视图更新单元以及视图单元;其中:通信中间件用于向其他通信中间件订阅第一目标数据;视图单元用于显示用户界面;视图更新单元用于向通信中间件订阅第二目标数据,并根据第二目标数据更新视图单元显示的用户界面,第二目标数据包括第一目标数据。该数据同步模块基于通信中间件至少能够实现跨应用的分布式MVVM,可以把一个分布式系统基本开发完成,在一个应用上的数据可以同步更新到其他应用,解决了现有技术只能实现同一应用不同界面之间的数据同步,不可以实现不同应用的数据同步的问题,极大的缩减了分布式架构的开发成本。The above-mentioned data synchronization module of the present application includes a communication middleware, a view update unit and a view unit; wherein: the communication middleware is used to subscribe to the first target data from other communication middleware; the view unit is used to display the user interface; the view update unit is used to subscribe to the second target data from the communication middleware, and update the user interface displayed by the view unit according to the second target data, and the second target data includes the first target data. The data synchronization module can at least realize distributed MVVM across applications based on the communication middleware, and can basically complete the development of a distributed system. The data on one application can be synchronized and updated to other applications, which solves the problem that the prior art can only realize data synchronization between different interfaces of the same application, but cannot realize data synchronization between different applications, and greatly reduces the development cost of the distributed architecture.
一些实例中,如图2所示,上述数据同步模块还包括监听单元40和模型单元50;其中:上述视图单元30还用于接收基于上述用户界面的交互数据;上述监听单元40用于监听上述交互数据,并在监听到上述交互数据时将上述交互数据更新至上述模型单元50;上述模型单元50用于处理上述交互数据得到处理数据;上述通信中间件10还用于监听上述处理数据,并在监听到上述处理数据时发布上述处理数据。In some instances, as shown in FIG. 2 , the data synchronization module further includes a monitoring unit 40 and a model unit 50; wherein: the view unit 30 is also used to receive interaction data based on the user interface; the monitoring unit 40 is used to monitor the interaction data, and update the interaction data to the model unit 50 when the interaction data is monitored; the model unit 50 is used to process the interaction data to obtain processed data; the communication middleware 10 is also used to monitor the processed data, and publish the processed data when the processed data is monitored.
具体地,监听单元用于监听交互数据,可以确保数据传输的实时性。Specifically, the monitoring unit is used to monitor the interactive data, which can ensure the real-time performance of data transmission.
其中,数据同步模块采用MVVM架构,即模型-视图-视图模型架构,并且本实例中至少包括监听单元、视图更新单元和通信中间件的组合提供了一种新的视图模型设计。The data synchronization module adopts the MVVM architecture, namely the model-view-viewmodel architecture, and the combination of at least a monitoring unit, a view updating unit and a communication middleware in this example provides a new view model design.
一些实例中,如图2所示,上述通信中间件10具体用于向上述视图更新单元20发布上述处理数据,上述第二目标数据还包括上述处理数据,和/或,上述通信中间件10具体用于向订阅上述处理数据的其他上述通信中间件10发布上述处理数据;和/或,上述通信中间件10采用DDS协议。In some instances, as shown in FIG. 2 , the communication middleware 10 is specifically used to publish the processed data to the view update unit 20, the second target data also includes the processed data, and/or the communication middleware 10 is specifically used to publish the processed data to other communication middlewares 10 that subscribe to the processed data; and/or the communication middleware 10 adopts the DDS protocol.
其中,通信中间件通过DDS将向订阅处理数据的其他上述通信中间件发布处理数据,可以突破进程内的限制,实现进程内、进程间、跨主机(终端)的数据传输。Among them, the communication middleware will publish the processed data to other communication middleware that subscribes to the processed data through DDS, which can break through the limitations within the process and realize data transmission within the process, between processes, and across hosts (terminals).
具体地,DDS由多种传输机制来保证实体之间的通信服务,其中包括:用户数据报协议(user datagram protocol,简称udp)、传输控制协议(transmission controlprotocol,简称tcp)、共享内存(sharedmemory,简称SHM)传输、Data-sharing(数据共享)和进程内交付,udp/tcp一般用于不同的主机间传输,SHM传输用于在同一主机上运行的实体之间的共享内存通信,Data-sharing通过共享内存及零拷贝技术,从而加快同一主机内实体之间的通信,避免了传输层中设计的任何开销,进程内交付为发布者直接调用订阅者的接收函数,完全避免传输的复制或发送操作,同时避免了确实机制。Specifically, DDS uses a variety of transmission mechanisms to ensure communication services between entities, including: User Datagram Protocol (UDP), Transmission Control Protocol (TCP), Shared Memory (SHM) transmission, Data-sharing (data sharing) and in-process delivery. UDP/TCP is generally used for transmission between different hosts. SHM transmission is used for shared memory communication between entities running on the same host. Data-sharing uses shared memory and zero-copy technology to speed up communication between entities in the same host, avoiding any overhead designed in the transport layer. In-process delivery is for the publisher to directly call the subscriber's receiving function, completely avoiding the copying or sending operations of the transmission, and at the same time avoiding the confirmation mechanism.
其中,DDS提供了多达22种的Qos,可单独或者组合应用。DDS还包括DDS Discovery机制,即通过多播或者发现服务器来交换不同的DDS实体之间的信息,以达到彼此互相订阅和发布功能。DDS provides up to 22 types of QoS, which can be used individually or in combination. DDS also includes a DDS Discovery mechanism, which exchanges information between different DDS entities through multicast or discovery servers to achieve mutual subscription and publishing functions.
因此,图2中基于DDS的MVVM架构极大的简化了带View显示的分布式系统,简化了多终端开发的复杂性,使得不同系统、不同编程语言、不同终端能基于相同的数据模型互相交互。Therefore, the DDS-based MVVM architecture in Figure 2 greatly simplifies the distributed system with View display and the complexity of multi-terminal development, allowing different systems, different programming languages, and different terminals to interact with each other based on the same data model.
本申请实施例提供了一种数据同步系统,如图3和图4所示,包括第一数据同步模块01和第二数据同步模块02,上述第一数据同步模块01和上述第二数据同步模块02为根据任意一种上述的数据同步模块;其中:上述第一数据同步模块01包括的第一通信中间件11用于向上述第二数据同步模块02包括的第二通信中间件12订阅第一目标数据;上述第二通信中间件12用于向上述第一通信中间件11发布上述第一目标数据。An embodiment of the present application provides a data synchronization system, as shown in Figures 3 and 4, including a first data synchronization module 01 and a second data synchronization module 02, wherein the first data synchronization module 01 and the second data synchronization module 02 are based on any one of the above-mentioned data synchronization modules; wherein: the first communication middleware 11 included in the first data synchronization module 01 is used to subscribe to the first target data from the second communication middleware 12 included in the second data synchronization module 02; the second communication middleware 12 is used to publish the first target data to the first communication middleware 11.
本申请的上述数据同步系统,包括第一数据同步模块和第二数据同步模块,第一数据同步模块和第二数据同步模块为根据任意一种的数据同步模块;其中:第一数据同步模块包括的第一通信中间件用于向第二数据同步模块包括的第二通信中间件订阅第一目标数据;第二通信中间件用于向第一通信中间件发布第一目标数据。该数据同步系统基于通信中间件至少能够实现跨应用的分布式MVVM,可以把一个分布式系统基本开发完成,在一个应用上的数据可以同步更新到其他应用,解决了现有技术只能实现同一应用不同界面之间的数据同步,不可以实现不同应用的数据同步的问题,极大的缩减了分布式架构的开发成本。The above-mentioned data synchronization system of the present application includes a first data synchronization module and a second data synchronization module, and the first data synchronization module and the second data synchronization module are data synchronization modules according to any one of them; wherein: the first communication middleware included in the first data synchronization module is used to subscribe the first target data to the second communication middleware included in the second data synchronization module; the second communication middleware is used to publish the first target data to the first communication middleware. The data synchronization system can at least realize distributed MVVM across applications based on the communication middleware, and can basically complete the development of a distributed system. The data on one application can be synchronized and updated to other applications, which solves the problem that the prior art can only realize data synchronization between different interfaces of the same application, but cannot realize data synchronization between different applications, and greatly reduces the development cost of the distributed architecture.
其中,如图4所示,第一数据同步模块01包括第一通信中间件11、第一视图更新单元21、第一视图单元31、第一监听单元41和第一模型单元51,第二数据同步模块02包括第二通信中间件12、第二视图更新单元22、第二视图单元32、第二监听单元42和第二模型单元52。As shown in Figure 4, the first data synchronization module 01 includes a first communication middleware 11, a first view update unit 21, a first view unit 31, a first listening unit 41 and a first model unit 51, and the second data synchronization module 02 includes a second communication middleware 12, a second view update unit 22, a second view unit 32, a second listening unit 42 and a second model unit 52.
一些实例中,上述第一数据同步模块和上述第二数据同步模块为同一应用中的不同模块;或者,上述第一数据同步模块和上述第二数据同步模块为同一设备中的不同进程;或者,上述第一数据同步模块和上述第二数据同步模块为同一分布式系统中的不同设备。In some instances, the first data synchronization module and the second data synchronization module are different modules in the same application; or, the first data synchronization module and the second data synchronization module are different processes in the same device; or, the first data synchronization module and the second data synchronization module are different devices in the same distributed system.
具体地,这样可以实现跨应用的分布式MVVM,可以把一个分布式系统基本开发完成,在一个应用上的数据可以同步更新到其他应用,解决了现有技术只能实现同一应用不同界面之间的数据同步,不可以实现不同应用的数据同步的问题,极大的缩减了分布式架构的开发成本。Specifically, this can realize distributed MVVM across applications, and can basically complete the development of a distributed system. The data on one application can be synchronized and updated to other applications, solving the problem that the existing technology can only realize data synchronization between different interfaces of the same application, but cannot realize data synchronization between different applications, greatly reducing the development cost of the distributed architecture.
其中,第一数据同步模块和第二数据同步模块预先通过DDSDiscovery机制互相发现对方,并订阅感兴趣的数据。如果第一数据同步模块和第二数据同步模块在不同的局域网内,可以通过代理服务器进行广播/监听,以与对方建立连接,这样可以实现跨终端的分布式MVVM数据同步,极大的简化了多终端开发的复杂性,使得不同系统、不同编程语言能基于相同的数据模型互相交互。Among them, the first data synchronization module and the second data synchronization module discover each other in advance through the DDSDiscovery mechanism and subscribe to the data of interest. If the first data synchronization module and the second data synchronization module are in different local area networks, they can broadcast/listen through the proxy server to establish a connection with each other, so that distributed MVVM data synchronization across terminals can be realized, which greatly simplifies the complexity of multi-terminal development and enables different systems and different programming languages to interact with each other based on the same data model.
其中,如图4所示,图中第一数据同步模块01和第二数据同步模块02表示不同分布式系统中的不同主机,或者同一主机上的不同进程,或者同一应用中的不同模块。第二数据同步模块02中的ModeView机制和第一数据同步模块01一致,但是并不限制编程语言,即第一数据同步模块01和第二数据同步模块02中可以是不同的编程语言。第一数据同步模块01和第二数据同步模块02均为MVVM架构。第一视图单元31为第一数据同步模块01的MVVM架构中的View,第一监听单元41、第一视图更新单元21、第一通信中间件11一起组成第一数据同步模块01的MVVM架构中的ModelView,第一模型单元51为第一数据同步模块01的MVVM架构中的Model;第二视图单元32为第二数据同步模块02的MVVM架构中的View,第二监听单元42、第二视图更新单元22、第二通信中间件12二起组成第二数据同步模块02的MVVM架构中的ModelView,第二模型单元52为第二数据同步模块02的MVVM架构中的Model。As shown in FIG4 , the first data synchronization module 01 and the second data synchronization module 02 in the figure represent different hosts in different distributed systems, or different processes on the same host, or different modules in the same application. The ModeView mechanism in the second data synchronization module 02 is consistent with that in the first data synchronization module 01, but does not limit the programming language, that is, the first data synchronization module 01 and the second data synchronization module 02 can be different programming languages. Both the first data synchronization module 01 and the second data synchronization module 02 are MVVM architectures. The first view unit 31 is the View in the MVVM architecture of the first data synchronization module 01, the first listening unit 41, the first view update unit 21, and the first communication middleware 11 together constitute the ModelView in the MVVM architecture of the first data synchronization module 01, and the first model unit 51 is the Model in the MVVM architecture of the first data synchronization module 01; the second view unit 32 is the View in the MVVM architecture of the second data synchronization module 02, the second listening unit 42, the second view update unit 22, and the second communication middleware 12 together constitute the ModelView in the MVVM architecture of the second data synchronization module 02, and the second model unit 52 is the Model in the MVVM architecture of the second data synchronization module 02.
本申请实施例还提供了一种数据同步方法,上述数据同步方法基于根据任意一种上述的数据同步模块实现,图5是根据本申请实施例的数据同步方法的流程图。如图5所示,上述数据同步方法包括以下步骤:The embodiment of the present application also provides a data synchronization method, which is implemented based on any of the above data synchronization modules. FIG5 is a flow chart of the data synchronization method according to the embodiment of the present application. As shown in FIG5, the data synchronization method includes the following steps:
步骤S201,通信中间件向其他通信中间件订阅第一目标数据;Step S201, the communication middleware subscribes to the first target data from other communication middleware;
步骤S202,视图更新单元向上述通信中间件订阅第二目标数据,并根据上述第二目标数据更新视图单元显示的上述用户界面,上述第二目标数据包括上述第一目标数据。Step S202: the view updating unit subscribes to second target data from the communication middleware, and updates the user interface displayed by the view unit according to the second target data, wherein the second target data includes the first target data.
一些实例中,上述数据同步模块还包括监听单元和模型单元;上述数据同步方法包括:上述视图单元接收基于上述用户界面的交互数据;上述监听单元监听上述交互数据,并在监听到上述交互数据时将上述交互数据更新至上述模型单元;上述模型单元处理上述交互数据得到处理数据;上述通信中间件监听上述处理数据,并在监听到上述处理数据时发布上述处理数据。In some instances, the data synchronization module further includes a monitoring unit and a model unit; the data synchronization method includes: the view unit receives interaction data based on the user interface; the monitoring unit monitors the interaction data, and updates the interaction data to the model unit when the interaction data is monitored; the model unit processes the interaction data to obtain processed data; the communication middleware monitors the processed data, and publishes the processed data when the processed data is monitored.
其中,监听单元实时监听数据,可以确保数据的实时性,将数据实时存储至模型单元可以保证数据不会丢失。Among them, the monitoring unit monitors the data in real time to ensure the real-time nature of the data, and stores the data in the model unit in real time to ensure that the data will not be lost.
其中,交互数据为数据同步模块中的View改变时相应改变的数据,而数据同步模块中的View改变时会有多个数据进行变化,交互数据为前期设定好的需要同步的数据内容。Among them, the interactive data is the data that changes accordingly when the View in the data synchronization module changes. When the View in the data synchronization module changes, multiple data will change. The interactive data is the data content that needs to be synchronized that was set in the early stage.
视图更新单元通过读取处理数据来对视图单元中的视图进行更新,可以确保数据更新的实时性。The view update unit updates the view in the view unit by reading and processing data, thereby ensuring the real-time nature of data update.
例如,手机和平板打开同一个应用,手机上对该应用进行了一些操作使得该应用的画面进行了改变,那么该应用的后台数据也会相应改变,而用户想要平板上该应用的画面与手机上该应用的画面进行同步变化,那么就会将变更后画面对应的数据确定为交互数据从手机上传输至平板上以使得平板上的画面与手机同步改变,这样可以实现不同终端之间的数据同步。For example, a mobile phone and a tablet open the same application, and some operations are performed on the mobile phone to change the screen of the application, then the background data of the application will also change accordingly, and the user wants the screen of the application on the tablet to change synchronously with the screen of the application on the mobile phone, then the data corresponding to the changed screen will be determined as interactive data and transmitted from the mobile phone to the tablet so that the screen on the tablet changes synchronously with the mobile phone, thus realizing data synchronization between different terminals.
一些实例中,在监听到上述处理数据时发布上述处理数据,包括:上述通信中间件向上述视图更新单元发布上述处理数据,上述第二目标数据还包括上述处理数据,和/或,上述通信中间件向订阅上述处理数据的其他上述通信中间件发布上述处理数据;和/或,上述通信中间件采用DDS协议。In some instances, the processing data is published when it is monitored, including: the communication middleware publishes the processing data to the view update unit, the second target data also includes the processing data, and/or the communication middleware publishes the processing data to other communication middlewares that subscribe to the processing data; and/or the communication middleware adopts the DDS protocol.
具体地,通信中间件通过DDS将处理数据传输至另一终端上,或者传输至另一进程上,可以突破进程内的限制,实现进程内、进程间、跨主机(终端)的数据传输。Specifically, the communication middleware transmits the processed data to another terminal or to another process through DDS, which can break through the limitations within the process and realize data transmission within the process, between processes, and across hosts (terminals).
其中,基于如图4所示的数据同步系统,本申请的实施例还包括如下步骤:Wherein, based on the data synchronization system shown in FIG4 , the embodiment of the present application further includes the following steps:
步骤S301,根据上述第一数据同步模块的数据传输条件,确定符合上述数据传输条件的服务质量传输策略为第一服务质量传输策略,上述数据传输条件包括数据传输准确度和数据传输速度,上述第一服务质量传输策略为第一通信中间件的服务质量传输策略;Step S301, according to the data transmission condition of the first data synchronization module, determining that the service quality transmission strategy that meets the data transmission condition is the first service quality transmission strategy, the data transmission condition includes data transmission accuracy and data transmission speed, and the first service quality transmission strategy is the service quality transmission strategy of the first communication middleware;
步骤S302,根据上述第一通信中间件的服务质量传输策略,确定与上述第一服务质量传输策略对应的上述服务质量传输策略为第二服务质量传输策略,上述第二服务质量传输策略为上述第二通信中间件的服务质量传输策略;Step S302, according to the service quality transmission strategy of the first communication middleware, determining that the service quality transmission strategy corresponding to the first service quality transmission strategy is a second service quality transmission strategy, and the second service quality transmission strategy is the service quality transmission strategy of the second communication middleware;
步骤S303,采用上述数据分发服务机制控制上述第一通信中间件基于上述第一服务质量传输策略将上述第一目标数据发送至上述第二通信中间件,并控制上述第二通信中间件基于上述第二服务质量传输策略接收上述第一目标数据,以将上述第一目标数据从上述第一数据同步模块同步至第二数据同步模块。Step S303, using the above-mentioned data distribution service mechanism to control the above-mentioned first communication middleware to send the above-mentioned first target data to the above-mentioned second communication middleware based on the above-mentioned first service quality transmission strategy, and control the above-mentioned second communication middleware to receive the above-mentioned first target data based on the above-mentioned second service quality transmission strategy, so as to synchronize the above-mentioned first target data from the above-mentioned first data synchronization module to the second data synchronization module.
具体地,第一服务质量传输策略与第二服务质量传输策略可以为相同的服务质量传输策略,也可以为不同的服务质量传输策略,而通过DDS设置的Qos策略,能最大限度的保证分布式MVVM的稳定性。Specifically, the first quality of service transmission strategy and the second quality of service transmission strategy can be the same quality of service transmission strategy or different quality of service transmission strategies, and the QoS strategy set by DDS can maximize the stability of distributed MVVM.
一些实例中,基于如图4所示的数据同步系统,上述第一数据同步模块采用第一编程语言,上述第二数据同步模块采用第二编程语言,上述方法还包括如下步骤:In some examples, based on the data synchronization system shown in FIG. 4 , the first data synchronization module adopts a first programming language, the second data synchronization module adopts a second programming language, and the method further includes the following steps:
步骤S401,控制上述第一通信中间件运行上述数据分发服务机制,以将上述第一目标数据的编程语言从上述第一编程语言转换为目标编程语言,得到目标语言数据,并且控制上述第一通信中间件运行上述数据分发服务机制,以将上述目标语言数据发送至上述第二通信中间件;Step S401, controlling the first communication middleware to run the data distribution service mechanism to convert the programming language of the first target data from the first programming language to the target programming language to obtain target language data, and controlling the first communication middleware to run the data distribution service mechanism to send the target language data to the second communication middleware;
步骤S402,控制上述第二通信中间件运行上述数据分发服务机制,以识别上述目标语言数据,并将上述目标语言数据的编程语言转换为上述第二编程语言,以使得上述目标语言数据从上述第一数据同步模块同步至第二数据同步模块。Step S402, controlling the second communication middleware to run the data distribution service mechanism to identify the target language data and convert the programming language of the target language data into the second programming language, so that the target language data is synchronized from the first data synchronization module to the second data synchronization module.
以一个文档评审项目为例,需求要在pc、ipad、ios、android等不同的终端上展示和操作。使用上述基于DDS的MVVM架构,基于相同的数据模型,开发人员只要关注在不同终端上的View如何呈现,然后把关心的数据通过ViewModel和Model绑定,设定DDS的服务发现机制及Qos策略,就可以把一个多终端分布式系统基本开发完成,在一个终端上的评审会立刻同步更新到其他终端,极大的缩减了分布式文档评审项目的开发。通过在ModelView中加入DDS标准协议,使得MVVM框架突破了进程内的限制,实现了分布式的MVVM框架,通过DDS丰富的Qos策略有效的解决了分布式上复杂的通信的问题,并且通过DDS实现不同MVVM实体间编程语言的无关性。Take a document review project as an example. The requirements are to display and operate on different terminals such as PC, iPad, iOS, and Android. Using the above DDS-based MVVM architecture, based on the same data model, developers only need to focus on how the View is presented on different terminals, and then bind the data of interest through ViewModel and Model, set the DDS service discovery mechanism and QoS strategy, and basically complete the development of a multi-terminal distributed system. The review on one terminal will be immediately updated to other terminals, greatly reducing the development of distributed document review projects. By adding the DDS standard protocol to ModelView, the MVVM framework breaks through the limitations of the process and realizes a distributed MVVM framework. The rich QoS strategies of DDS effectively solve the problem of complex communication in the distributed system, and the independence of programming languages between different MVVM entities is achieved through DDS.
本申请的上述数据同步方法,基于根据任意一种上述的数据同步模块实现,该数据同步方法包括:通信中间件向其他通信中间件订阅第一目标数据;视图更新单元向上述通信中间件订阅第二目标数据,并根据上述第二目标数据更新视图单元显示的上述用户界面,上述第二目标数据包括上述第一目标数据。该方法基于通信中间件的设计至少能够实现跨应用的分布式MVVM,可以把一个分布式系统基本开发完成,在一个应用上的数据可以同步更新到其他应用,解决了现有技术只能实现同一应用不同界面之间的数据同步,不可以实现不同应用的数据同步的问题,极大的缩减了分布式架构的开发成本。The above-mentioned data synchronization method of the present application is implemented based on any one of the above-mentioned data synchronization modules, and the data synchronization method includes: the communication middleware subscribes to the first target data from other communication middleware; the view update unit subscribes to the second target data from the above-mentioned communication middleware, and updates the above-mentioned user interface displayed by the view unit according to the above-mentioned second target data, and the above-mentioned second target data includes the above-mentioned first target data. This method can at least realize distributed MVVM across applications based on the design of the communication middleware, and can basically complete the development of a distributed system. The data on one application can be synchronized and updated to other applications, which solves the problem that the existing technology can only realize data synchronization between different interfaces of the same application, but cannot realize data synchronization between different applications, and greatly reduces the development cost of the distributed architecture.
为了使得本领域技术人员能够更加清楚地了解本申请的技术方案,以下将结合具体的实施例对本申请的数据同步方法的实现过程进行详细说明。In order to enable those skilled in the art to more clearly understand the technical solution of the present application, the implementation process of the data synchronization method of the present application will be described in detail below in combination with specific embodiments.
本实施例涉及一种数据同步方法,如图4所示,第一数据同步模块01和第二数据同步模块02表示不同分布式系统中的不同主机,或者同一主机上的不同进程,或者同一应用中的不同模块。以第一数据同步模块01中的View变化为例,首先第一数据同步模块01和第二数据同步模块02通过DDSDiscovery机制互相发现对方,并订阅感兴趣的数据,之后第一数据同步模块01中的第一视图单元31根据用户操作发生变化,第一监听单元41监听到第一视图单元31中的数据发生变化,即将变化的数据更新到第一模型单元51中,第一通信中间件11通过监听第一模型单元51中的数据,获取到第一模型单元51中的目标数据,之后公共DDS协议将变化的数据发布至第二通信中间件12,第二视图更新单元22获取到第二通信中间件12得到的目标数据,并根据目标数据对第二视图单元32中的视图进行更新,以实现进程内、进程间、跨终端的数据同步。This embodiment relates to a data synchronization method. As shown in FIG4 , the first data synchronization module 01 and the second data synchronization module 02 represent different hosts in different distributed systems, or different processes on the same host, or different modules in the same application. Taking the change of View in the first data synchronization module 01 as an example, firstly, the first data synchronization module 01 and the second data synchronization module 02 discover each other through the DDSDiscovery mechanism and subscribe to the data of interest. Then, the first view unit 31 in the first data synchronization module 01 changes according to the user operation, and the first monitoring unit 41 monitors the change of the data in the first view unit 31, that is, the changed data is updated to the first model unit 51. The first communication middleware 11 obtains the target data in the first model unit 51 by monitoring the data in the first model unit 51. Then, the public DDS protocol publishes the changed data to the second communication middleware 12, and the second view update unit 22 obtains the target data obtained by the second communication middleware 12, and updates the view in the second view unit 32 according to the target data, so as to realize data synchronization within the process, between processes, and across terminals.
需要说明的是,在附图的流程图示出的步骤可以在诸如一组计算机可执行指令的计算机系统中执行,并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
上述数据同步模块中还包括处理器和存储器,上述通信中间件等均作为程序单元存储在存储器中,由处理器执行存储在存储器中的上述程序单元来实现相应的功能。上述模块均位于同一处理器中;或者,上述各个模块以任意组合的形式分别位于不同的处理器中。The data synchronization module also includes a processor and a memory. The communication middleware and the like are stored in the memory as program units, and the processor executes the program units stored in the memory to implement corresponding functions. The modules are all located in the same processor; or, the modules are located in different processors in any combination.
处理器中包含内核,由内核去存储器中调取相应的程序单元。内核可以设置一个或以上,通过调整内核参数来解决现有技术只能实现同一应用不同界面之间的数据同步,不可以实现不同应用的数据同步的问题。The processor includes a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be set, and the kernel parameters can be adjusted to solve the problem that the existing technology can only synchronize data between different interfaces of the same application, but cannot synchronize data between different applications.
存储器可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM),存储器包括至少一个存储芯片。The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and/or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
本发明实施例提供了一种计算机可读存储介质,上述计算机可读存储介质包括存储的程序,其中,在上述程序运行时控制上述计算机可读存储介质所在设备执行上述数据同步方法。An embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the data synchronization method.
本发明实施例提供了一种处理器,上述处理器用于运行程序,其中,上述程序运行时执行上述数据同步方法。An embodiment of the present invention provides a processor, and the processor is used to run a program, wherein the data synchronization method is executed when the program is running.
本发明实施例提供了一种设备,设备包括处理器、存储器及存储在存储器上并可在处理器上运行的程序。An embodiment of the present invention provides a device, which includes a processor, a memory, and a program stored in the memory and executable on the processor.
本文中的设备可以是服务器、PC、PAD、手机等。The devices in this article can be servers, PCs, PADs, mobile phones, etc.
本申请还提供了一种计算机程序产品,当在数据处理设备上执行时,适于执行初始化有至少数据同步方法步骤的程序。The present application also provides a computer program product, which, when executed on a data processing device, is suitable for executing a program that initializes at least the steps of the data synchronization method.
显然,本领域的技术人员应该明白,上述的本发明的各模块或各步骤可以用通用的计算装置来实现,它们可以集中在单个的计算装置上,或者分布在多个计算装置所组成的网络上,它们可以用计算装置可执行的程序代码来实现,从而,可以将它们存储在存储装置中由计算装置来执行,并且在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤,或者将它们分别制作成各个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。这样,本发明不限制于任何特定的硬件和软件结合。Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
本申请是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present application is described with reference to the flowchart and/or block diagram of the method, device (system) and computer program product according to the embodiment of the present application. It should be understood that each process and/or box in the flowchart and/or block diagram, and the combination of the process and/or box in the flowchart and/or block diagram can be realized by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for realizing the function specified in one process or multiple processes in the flowchart and/or one box or multiple boxes in the block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions may also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and/or one or more boxes in the block diagram.
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In a typical configuration, a computing device includes one or more processors (CPU), input/output interfaces, network interfaces, and memory.
存储器可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。存储器是计算机可读介质的示例。The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and/or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括要素的过程、方法、商品或者设备中还存在另外的相同要素。It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
从以上的描述中,可以看出,本申请上述的实施例实现了如下技术效果:From the above description, it can be seen that the above embodiments of the present application achieve the following technical effects:
1)、本申请的上述数据同步模块,包括通信中间件、视图更新单元以及视图单元;其中:通信中间件用于向其他通信中间件订阅第一目标数据;视图单元用于显示用户界面;视图更新单元用于向通信中间件订阅第二目标数据,并根据第二目标数据更新视图单元显示的用户界面,第二目标数据包括第一目标数据。该数据同步模块基于通信中间件至少能够实现跨应用的分布式MVVM,可以把一个分布式系统基本开发完成,在一个应用上的数据可以同步更新到其他应用,解决了现有技术只能实现同一应用不同界面之间的数据同步,不可以实现不同应用的数据同步的问题,极大的缩减了分布式架构的开发成本。1) The above-mentioned data synchronization module of the present application includes a communication middleware, a view update unit and a view unit; wherein: the communication middleware is used to subscribe to the first target data from other communication middleware; the view unit is used to display the user interface; the view update unit is used to subscribe to the second target data from the communication middleware, and update the user interface displayed by the view unit according to the second target data, and the second target data includes the first target data. The data synchronization module can at least realize distributed MVVM across applications based on the communication middleware, and can basically complete the development of a distributed system. The data on one application can be synchronized and updated to other applications, which solves the problem that the existing technology can only realize data synchronization between different interfaces of the same application, but cannot realize data synchronization between different applications, and greatly reduces the development cost of the distributed architecture.
2)、本申请的上述数据同步系统,包括第一数据同步模块和第二数据同步模块,第一数据同步模块和第二数据同步模块为根据任意一种的数据同步模块;其中:第一数据同步模块包括的第一通信中间件用于向第二数据同步模块包括的第二通信中间件订阅第一目标数据;第二通信中间件用于向第一通信中间件发布第一目标数据。该数据同步系统基于通信中间件至少能够实现跨应用的分布式MVVM,可以把一个分布式系统基本开发完成,在一个应用上的数据可以同步更新到其他应用,解决了现有技术只能实现同一应用不同界面之间的数据同步,不可以实现不同应用的数据同步的问题,极大的缩减了分布式架构的开发成本。2) The above-mentioned data synchronization system of the present application includes a first data synchronization module and a second data synchronization module, and the first data synchronization module and the second data synchronization module are data synchronization modules according to any one of them; wherein: the first communication middleware included in the first data synchronization module is used to subscribe the first target data to the second communication middleware included in the second data synchronization module; the second communication middleware is used to publish the first target data to the first communication middleware. The data synchronization system can at least realize distributed MVVM across applications based on the communication middleware, and can basically complete the development of a distributed system. The data on one application can be synchronized and updated to other applications, which solves the problem that the prior art can only realize data synchronization between different interfaces of the same application, but cannot realize data synchronization between different applications, and greatly reduces the development cost of the distributed architecture.
3)、本申请的上述数据同步方法,基于根据任意一种上述的数据同步模块实现,该数据同步方法包括:通信中间件向其他通信中间件订阅第一目标数据;视图更新单元向上述通信中间件订阅第二目标数据,并根据上述第二目标数据更新视图单元显示的上述用户界面,上述第二目标数据包括上述第一目标数据。该方法基于通信中间件的设计至少能够实现跨应用的分布式MVVM,可以把一个分布式系统基本开发完成,在一个应用上的数据可以同步更新到其他应用,解决了现有技术只能实现同一应用不同界面之间的数据同步,不可以实现不同应用的数据同步的问题,极大的缩减了分布式架构的开发成本。3) The above-mentioned data synchronization method of the present application is implemented based on any one of the above-mentioned data synchronization modules, and the data synchronization method includes: the communication middleware subscribes to the first target data from other communication middleware; the view update unit subscribes to the second target data from the above-mentioned communication middleware, and updates the above-mentioned user interface displayed by the view unit according to the above-mentioned second target data, and the above-mentioned second target data includes the above-mentioned first target data. This method can at least realize distributed MVVM across applications based on the design of the communication middleware, and can basically complete the development of a distributed system. The data on one application can be synchronized and updated to other applications, which solves the problem that the existing technology can only realize data synchronization between different interfaces of the same application, but cannot realize data synchronization between different applications, and greatly reduces the development cost of the distributed architecture.
以上所述仅为本申请的优选实施例而已,并不用于限制本申请,对于本领域的技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本申请的保护范围之内。The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202411015981.7A CN118842807A (en) | 2024-07-26 | 2024-07-26 | Data synchronization module, data synchronization system and data synchronization method |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202411015981.7A CN118842807A (en) | 2024-07-26 | 2024-07-26 | Data synchronization module, data synchronization system and data synchronization method |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN118842807A true CN118842807A (en) | 2024-10-25 |
Family
ID=93147161
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202411015981.7A Pending CN118842807A (en) | 2024-07-26 | 2024-07-26 | Data synchronization module, data synchronization system and data synchronization method |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN118842807A (en) |
-
2024
- 2024-07-26 CN CN202411015981.7A patent/CN118842807A/en active Pending
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US8918452B2 (en) | Web API framework | |
| CN109729040B (en) | Method, apparatus and computer readable medium for selection of a protocol | |
| US9332038B2 (en) | Remote procedure call with call-by-reference semantics using remote direct memory access | |
| CN111158818A (en) | Page rendering method and device | |
| US20100257539A1 (en) | System, method and apparatus for providing functions to applications on a digital electronic device | |
| US20150370546A1 (en) | Method and apparatus for generating data distribution service application | |
| US10133696B1 (en) | Bridge, an asynchronous channel based bus, and a message broker to provide asynchronous communication | |
| KR20210042283A (en) | Data processing method, device, equipment and medium for applet | |
| KR102194513B1 (en) | Web service system and method using gpgpu based task queue | |
| JP2020004379A (en) | Method and device for releasing information, and method and device for processing information | |
| CN113965628B (en) | Message scheduling method, server and storage medium | |
| WO2024067529A1 (en) | Rdma-based link establishment method and apparatus, and device and storage medium | |
| US9176796B2 (en) | Shared memory reusable IPC library | |
| CN111581576B (en) | Development processing method and device based on micro-service and storage medium | |
| US9614900B1 (en) | Multi-process architecture for a split browser | |
| US10740273B2 (en) | Schema to ensure payload validity for communications on an asynchronous channel based bus | |
| CN113992641B (en) | Data processing method, device, equipment and storage medium | |
| CN115373869A (en) | Process processing method and device based on AAR and electronic equipment | |
| Indrasiri | Introduction to WSO2 ESB | |
| CN118842807A (en) | Data synchronization module, data synchronization system and data synchronization method | |
| CN106911739A (en) | A kind of information dispensing method and device | |
| CN113722115A (en) | Method, device, equipment and computer readable medium for calling interface | |
| CN117194068A (en) | Cross-process data transmission method, system, equipment and storage medium | |
| CN116561013A (en) | Test method, device, electronic equipment and medium based on target service framework | |
| WO2023093885A1 (en) | Cloud technology-based graphic program online development method and system, and related device |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| CB02 | Change of applicant information |
Country or region after: China Address after: 201203 Shanghai Pudong New Area BiBo Road 690, Building 5, 4th Floor Applicant after: Shanghai Xingsi Semiconductor Co., Ltd. Address before: 201203 Shanghai Pudong New Area BiBo Road 690, Building 5, 4th Floor Applicant before: Shanghai Xingsi Semiconductor Co.,Ltd. Country or region before: China |