CN101917394A - Middleware system and working method for data sharing on mobile devices - Google Patents
Middleware system and working method for data sharing on mobile devices Download PDFInfo
- Publication number
- CN101917394A CN101917394A CN 201010202939 CN201010202939A CN101917394A CN 101917394 A CN101917394 A CN 101917394A CN 201010202939 CN201010202939 CN 201010202939 CN 201010202939 A CN201010202939 A CN 201010202939A CN 101917394 A CN101917394 A CN 101917394A
- Authority
- CN
- China
- Prior art keywords
- message
- client
- unit
- server
- conflict
- 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.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 33
- 238000004891 communication Methods 0.000 claims abstract description 54
- 230000008569 process Effects 0.000 claims abstract description 19
- 238000006243 chemical reaction Methods 0.000 claims abstract description 15
- 238000012545 processing Methods 0.000 claims abstract description 3
- 230000005540 biological transmission Effects 0.000 claims abstract 2
- 238000012790 confirmation Methods 0.000 claims description 26
- 238000013461 design Methods 0.000 claims description 5
- 230000002085 persistent effect Effects 0.000 claims description 5
- 238000003672 processing method Methods 0.000 claims description 3
- 238000012217 deletion Methods 0.000 claims description 2
- 230000037430 deletion Effects 0.000 claims description 2
- 238000012546 transfer Methods 0.000 claims 2
- 230000002596 correlated effect Effects 0.000 claims 1
- 230000002045 lasting effect Effects 0.000 claims 1
- 238000012986 modification Methods 0.000 claims 1
- 230000004048 modification Effects 0.000 claims 1
- 230000004044 response Effects 0.000 claims 1
- 238000007726 management method Methods 0.000 description 18
- 210000004080 milk Anatomy 0.000 description 16
- 235000013336 milk Nutrition 0.000 description 16
- 239000008267 milk Substances 0.000 description 15
- 241000220225 Malus Species 0.000 description 12
- 239000003999 initiator Substances 0.000 description 11
- 235000021016 apples Nutrition 0.000 description 6
- 230000008859 change Effects 0.000 description 4
- 238000010586 diagram Methods 0.000 description 3
- 230000001360 synchronised effect Effects 0.000 description 3
- 238000002372 labelling Methods 0.000 description 2
- 239000008186 active pharmaceutical agent Substances 0.000 description 1
- 239000000654 additive Substances 0.000 description 1
- 230000000996 additive effect Effects 0.000 description 1
- 239000003795 chemical substances by application Substances 0.000 description 1
- 230000008878 coupling Effects 0.000 description 1
- 238000010168 coupling process Methods 0.000 description 1
- 238000005859 coupling reaction Methods 0.000 description 1
- 230000006837 decompression Effects 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000009434 installation Methods 0.000 description 1
- 230000007246 mechanism Effects 0.000 description 1
- 238000012544 monitoring process Methods 0.000 description 1
- 230000006855 networking Effects 0.000 description 1
- 229920001690 polydopamine Polymers 0.000 description 1
Images
Landscapes
- Mobile Radio Communication Systems (AREA)
Abstract
本发明公开了一种在手机设备上进行数据共享的中间件系统及工作方法,该系统应用于至少一个服务器端和两个以上运行于手机设备的客户端组成的系统中;客户端包括客户端项目管理单元,客户端消息转换单元,客户端缓存单元,客户端通信单元,客户端DOM操作单元,客户端消解策略单元,客户端冲突消解单元;服务器端具有:服务器端消息队列管理单元,服务器端存储单元,服务器端通信单元,服务器端消解策略单元,服务器端DOM操作单元,服务器端冲突消解单元。通过上述各单元的数据传输和处理,使两个终端互相发送消息,并对接收到的消息进行处理,进而继续发送处理过的消息,并且程序可进行回滚,这样也保证了两个终端之间消息的双向同步。The invention discloses a middleware system and a working method for data sharing on a mobile phone device. The system is applied to a system composed of at least one server and more than two clients running on the mobile phone; the client includes a client Project management unit, client message conversion unit, client cache unit, client communication unit, client DOM operation unit, client resolution strategy unit, client conflict resolution unit; the server has: server message queue management unit, server The storage unit on the server side, the communication unit on the server side, the policy resolution unit on the server side, the DOM operation unit on the server side, and the conflict resolution unit on the server side. Through the data transmission and processing of the above-mentioned units, the two terminals can send messages to each other, process the received messages, and then continue to send the processed messages, and the program can be rolled back, which also ensures the communication between the two terminals. Two-way synchronization of messages between
Description
技术领域technical field
本发明涉及一种运行于手机设备上的中间件系统,更具体地说是涉及移动手机组成的分布式环境下的计算机软件系统及工作方法。The invention relates to a middleware system running on a mobile phone device, more specifically to a computer software system and a working method in a distributed environment composed of mobile phones.
背景技术Background technique
有线网络,又称固定网络,即由一系列固定的主机,通过高带宽的网线及组网设备连接在一起从而组成的相对持久的物理网络。这样的运行环境要求分布式应用程序考虑:(1)可扩展性,是指在未来一段时间内可以容纳更高负载的能力;(2)开放性,指的是可以在功能需求变化时,更容易的扩展和修改系统;(3)异构性,是指分布式系统中被集成的不同组件是由不同的程序语言编写的,运行的不同的操作系统之上,并且又是在不同的硬件平台上执行;(4)容错性,指的是在系统出错时,能够在不停止整个系统运行的情况下自动恢复;(5)资源共享和访问控制,即硬件和软件资源都可以为不同系统的用户有条件地共享。中间件就是为了解决这些问题而产生的,它处于网络操作系统之上,对开发者隐藏了分布式系统的复杂性,成功应有于固定网络环境下的中间件系统有OMG CORBA、Microsoft COM、Sun Java/RMI以及IBM MQSeries等。Wired network, also known as fixed network, is a relatively persistent physical network composed of a series of fixed hosts connected together through high-bandwidth network cables and networking equipment. Such an operating environment requires distributed applications to consider: (1) scalability, which refers to the ability to accommodate higher loads for a period of time in the future; (2) openness, which refers to the ability to update when functional requirements change Easy to expand and modify the system; (3) Heterogeneity means that the different components integrated in the distributed system are written in different programming languages, run on different operating systems, and run on different hardware (4) fault tolerance, which means that when the system fails, it can automatically recover without stopping the operation of the entire system; (5) resource sharing and access control, that is, both hardware and software resources can be used by different systems of users conditionally share. Middleware is created to solve these problems. It is on top of the network operating system and hides the complexity of distributed systems from developers. The middleware systems that should succeed in fixed network environments include OMG CORBA, Microsoft COM, Sun Java/RMI and IBM MQSeries, etc.
近年来由于PDA、手机、笔记本电脑等移动设备的普及,以及无线网络的迅猛发展,移动应用正在不断接近人们的工作生活。由于设备的移动性、资源受限,移动无线网络不同于传统的固定网络,网络结构不固定,网络连接性较差。再加上移动设备的计算能力有限,设备异构性强,固定网络上中间件系统完全不适合移动无线网络。In recent years, due to the popularity of mobile devices such as PDAs, mobile phones, and notebook computers, as well as the rapid development of wireless networks, mobile applications are constantly approaching people's work and life. Due to the mobility of equipment and limited resources, mobile wireless networks are different from traditional fixed networks in that the network structure is not fixed and the network connectivity is poor. Coupled with the limited computing power of mobile devices and strong device heterogeneity, middleware systems on fixed networks are completely unsuitable for mobile wireless networks.
轻量级的移动中间件正是在这种背景之下产生的。移动中间件位于移动网络、操作系统和移动应用软件之间,使用底层操作系统提供的基本功能和服务,通过API为上层的移动应用系统提供从一般的应用需求中抽象出来的、移动网络应用所需要的更高层的、通用的功能与服务。Lightweight mobile middleware is produced under this background. Mobile middleware is located between the mobile network, operating system, and mobile application software. It uses the basic functions and services provided by the underlying operating system, and provides the upper mobile application system with abstracted from general application requirements and required by mobile network applications through APIs. Higher-level, general-purpose functions and services required.
比较成熟的移动中间件有上下文感知的中间件和数据共享中间件等。上下文感知的中间件使得移动应用可以感知诸如位置、设备状态、用户行为等上下文信息。位置信息是上下文感知的中间件研究最多的方面,目前有许多成熟的应用,例如提供旅游指南的CyberGuide,可以发送广告的Object Pager,及在一个特定区域发送消息给任何人的Conference Assistant等。数据共享的中间件支持用户离线操作,并在他们再次连线时对数据进行共享。较为优秀的数据共享中间件有Coda、Odyssey、Bayou及Xmiddle。他们都是最大限度地提高数据的可用性,但他们检测并解决冲突的机制并不相同。Odyssey比它的前任Coda更适合移动环境,但是由于它需要较大的计算能力;Bayou使用应用程序相关的知识进行依赖检查,可能受到级联冲突解决的影响;Xmiddle使用XML来描述信息,使用DOM来对数据进行操作。Coda、Odyssey等其他的数据共享中间件在进行数据复制时需要将整个文件都复制一遍,而Xmiddle可以简单的调整复制单元来适应不同的需要,更适合存储容量有限的移动设备。More mature mobile middleware includes context-aware middleware and data sharing middleware. Context-aware middleware enables mobile applications to be aware of contextual information such as location, device status, and user behavior. Location information is the most researched aspect of context-aware middleware. There are many mature applications, such as CyberGuide that provides travel guides, Object Pager that can send advertisements, and Conference Assistant that sends messages to anyone in a specific area. Data sharing middleware allows users to work offline and share data when they are connected again. More excellent data sharing middleware include Coda, Odyssey, Bayou and Xmiddle. They both maximize data availability, but their mechanisms for detecting and resolving conflicts differ. Odyssey is more suitable for mobile environments than its predecessor Coda, but because it requires greater computing power; Bayou uses application-related knowledge for dependency checking, which may be affected by cascading conflict resolution; Xmiddle uses XML to describe information, using DOM to operate on the data. Other data sharing middleware such as Coda and Odyssey need to copy the entire file once when copying data, while Xmiddle can simply adjust the copy unit to meet different needs, and is more suitable for mobile devices with limited storage capacity.
消息是异构系统交换数据的一种有效方式,它可以被不同的应用程序所理解,异构的系统可以通过交换消息进行通信。消息中间件(MOM)通过消息队列和订阅/发布模式支持分布式应用软件之间进行跨平台的消息传递。与远程过程调用(RPC)相比,PRC就像打电话,而MOM就像发邮件,不用即时,可以断断续续事后批量处理。MOM具有松耦合、异步通讯等特点使其特别适合网络连接性较差的移动网络环境。不过现有的消息中间件(如IBM MQSeries等)都是运行于固定网络上的固定主机上,设备能力要求较高,不适合手机设备。他们对于关键字相同的消息只是进行简单的单向替换,所以也不支持数据共享。Message is an effective way for heterogeneous systems to exchange data, which can be understood by different applications, and heterogeneous systems can communicate by exchanging messages. Messaging middleware (MOM) supports cross-platform message delivery between distributed application software through message queue and subscribe/publish mode. Compared with remote procedure call (RPC), PRC is like making a phone call, while MOM is like sending an email. It does not need to be instant, but can be processed intermittently and afterwards in batches. MOM has the characteristics of loose coupling and asynchronous communication, which makes it especially suitable for the mobile network environment with poor network connectivity. However, the existing message middleware (such as IBM MQSeries, etc.) all run on a fixed host on a fixed network, which requires high equipment capabilities and is not suitable for mobile devices. They only perform simple one-way replacement for messages with the same keyword, so they do not support data sharing.
发明内容Contents of the invention
本发明针对以上问题的提出,而研制一套能够运行于手机设备上的移动消息中间件系统及方法。本发明采用的技术手段如下:In view of the above problems, the present invention develops a set of mobile message middleware system and method that can run on mobile phone equipment. The technical means adopted in the present invention are as follows:
一种在手机设备上进行数据共享的中间件系统,其特征在于该系统应用于至少一个服务器端和两个以上运行于手机设备的客户端组成的系统中;A middleware system for data sharing on mobile devices, characterized in that the system is applied to a system composed of at least one server and more than two clients running on mobile devices;
所述客户端包括:The clients include:
客户端项目管理单元,用于用户编辑消息,配置通信对象以及通信方式参数;The client project management unit is used for users to edit messages, configure communication objects and communication mode parameters;
客户端消息转换单元,用于将用户编辑的消息转换成XML格式的消息,并将此消息继续转换成树的形式;The client message conversion unit is used to convert the message edited by the user into a message in XML format, and continue to convert the message into a tree form;
客户端缓存单元,用于存储用户本地的数据,使用户可以离线的对数据进行操作修改,并将客户端经常访问的服务器端的数据存储在本地;The client cache unit is used to store the user's local data, so that the user can operate and modify the data offline, and store the server-side data frequently accessed by the client locally;
客户端通信单元,用于使用户同其他客户端或服务器进行通信;The client communication unit is used to enable the user to communicate with other clients or servers;
客户端DOM操作单元,用于对XML格式的树形结构的消息进行添加和修改操作,并对其他终端发送过来的消息进行解析;The client DOM operation unit is used to add and modify messages in the tree structure in XML format, and to parse messages sent by other terminals;
客户端消解策略单元,用于对消息转换单元转换成树形式的消息中的冲突节点定义冲突解决策略;The client resolution strategy unit is used to define a conflict resolution strategy for the conflict nodes in the message converted by the message conversion unit into a tree form;
客户端冲突消解单元,用于调用客户端DOM操作单元对XML消息进行处理,之后调用所述客户端消解策略单元,按照事先定义的冲突消解策略来解决冲突;The client-side conflict resolution unit is used to call the client-side DOM operation unit to process the XML message, and then call the client-side resolution strategy unit to resolve the conflict according to the previously defined conflict resolution strategy;
显示单元,用于将结果显示给用户;a display unit, configured to display the result to the user;
服务器端具有:The server side has:
服务器端消息队列管理单元,用于对服务器的消息进行管理,并控制服务器同其他终端之间进行收发消息;The server-side message queue management unit is used to manage the messages of the server and control the sending and receiving of messages between the server and other terminals;
服务器端存储单元,用于将消息存储在数据库中;A server-side storage unit for storing messages in a database;
服务器端通信单元,用于使该服务器与其他客户端或服务器进行通信;a server-side communication unit for enabling the server to communicate with other clients or servers;
服务器端消解策略单元,用于对树形式的消息中的冲突节点定义冲突解决策略;The server-side resolution strategy unit is used to define a conflict resolution strategy for the conflict nodes in the message in the form of a tree;
服务器端DOM操作单元,用于对XML格式的树形结构的消息进行添加和修改操作,并对其他终端发送过来的消息进行解析;The server-side DOM operation unit is used to add and modify messages in a tree structure in XML format, and to parse messages sent by other terminals;
服务器端冲突消解单元,用于调用服务器端DOM操作单元对XML消息进行处理,之后调用所述服务器端消解策略单元,按照事先定义的冲突消解策略来解决冲突;The server-side conflict resolution unit is used to call the server-side DOM operation unit to process the XML message, and then call the server-side resolution strategy unit to resolve the conflict according to the previously defined conflict resolution strategy;
所述中间件系统的一个客户端作为消息的发送方,其客户端消息转换单元在收到用户利用该客户端项目管理单元编辑的消息后,将此消息转换成XML格式,然后利用客户端消解策略单元为可能会产生冲突的节点添加冲突解决策略,再通过客户端通信单元向外发送消息;由服务器端或者是另一个客户端接收消息,服务器端或者是另一个客户端的DOM操作单元对消息进行相关DOM操作,即接收方DOM操作单元对两个不同的树型结构的XML消息进行比较,产生diff树,以记录着由两个不同消息所产生的冲突;然后接收方中的冲突消解单元对冲突进行消解,产生一个没有冲突的新树,再将此树发送给发送方;如果此过程发生在两个移动客户端之间,则将结果存储于所述的客户端缓存单元中,并交由所述的显示单元显示;如果此过程发生在移动客户端与服务器之间,则服务器将此消息保存在服务器端存储单元的数据库中,并由所述的服务器端消息队列管理单元将此消息通过服务器端通信单元发送给所有订阅者。A client of the middleware system is used as the sender of the message, and its client message conversion unit converts the message into XML format after receiving the message edited by the user using the project management unit of the client, and then uses the client to digest the message. The strategy unit adds a conflict resolution strategy for nodes that may cause conflicts, and then sends messages through the client communication unit; the server or another client receives the message, and the server or another client’s DOM operation unit responds to the message Perform related DOM operations, that is, the DOM operation unit of the receiver compares two XML messages with different tree structures to generate a diff tree to record the conflicts generated by the two different messages; then the conflict resolution unit in the receiver resolve the conflict, generate a new tree without conflict, and then send the tree to the sender; if this process occurs between two mobile clients, store the result in the client cache unit, and Displayed by the display unit; if this process occurs between the mobile client and the server, the server stores the message in the database of the server-side storage unit, and the server-side message queue management unit stores the message Messages are sent to all subscribers via the server-side communication unit.
所述的客户端缓存单元包括一个临时的消息队列,客户端将消息放到此消息队列中,由此消息队列主动按照该客户端通信单元所设定的协议来发送或接收消息;每个消息都附加一个发送结束符,当消息发送到结束符时,则认为消息发送成功,否则认为消息发送失败,重新发送此消息或进行后一步处理。The client cache unit includes a temporary message queue, and the client puts messages into the message queue, so that the message queue actively sends or receives messages according to the protocol set by the client communication unit; each message A sending terminator is attached to each of them. When the message is sent to the terminator, it is considered that the message is sent successfully, otherwise it is considered that the message is sent as a failure, and the message is resent or processed in the next step.
所述的服务器消息队列管理单元包括一个线程池与工作队列,由工作队列对接收到的请求进行监听,然后按照优先级在线程池中取出一个线程与响应的终端进行通信;每个线程与终端通信时,都包含一个与客户端类似的消息队列,用于主动的发送或接收消息,并将接收到的消息保存在数据库中;当在给定时间内没收到确认信息时,服务器的处理方法是:对于持久的订阅者来说,如果终端断线,服务器将消息存储起来,当他再次连线时,服务器会将消息再次发给订阅者;对于非持久的订阅者来说,断线就意味着失败,服务器将此订阅信息删除,如果订阅者想继续接收消息,那么他需要再次发送订阅信息。The server message queue management unit includes a thread pool and a work queue, and the work queue listens to the received request, and then takes out a thread from the thread pool to communicate with the corresponding terminal according to the priority; each thread communicates with the terminal When communicating, it includes a message queue similar to the client, which is used to actively send or receive messages, and save the received messages in the database; when the confirmation information is not received within a given time, the processing method of the server Yes: For persistent subscribers, if the terminal is disconnected, the server will store the message, and when he connects again, the server will send the message to the subscriber again; for non-persistent subscribers, disconnection is means failure, the server deletes the subscription information, and if the subscriber wants to continue receiving messages, he needs to send the subscription information again.
所述发送方通过通信单元与接收方通信,由发送方先发送一个发现请求消息,如果接收方收到此消息,会返回给发送方一个确认码,则发送方将自己所存储消息的所有版本都发送给接收方;如果接收方没有收到发现请求消息或发送方没有收到确认码,则需要发送方重新发送发现请求消息给接收方。The sender communicates with the receiver through the communication unit, and the sender first sends a discovery request message. If the receiver receives this message, it will return a confirmation code to the sender, and the sender will send all versions of the message stored by itself. Both are sent to the receiver; if the receiver does not receive the discovery request message or the sender does not receive the confirmation code, the sender needs to resend the discovery request message to the receiver.
一种在手机设备上进行数据共享的中间件系统的工作方法,其特征在于包括如下步骤:A kind of working method of the middleware system that carries out data sharing on mobile phone equipment, it is characterized in that comprising the following steps:
步骤1由用户根据具体的应用,通过客户端项目管理单元来编辑消息,并对配置信息进行相应设计;Step 1: According to the specific application, the user edits the message through the project management unit of the client, and designs the configuration information accordingly;
步骤2客户端通过客户端消息转换单元将用户编辑的消息转换成XML格式的消息,将此消息存储于客户端缓存单元中;之后将此消息继续转换成树的形式,然后根据具体的应用,通过客户端消解策略单元为每个可能产生冲突的节点定义一个冲突解决策略,并通过客户端DOM操作单元为这颗树添加一个节点,此节点记录着冲突解决策略;当发生冲突时,应用程序应该采取此节点定义的冲突解决策略来解决冲突;Step 2 The client converts the message edited by the user into a message in XML format through the client message conversion unit, and stores the message in the client cache unit; then continues to convert the message into a tree form, and then according to the specific application, Define a conflict resolution strategy for each node that may cause conflicts through the client resolution strategy unit, and add a node to the tree through the client DOM operation unit, which records the conflict resolution strategy; when a conflict occurs, the application The conflict resolution strategy defined by this node should be adopted to resolve conflicts;
步骤3当客户端作为发送方通过客户端通信单元与另一个终端作为接收方开始通信,发送方先发送一个发现请求消息,如果接收方收到此消息,会返回给发送方一个确认码,说明此时发送方与接收方是可以进行通信的,发送方将自己所存储消息的所有版本都发送给接收方;如果接收方没有收到发现请求消息或发送方没有收到确认码,则需要重新发送发现请求消息;Step 3 When the client as the sender starts to communicate with another terminal as the receiver through the client communication unit, the sender first sends a discovery request message, and if the receiver receives this message, it will return a confirmation code to the sender, indicating At this time, the sender and the receiver can communicate, and the sender will send all versions of the messages stored by itself to the receiver; if the receiver does not receive the discovery request message or the sender does not receive the confirmation code, it needs to re- Send a discovery request message;
步骤4接收方收到发送方所存储消息的所有版本后,通过服务器端或者是另一个客户端的DOM操作单元对这些消息进行解析,并与自己存储的消息进行比较,此时若发送方与接收方中有一方修改过消息,则比较时会发现冲突,接收方将这些冲突记录下来;Step 4 After receiving all versions of the messages stored by the sender, the receiver parses these messages through the DOM operation unit of the server or another client, and compares them with the messages stored by itself. At this time, if the sender and the receiver If one of the parties has modified the message, a conflict will be found during comparison, and the receiver will record these conflicts;
步骤5接收方根据步骤2所定义的冲突节点的解决策略节点,通过服务器端或者是另一个客户端的消解策略单元调用事先定义好的消解策略,由服务器端或者是另一个客户端的冲突消解单元对冲突进行消解,并记录下解决冲突后的新消息;Step 5. According to the resolution strategy node of the conflict node defined in step 2, the receiver calls the resolution strategy defined in advance through the resolution strategy unit of the server or another client, and the conflict resolution unit of the server or another client The conflict is resolved, and the new message after the conflict is recorded;
步骤6若接收方是移动客户端,则接收方将此新消息通过客户端缓存单元存储在缓存中,并将此新消息通过客户端通信单元返回给发送方,发送方记录下这个解决冲突后的消息,并存储在缓存中,然后交由客户端显示单元显示结果;Step 6 If the receiver is a mobile client, the receiver stores the new message in the cache through the client cache unit, and returns the new message to the sender through the client communication unit, and the sender records the conflict resolution and stored in the cache, and then handed over to the client display unit to display the results;
步骤7若接收方是服务器,则接收方通过服务器端消息队列管理单元对消息进行一定处理,把消息包装成服务器可识别的消息,之后通过服务器端存储单元将消息存储在数据库中;Step 7: If the recipient is a server, the recipient processes the message through the server-side message queue management unit, packs the message into a message recognizable by the server, and then stores the message in the database through the server-side storage unit;
步骤8然后服务器将更新过的消息通过服务器端通信单元发送给所有订阅者,使得所有订阅者中的消息保持同步。Step 8 Then the server sends the updated message to all subscribers through the server-side communication unit, so that the messages in all subscribers are kept synchronized.
本发明提供的在手机设备上进行数据共享的中间件系统及工作方法同现有技术相比其优点是显而易见的,具体如下:Compared with the prior art, the middleware system and working method for data sharing provided by the present invention are obvious, as follows:
(1)使消息中间件支持移动分布式环境。区别于传统消息中间件,本发明支持移动网络环境,针对移动网络的特殊性和手机设备的特点,能够在手机设备真实的硬件环境和Java虚拟运行环境上运行,通过消息队列管理为时断时续的网络连接条件下的移动应用程序提供一种可靠的数据通信手段。(1) Make the message middleware support the mobile distributed environment. Different from the traditional message middleware, the present invention supports the mobile network environment. Aiming at the particularity of the mobile network and the characteristics of the mobile phone device, it can run on the real hardware environment of the mobile phone device and the Java virtual operating environment. It provides a reliable means of data communication for mobile applications under continuous network connection conditions.
(2)有效地保证共享数据的成功收发及数据的一致性,支持数据共享。两个终端互相发送消息,并对接收到的消息进行处理,进而继续发送处理过的消息,并且这过程出现问题时,程序进行相应的回滚,这样也保证了两个终端之间消息的双向同步,而不是简单的消息替换。(2) Effectively ensure the successful sending and receiving of shared data and the consistency of data, and support data sharing. The two terminals send messages to each other, process the received messages, and then continue to send the processed messages, and when there is a problem in this process, the program rolls back accordingly, which also ensures the two-way message between the two terminals Synchronization, not simple message replacement.
附图说明Description of drawings
图1为本发明所述系统的总体结构示意图;Fig. 1 is the overall structure schematic diagram of the system of the present invention;
图2为本发明所述系统的移动客户端结构示意图;Fig. 2 is a schematic structural diagram of a mobile client of the system of the present invention;
图3为本发明所述系统的服务器端结构示意图;Fig. 3 is a schematic diagram of the server-side structure of the system of the present invention;
图4为本发明所述系统的工作流程图;Fig. 4 is the work flowchart of system of the present invention;
图5为本发明所述系统设计的实施装置工作流程图。Fig. 5 is a working flow chart of the implementation device of the system design of the present invention.
具体实施方式Detailed ways
本发明提供了一种用于支持移动环境的消息中间件的实施系统。物理上,该系统可划分为服务器端(后台计算机)和客户端(手机设备)两部分,两者通过无线网络、蓝牙等通信协议连接在一起,其中后台计算机上运行着本发明的消息中间件服务器部分,手机设备上运行移动客户端部分。可以实施两个手机设备之间的数据共享,他们可以不需通过服务器,而是直接进行点对点的通信;也可以实施一台服务器与多个手机设备之间的数据共享,这是结合消息中间件上的发布/订阅方式而完成的。可以选择通过TCP/IP、HTTP或蓝牙等协议同手机设备上的移动应用程序进行通讯。The invention provides an implementation system of message middleware for supporting mobile environment. Physically, this system can be divided into server end (background computer) and client (mobile phone equipment) two parts, both are connected together by communication protocols such as wireless network, bluetooth, wherein the message middleware of the present invention is running on the background computer The server part and the mobile client part run on the mobile device. Data sharing between two mobile devices can be implemented, and they can directly communicate point-to-point without going through a server; data sharing between a server and multiple mobile devices can also be implemented, which is combined with message middleware Completed by the publish/subscribe method above. You can choose to communicate with the mobile application on the mobile device through protocols such as TCP/IP, HTTP or Bluetooth.
如图1所示该手机设备上进行数据共享的中间件系统应用于至少一个服务器端和两个以上运行于手机设备的客户端组成的系统中;As shown in Figure 1, the middleware system for data sharing on the mobile device is applied to a system consisting of at least one server and more than two clients running on the mobile device;
如图2所示所述客户端包括:As shown in Figure 2, the client includes:
客户端项目管理单元100,用于用户编辑消息,配置通信对象以及通信方式参数,由PanelManager、ClientEdit类组成;客户端消息转换单元101,用于将用户编辑的消息转换成XML格式的消息,并将此消息继续转换成树的形式,由TransformMessage、ExportLink类组成;客户端缓存单元102,用于使用户可以离线的对数据进行操作修改,并将客户端经常访问的服务器端的数据存储在本地,以防止当客户端频繁的访问服务器,节约网络带宽,由RecordStoreOperation类组成;客户端消解策略单元103,用于对消息转换单元转换成树形式的消息中的冲突节点定义冲突解决策略,即根据具体的应用来定义不同的冲突消解策略,如添加、修改、替换等,由TreeDiff、TreeMerge、TreeReplica、ListEntry类组成;客户端DOM操作单元104,用于对XML格式的树形结构的消息进行添加和修改操作,并对其他终端发送过来的消息进行解析,如比较两颗树的不同之处,对节点进行修改等;由XMLTranslator、MessageHead、MessageBody、Message、NeedToShare、DiscoveryRequest、AgentConnected、AgentDisconnected、EditionIdentifier、LinkedTableMessage、LinkedFrom、ConfirmMessage、TlistOfEI、NewChanges、Acknowledge类组成;客户端冲突消解单元105,用于调用客户端DOM操作单元对XML消息进行处理,之后调用所述客户端消解策略单元,按照事先定义的冲突消解策略来解决冲突,由Reconcile、ReplaceStrategy、MinusStrategy、AddStrategy类组成;客户端通信单元106,用于使用户采用一定的通信协议,如Http,蓝牙等,来与其他客户端或服务器进行通信,由Observer、Protocol、Subject接口,Transport、ProSocket、ProHttp、ProBluetooth、Agent、ConnectAgent、ReconcileAgent、ExchangeInfoAgent、ConfirmChangesAgent、ListEIAgent、NewChangesAgent、AckAgent、Terminate类组成;机上应用程序管理单元107,手机设备厂商提供,用于管理Java Me移动应用程序的下载、解压、安装、删除、运行;显示单元108,用于将结果显示给用户。The client
如图3所示服务器端包括:As shown in Figure 3, the server side includes:
服务器端通信单元206,用于使该服务器与其他客户端或服务器进行通信;服务器端消解策略单元205,用于对树形式的消息中的冲突节点定义冲突解决策略;服务器端DOM操作单元204,用于对XML格式的树形结构的消息进行添加和修改操作,并对其他终端发送过来的消息进行解析;服务器端冲突消解单元203,用于调用服务器端DOM操作单元对XML消息进行处理,之后调用所述服务器端消解策略单元,按照事先定义的冲突消解策略来解决冲突;上述各单元与客户端组成基本一致,这里不再赘述。其中服务器端存储单元202,用于将消息存储在数据库中,并支持对数据库中消息的操作;由类FileOperation、DatabaseOperation组成;服务器端消息队列管理单元201,用于对服务器的消息进行管理,并控制服务器同其他终端之间进行收发消息,由类Start、Init、StartXMLTranslator、ThreadPool类组成。The server-
所述中间件系统的一个客户端作为消息的发送方,其客户端消息转换单元在收到用户利用该客户端项目管理单元编辑的消息后,将此消息转换成XML格式,然后利用客户端消解策略单元为可能会产生冲突的节点添加冲突解决策略,再通过客户端通信单元向外发送消息;由服务器端或者是另一个客户端接收消息,服务器端或者是另一个客户端的DOM操作单元对消息进行相关DOM操作,即接收方DOM操作单元对两个不同的树型结构的XML消息进行比较,产生diff树,以记录着由两个不同消息所产生的冲突;然后接收方中的冲突消解单元对冲突进行消解,产生一个没有冲突的新树,再将此树发送给发送方;如果此过程发生在两个移动客户端之间,则将结果存储于所述的客户端缓存单元中,并交由所述的显示单元显示;如果此过程发生在移动客户端与服务器之间,则服务器将此消息保存在服务器端存储单元的数据库中,并由所述的服务器端消息队列管理单元将此消息通过服务器端通信单元发送给所有订阅者。A client of the middleware system is used as the sender of the message, and its client message conversion unit converts the message into XML format after receiving the message edited by the user using the project management unit of the client, and then uses the client to digest the message. The strategy unit adds a conflict resolution strategy for nodes that may cause conflicts, and then sends messages through the client communication unit; the server or another client receives the message, and the server or another client’s DOM operation unit responds to the message Perform related DOM operations, that is, the DOM operation unit of the receiver compares two XML messages with different tree structures to generate a diff tree to record the conflicts generated by the two different messages; then the conflict resolution unit in the receiver resolve the conflict, generate a new tree without conflict, and then send the tree to the sender; if this process occurs between two mobile clients, store the result in the client cache unit, and Displayed by the display unit; if this process occurs between the mobile client and the server, the server stores the message in the database of the server-side storage unit, and the server-side message queue management unit stores the message Messages are sent to all subscribers via the server-side communication unit.
另外,客户端缓存单元包括一个临时的消息队列,客户端将消息放到此消息队列中,由此消息队列主动按照该客户端通信单元所设定的协议来发送或接收消息,以防止在网络条件不好时,客户端阻塞等待;每个消息都附加一个发送结束符,当消息发送到结束符时,则认为消息发送成功,否则认为消息发送失败,重新发送此消息或进行后一步处理。在服务器消息队列管理单元包括一个线程池与工作队列,由工作队列对接收到的请求进行监听,然后按照优先级在线程池中取出一个线程与响应的终端进行通信,这样就可以使服务器在多线程的情况下同时与多个终端进行消息的通信;每个线程与终端通信时,都包含一个与客户端类似的消息队列,用于主动的发送或接收消息,只是并将接收到的消息不再保存于缓存中,而是保存在数据库中;当在给定时间内没收到确认信息时,服务器的处理方法是:对于持久的订阅者来说,如果终端断线,服务器将消息存储起来,当他再次连线时,服务器会将消息再次发给订阅者;对于非持久的订阅者来说,断线就意味着失败,服务器将此订阅信息删除,如果订阅者想继续接收消息,那么他需要再次发送订阅信息。发送方通过通信单元与接收方通信,由发送方先发送一个发现请求消息,如果接收方收到此消息,会返回给发送方一个确认码,则发送方将自己所存储消息的所有版本都发送给接收方;如果接收方没有收到发现请求消息或发送方没有收到确认码,则需要发送方重新发送发现请求消息给接收方。In addition, the client cache unit includes a temporary message queue, and the client puts messages into this message queue, so that the message queue actively sends or receives messages according to the protocol set by the client communication unit, so as to prevent When the condition is not good, the client blocks and waits; each message is attached with a sending terminator. When the message is sent to the terminator, it is considered that the message is sent successfully, otherwise it is considered that the message is sent as failed, and the message is resent or processed in the next step. The server message queue management unit includes a thread pool and a work queue. The work queue monitors the received request, and then takes out a thread from the thread pool to communicate with the responding terminal according to the priority, so that the server can be used in multiple In the case of a thread, it communicates messages with multiple terminals at the same time; when each thread communicates with a terminal, it contains a message queue similar to the client, which is used to actively send or receive messages, but the received messages will not Then save it in the cache, but in the database; when the confirmation message is not received within a given time, the processing method of the server is: for persistent subscribers, if the terminal is disconnected, the server will store the message, When he connects again, the server will send the message to the subscriber again; for non-durable subscribers, disconnection means failure, and the server will delete the subscription information. If the subscriber wants to continue to receive messages, then he Subscription information needs to be sent again. The sender communicates with the receiver through the communication unit, and the sender first sends a discovery request message. If the receiver receives this message, it will return a confirmation code to the sender, and the sender will send all versions of the message it has stored. To the receiver; if the receiver does not receive the discovery request message or the sender does not receive the confirmation code, the sender needs to resend the discovery request message to the receiver.
结合图4说明本发明用于支持移动环境的消息中间件系统设计的工作方法,具体如下:The present invention is used to support the working method of the message middleware system design of mobile environment in conjunction with Fig. 4, specifically as follows:
首先由用户根据具体的应用,通过客户端项目管理单元100来编辑消息,并对配置信息进行相应设计,如希望与哪个终端进行通信,通信的方式及端口(步骤S301);First, according to the specific application, the user edits the message through the client
客户端通过客户端消息转换单元101将用户编辑的消息转换成XML格式的消息,将此消息存储于客户端缓存单元中102;之后将此消息继续转换成树的形式,然后根据具体的应用,通过客户端消解策略单元105为每个可能产生冲突的节点定义一个冲突解决策略,并通过客户端DOM操作单元104为这颗树添加一个节点,此节点记录着冲突解决策略;当发生冲突时,应用程序应该采取此节点定义的冲突解决策略来解决冲突(步骤S302);The client converts the message edited by the user into a message in XML format through the client
当客户端A作为发送方通过客户端通信单元106与另一个终端B作为接收方开始通信,客户端A(发送方)先发送一个发现请求消息,如果B(接收方)收到此消息,会返回给A(发送方)一个确认码,说明此时A(发送方)与B(接收方)是可以进行通信的,A(发送方)将自己所存储消息的所有版本都发送给B(接收方);如果B(接收方)没有收到发现请求消息或A(发送方)没有收到确认码,则说明此时网络条件不良,则需要重新发送发现请求消息(步骤S303);When the client A as the sender starts to communicate with another terminal B as the receiver through the
B(接收方)收到A(发送方)所存储消息的所有版本后,通过服务器端或者是另一个客户端的DOM操作单元104对这些消息进行解析,并与自己存储的消息进行比较,此时若A(发送方)与B(接收方)中有一方修改过消息,则比较时会发现冲突,B(接收方)将这些冲突记录下来(步骤S304);After B (receiver) receives all versions of the messages stored by A (sender), these messages are parsed by the
B(接收方)根据步骤S302所定义的冲突节点的解决策略节点,通过服务器端或者是另一个客户端的消解策略单元调用事先定义好的消解策略,由服务器端或者是另一个客户端的冲突消解单元对冲突进行消解,并记录下解决冲突后的新消息(步骤S305);B (receiver) calls the resolution strategy defined in advance through the resolution strategy unit of the server end or another client according to the resolution strategy node of the conflict node defined in step S302, and the conflict resolution unit of the server end or another client The conflict is resolved, and the new message after the conflict is recorded (step S305);
若B(接收方)是移动客户端,则B(接收方)将此新消息通过客户端缓存单元102存储在缓存中,并将此新消息通过客户端通信单元返回给A(发送方),A(发送方)记录下这个解决冲突后的消息,并存储在缓存中,然后交由客户端显示单元108显示结果(步骤S306);If B (receiver) is a mobile client, then B (receiver) stores this new message in the cache through the
若B(接收方)是服务器,则B(接收方)通过服务器端消息队列管理单元201对消息进行一定处理,把消息包装成服务器可识别的消息,之后通过服务器端存储单元202将消息存储在数据库中步骤307);If B (receiver) is a server, then B (receiver) performs certain processing on the message through the server-side message
步骤8然后服务器将更新过的消息通过服务器端通信单元206发送给所有订阅者,使得所有订阅者中的消息保持同步(步骤308)。Step 8 Then the server sends the updated message to all subscribers through the server-
图5给出了本发明实施装置的流程图。该装置可划分为发起端与接收端,发起端是一台移动智能手机,接收端可以使一台移动智能手机,也可以是消息中间件服务器,发起端与接收端通过蓝牙、TCP/IP或者HTTP协议进行通讯连接。Fig. 5 shows the flowchart of the implementation device of the present invention. The device can be divided into an initiator and a receiver. The initiator is a mobile smart phone, and the receiver can be a mobile smart phone or a message middleware server. The initiator and the receiver communicate via Bluetooth, TCP/IP or HTTP protocol for communication connection.
为方便起见,图5中的判断条件都简写成标识符,其中X1表示“接收端是否为服务器”,X2表示“接收端是否接收到了发现请求消息”,X3表示“发起端是否收到确认码”,X4表示“是否接收到新消息发送成功的确认码”。如图3所示,本发明装置的具体步骤为:For convenience, the judgment conditions in Figure 5 are abbreviated as identifiers, where X1 means "whether the receiving end is a server", X2 means "whether the receiving end has received a discovery request message", and X3 means "whether the initiator has received a confirmation code ", X4 means "whether the confirmation code for the successful sending of the new message has been received". As shown in Figure 3, the concrete steps of device of the present invention are:
1、如果用户通过移动智能手机想要与服务器进行通信连接(X1为真),则服务器需先进行一系列的初始化,包括使数据库与实时信息同步、设置工作队列与线程池。发起端订阅自己感兴趣的消息,或发布一些消息到服务器中。如果用户通过移动智能手机想要与另一手机进行通信连接(X1为假),则接收端与发起端一并进行消息的编辑,由程序将编辑好的消息转化成机器可识别的XML格式的消息。1. If the user wants to communicate with the server through a mobile smartphone (X1 is true), the server needs to perform a series of initializations, including synchronizing the database with real-time information, setting up the work queue and thread pool. The originator subscribes to the messages it is interested in, or publishes some messages to the server. If the user wants to communicate with another mobile phone through a mobile smart phone (X1 is false), the receiving end and the initiator will edit the message together, and the program will convert the edited message into a machine-recognizable XML format information.
2、接收端监听端口,看有没有输入流流入,发起端发送发现请求消息,若接收端接收到消息(X2为真),则返回一个接收到消息后的确认码,否则接收端一直处于监听端口的状态。同样,在发起端发送发现请求消息之后,一直处于监听端口的状态,直到接收到接收端换回的确认码为止(X3为真)。此处当发起端与接收端若超过一段时间还没有接收到消息,则认定当前网络不良,需要过一段时间再次执行此步骤。2. The receiving end monitors the port to see if there is any input flow flowing in. The initiator sends a discovery request message. If the receiving end receives the message (X2 is true), it returns a confirmation code after receiving the message, otherwise the receiving end is always in monitoring The state of the port. Similarly, after the initiator sends the discovery request message, it is always in the state of listening to the port until it receives the confirmation code returned by the receiver (X3 is true). Here, if the initiator and the receiver have not received the message for a period of time, it is determined that the current network is not good, and this step needs to be performed again after a period of time.
3、发起端发送需进行数据共享的消息,接收端接收到消息后,与本地消息一并进行处理,找出两个不同消息所产生的冲突,并对这些冲突进行消解。之后将解决冲突后的新消息返回给发起端。此时两个终端会彼此发送新消息接收成功的确认码,如果超出预定时间没有接收到确认码(X4为假),则需要对程序进行回滚,从第2步重新开始执行。3. The initiator sends a message that needs to be shared. After receiving the message, the receiving end processes it together with the local message, finds out the conflicts between two different messages, and resolves these conflicts. Then return the new message after the conflict is resolved to the initiator. At this time, the two terminals will send each other a confirmation code for the successful reception of the new message. If the confirmation code is not received within the predetermined time (X4 is false), the program needs to be rolled back, and the execution is restarted from step 2.
4、如果成功接收到确认码(X4为真),则发起端须将新消息存储在缓存中,以便下次继续使用。同样地,若接收端是移动智能手机(X1为假),则接收端也需将新消息存储在缓存中。若接收端是服务器(X1为真),则需将新消息存储在数据库中,并由服务器通知其他订阅此消息的主机,数据已变动,使他们的数据与服务器中的数据保持同步。4. If the confirmation code is successfully received (X4 is true), the initiator must store the new message in the cache for continued use next time. Similarly, if the receiving end is a mobile smart phone (X1 is false), the receiving end also needs to store the new message in the cache. If the receiving end is a server (X1 is true), the new message needs to be stored in the database, and the server notifies other hosts who subscribe to this message that the data has changed, so that their data is synchronized with the data in the server.
[第一实施方式][first embodiment]
本发明的第一优选实施例以一个合作的电子购物系统为例。一个家庭很多成员在网上购物,他们每人都有一个移动智能手机,他们独自选择所需的商品,并将所选择的商品记录在个人智能手机上,而最终付账时是共同交钱,所以要将个人买的商品“合并”在一起,再由其中一个智能手机进行网络支付。例如,成员A买了1瓶牛奶和2个苹果,成员B买了2瓶牛奶,他们独自的将这些信息记录在个人智能手机上,当他们想要支付时,他们先将这些商品通过手机“合并”在一起,程序合并两个手机中的消息,结果为3瓶牛奶和2个苹果,然后由A进行最终的网络支付。该程序主要由Merchandise,Milk,Apple,Parser,ClientPanel,UploadToPay类组成,本实例实施目的是检查在目标机型SonyEricsson K700C上数据数据共享的执行结果是否正确。具体的实施步骤如下:The first preferred embodiment of the present invention takes a cooperative electronic shopping system as an example. Many members of a family shop online, each of them has a mobile smart phone, they choose the goods they need individually, and record the selected goods on their personal smart phones, and when they finally pay the bill, they pay together, so it is necessary "Merge" the goods purchased by individuals together, and then use one of the smartphones to make online payments. For example, member A buys 1 bottle of milk and 2 apples, and member B buys 2 bottles of milk. They record these information on their personal smartphones independently. When they want to pay, they first send these goods through the phone " Merge" together, the program merges the messages in the two mobile phones, and the result is 3 bottles of milk and 2 apples, and then A makes the final network payment. The program is mainly composed of Merchandise, Milk, Apple, Parser, ClientPanel, and UploadToPay classes. The purpose of this example implementation is to check whether the execution result of data sharing on the target model SonyEricsson K700C is correct. The specific implementation steps are as follows:
1、用户A与B分别在客户端项目管理单元100的向导面板下编辑消息,A编辑消息1 milk and 2 apple,B编辑消息2milk,然后设置对方为通信的对象,并设置通信协议为蓝牙,之后提交消息,用户可以去忙别的事,如打电话,发短信等,无需等待。1. Users A and B respectively edit messages under the wizard panel of the client
2、程序接收到消息后,使用客户端消息转换单元101对消息进行解析,解析完的结果是{milk:1,apple:2}及{milk:2},之后将消息转换成XML格式的消息,根节点为basket,A的消息为<basket><order><product>milk</product><quantity><howmuch>1</howmuch></quantity></order><order><product>apple</product><quantity><howmuch>2</howmuch></quantity></order></basket>,B的消息为<basket><order><product>milk</product><quantity><howmuch>2</howmuch></quantity></order></basket>,他们都将消息存储在缓存中。之后通过客户端消解策略单元105为quantity节点定义一个冲突解决策略add,意味着当quantity节点产生冲突时,系统应该将采取相加的策略来解决冲突。之后通过客户端DOM操作单元104为每个quantity节点添加一个节点add,用于显示的标注冲突解决策略。2. After the program receives the message, it uses the client
3、客户端A通过客户端通信单元106与另一个终端B开始进行通信连接,本地主机A先发送一个“发现请求”消息<DiscoveryRequest/>,当网络条件较好时,B会接收到此消息,并返回给A一个确认码<ConnectAgent/>,A将自己所存储消息发送给B;当网络条件不好或设备出现硬件故障时,B不会接收到发现请求消息或者A不会接收到确认码,则需要对硬件进行处理或间隔一段时间再次重新进行通信连接。3. Client A starts a communication connection with another terminal B through the
4、B收到A的消息后,通过客户端DOM操作单元104对这些消息进行解析,并与自己存储的消息进行比较,B会发现两个消息是不同的,此时就产生了冲突,冲突为:B的milk的数量是2,A的milk数量是1,并且B比A少了2个apple。B将这些冲突记录下来。4. After B receives A's message, it analyzes these messages through the client
5、B在客户端冲突消解单元103对冲突进行消解。先解决前半部分冲突,根据quantity节点所定义的解决策略节点add,对milk的数量进行相加,为2+1=3。然后解决后半部分冲突,因为B比A少2个apple,所以将A的apple分支整体复制到B的消息下。最终冲突消解后的内容为3个milk及2个apple,为<basket><order><product>milk</product><quantity><howmuch>1</howmuch></quantity></order><order><product>apple</product><quantity><howmuch>2</howmuch></quantity></order></basket>。5. B resolves the conflict at the client
6、B将此新消息通过客户端缓存单元102存储在缓存中,以便用于之后的网上支付或再次与其他终端进行数据共享,并将此新消息通过客户端通信单元106返回给A,A记录下这个解决冲突后的消息,并存储在缓存中。系统通过显示单元108分别将结果显示给两个用户。6. B stores the new message in the cache through the
7、A将最终结果3个milk及2个apple经由网络上传到网上,进行网上支付。7. A uploads the final result of 3 milks and 2 apples to the Internet via the Internet for online payment.
[第二实施方式][Second Embodiment]
本发明的第二优选实施例以股票交易系统为例。用户首先通过移动智能手机与消息服务器相连,并通过在手机设备上对股票进行买卖操作,买卖结果通知服务器,服务器对此进行进一步处理。当此股票出现一些重大变更,如涨停、跌停、或分红等,用户还可以收到来自服务器的通知,以便用户对此变更进行及时的处理。该程序主要由ClientPanel,StockOperation,Subscribe,SendToClient类组成,本实例的实施目的是检查在目标机型SonyEricsson K700C上整个股票交易系统完成的情况,是否可以实现数据共享,当用户订阅的股票出现一些重大变更时是否可以及时收到服务器的通知。具体实施步骤如下:The second preferred embodiment of the present invention takes a stock trading system as an example. The user first connects to the message server through the mobile smart phone, and through the mobile phone device to buy and sell stocks, the trading result is notified to the server, and the server further processes this. When there are some major changes in the stock, such as daily limit, lower limit, or dividends, the user can also receive a notification from the server, so that the user can process the change in a timely manner. The program is mainly composed of ClientPanel, StockOperation, Subscribe, and SendToClient. The implementation purpose of this example is to check the completion of the entire stock trading system on the target model SonyEricsson K700C, and whether data sharing can be realized. Whether you can receive the notification from the server in time when the change is made. The specific implementation steps are as follows:
1、首先对服务器进行初始化,设置工作队列及线程池,并与实时股票结合起来,服务器管理者将股票信息录入到服务器中。当股票信息发送改变时,服务器中的股票信息会及时做出相应改变。1. Initialize the server first, set up the work queue and thread pool, and combine it with real-time stocks. The server manager will enter the stock information into the server. When the stock information is sent and changed, the stock information in the server will make corresponding changes in time.
2、用户通过项客户端目管理单元100的向导面板向服务器订阅自己感兴趣的股票,服务器将这些股票的信息通过服务器端通信单元206返回给用户,用户可以在向导面板查看股票信息,当股票信息发生改变时,服务器会实时的通知用户,以便用户进一步对股票进行操作。2. The user subscribes to the server for the stocks he is interested in through the wizard panel of the
3、当用户想要在手机端对股票进一步操作时,如用户已有a股票200股,在价格不变的情况下再次买进100股,用户通过客户端项目管理单元100的向导面板来编辑相应的股票信息buy 100 for a,选择HTTP方式与服务器进行通信,之后提交消息。3. When the user wants to further operate the stock on the mobile phone, for example, the user already has 200 shares of stock a and buys another 100 shares without changing the price, the user edits through the wizard panel of the
4、程序接收到消息后,使用客户端消息转换单元101对消息进行解析,解析完的结果是{<a,100,buy>},之后将消息转换成XML格式的消息,根节点为stock,,转换结果为<stock><order><ID>a</ID><quantity><howmuch>100</howmuch></quantity><style>buy</style></order></stock>,之后通过客户端消解策略单元105为quantity节点定义一个冲突解决策略add,意味着当服务器中储存的用户原有的股票数量与现在新购买的股票数量发生冲突时,程序会采取对数量相加的方式来解决冲突。之后通过客户端DOM操作单元104为每个quantity节点添加一个节点add,用于显示的标注冲突解决策略。4. After the program receives the message, it uses the client
5、用户使用手机通过客户端通信单元106与服务器开始进行通信连接,手机端先发送一个“发现请求”消息<DiscoveryRequest/>,当网络条件较好时,服务器会接收到此消息,并返回给手机一个确认码<ConnectAgent/>,手机端将自己所存储消息发送给服务器;当网络条件不好或设备出现硬件故障时,服务器不会接收到发现请求消息,或者手机端不会接收到确认码,则此时需要对硬件进行处理或间隔一段时间再次重新进行通信连接。5. The user uses the mobile phone to communicate with the server through the
6、服务器收到用户消息后,通过服务器端DOM操作单元204对这些消息进行解析,并与存储在数据库中的消息进行比较,服务器会发现两个消息是不同的,此时就产生了冲突,冲突为:服务器中用户所买的a股票的数量是200,用户新提交的a股票的数量是100。B将这些冲突记录下来。6. After the server receives the user messages, it parses these messages through the server-side
7、B在服务器端冲突消解单元203对冲突进行消解。根据quantity节点所定义的解决策略节点add,对a的数量进行相加,为200+100=300。最终冲突消解后的内容为300股a股票,为<stock><order><ID>a</ID><quantity><howmuch>300</howmuch></quantity></order></stock>。7. B resolves the conflict at the server-side
8、服务器通过服务器端消息队列管理单元201对消息进行一定处理,把消息包装成服务器可识别的消息,之后通过服务器端存储单元202将消息存储在数据库中。8. The server processes the message through the server-side message
9、如果服务器收到此a股票分红或涨停等新消息后,服务器将更新过的消息通过服务器端通信单元206发送给订阅此a股票的所有订阅者,以便用户可以及时的对股票进行实时处理。9. If the server receives new news such as dividends or daily limit of this a stock, the server sends the updated message to all subscribers who subscribe to this a stock through the server-
运用本发明所提供的方法,可以实现在不经过服务器的情况下,支持客户端之间的数据共享。本发明允许客户端在他们连接的时候共享数据,并在他们重新取得连接时,对他们断开连接时进行离线的数据操作所导致的冲突进行冲突消解。本发明还支持在手机设备与服务器之间的采用数据共享式的通信,允许用户对自己已经发布的信息作出修改,并订阅相应信息,服务器会在用户订阅的信息作出改变通知用户。By using the method provided by the invention, data sharing between clients can be supported without going through a server. The invention allows clients to share data when they are connected, and when they reconnect, resolve conflicts caused by offline data operations when they were disconnected. The invention also supports data-sharing communication between the mobile device and the server, allowing users to modify the information they have published and subscribe to corresponding information, and the server will notify the user of changes in the information subscribed by the user.
以上所述,仅为本发明较佳的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,根据本发明的技术方案及其发明构思加以等同替换或改变,都应涵盖在本发明的保护范围之内。The above is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto, any person familiar with the technical field within the technical scope disclosed in the present invention, according to the technical solution of the present invention Any equivalent replacement or change of the inventive concepts thereof shall fall within the protection scope of the present invention.
Claims (5)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN 201010202939 CN101917394B (en) | 2010-06-13 | 2010-06-13 | Middleware system for sharing data in mobile phone equipment and working method |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN 201010202939 CN101917394B (en) | 2010-06-13 | 2010-06-13 | Middleware system for sharing data in mobile phone equipment and working method |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN101917394A true CN101917394A (en) | 2010-12-15 |
| CN101917394B CN101917394B (en) | 2013-03-20 |
Family
ID=43324780
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN 201010202939 Expired - Fee Related CN101917394B (en) | 2010-06-13 | 2010-06-13 | Middleware system for sharing data in mobile phone equipment and working method |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN101917394B (en) |
Cited By (10)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102262668A (en) * | 2011-07-28 | 2011-11-30 | 南京中兴新软件有限责任公司 | Method for reading and writing files of distributed file system, distributed file system and device of distributed file system |
| CN108243174A (en) * | 2016-12-27 | 2018-07-03 | 北京新唐思创教育科技有限公司 | Online Live Interactive System and Method |
| CN108881492A (en) * | 2018-08-08 | 2018-11-23 | 百卓网络科技有限公司 | A method of it solving Message Processing sequence and dredges Message Processing |
| CN108898356A (en) * | 2018-06-12 | 2018-11-27 | 北京仿真中心 | Across the unit test data team shared system of one kind |
| CN109286671A (en) * | 2018-09-29 | 2019-01-29 | 青岛海尔科技有限公司 | Subscription notification processing method, device, storage medium and device in IoT environment |
| CN109743142A (en) * | 2018-09-30 | 2019-05-10 | 比亚迪股份有限公司 | Message communication method and device |
| CN111130999A (en) * | 2019-12-23 | 2020-05-08 | 飞天诚信科技股份有限公司 | Method and bus adapter suitable for distributed message transmission |
| CN112987915A (en) * | 2021-02-04 | 2021-06-18 | 复旦大学 | AST-based method applied to VR conference and whiteboard editing task |
| CN113434522A (en) * | 2021-05-08 | 2021-09-24 | 华东师范大学 | Parallel updating method and updating system on state tree facing alliance chain |
| CN114756520A (en) * | 2015-10-02 | 2022-07-15 | 谷歌有限责任公司 | Method and system for synchronizing offline data in a computing system |
Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2008245031A (en) * | 2007-03-28 | 2008-10-09 | Nippon Telegr & Teleph Corp <Ntt> | Multilink communication system, multilink communication method, multilink communication apparatus, multilink communication system management method, multilink communication base station, and multilink terminal |
| CN101521899A (en) * | 2009-03-31 | 2009-09-02 | 大连海事大学 | System and method for on-computer test of mobile applications |
-
2010
- 2010-06-13 CN CN 201010202939 patent/CN101917394B/en not_active Expired - Fee Related
Patent Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| JP2008245031A (en) * | 2007-03-28 | 2008-10-09 | Nippon Telegr & Teleph Corp <Ntt> | Multilink communication system, multilink communication method, multilink communication apparatus, multilink communication system management method, multilink communication base station, and multilink terminal |
| CN101521899A (en) * | 2009-03-31 | 2009-09-02 | 大连海事大学 | System and method for on-computer test of mobile applications |
Cited By (14)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102262668A (en) * | 2011-07-28 | 2011-11-30 | 南京中兴新软件有限责任公司 | Method for reading and writing files of distributed file system, distributed file system and device of distributed file system |
| CN114756520A (en) * | 2015-10-02 | 2022-07-15 | 谷歌有限责任公司 | Method and system for synchronizing offline data in a computing system |
| CN108243174A (en) * | 2016-12-27 | 2018-07-03 | 北京新唐思创教育科技有限公司 | Online Live Interactive System and Method |
| CN108243174B (en) * | 2016-12-27 | 2020-10-30 | 北京新唐思创教育科技有限公司 | Online live interactive system and method |
| CN108898356A (en) * | 2018-06-12 | 2018-11-27 | 北京仿真中心 | Across the unit test data team shared system of one kind |
| CN108881492A (en) * | 2018-08-08 | 2018-11-23 | 百卓网络科技有限公司 | A method of it solving Message Processing sequence and dredges Message Processing |
| CN109286671A (en) * | 2018-09-29 | 2019-01-29 | 青岛海尔科技有限公司 | Subscription notification processing method, device, storage medium and device in IoT environment |
| CN109743142A (en) * | 2018-09-30 | 2019-05-10 | 比亚迪股份有限公司 | Message communication method and device |
| CN111130999A (en) * | 2019-12-23 | 2020-05-08 | 飞天诚信科技股份有限公司 | Method and bus adapter suitable for distributed message transmission |
| CN111130999B (en) * | 2019-12-23 | 2021-08-31 | 飞天诚信科技股份有限公司 | Method and bus adapter suitable for distributed message transmission |
| CN112987915A (en) * | 2021-02-04 | 2021-06-18 | 复旦大学 | AST-based method applied to VR conference and whiteboard editing task |
| CN112987915B (en) * | 2021-02-04 | 2022-10-11 | 复旦大学 | AST-based method for collaborative whiteboard editing tasks in VR conferences |
| CN113434522A (en) * | 2021-05-08 | 2021-09-24 | 华东师范大学 | Parallel updating method and updating system on state tree facing alliance chain |
| CN113434522B (en) * | 2021-05-08 | 2023-06-09 | 华东师范大学 | Parallel updating method and updating system on state tree oriented to alliance chain |
Also Published As
| Publication number | Publication date |
|---|---|
| CN101917394B (en) | 2013-03-20 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| CN101917394B (en) | Middleware system for sharing data in mobile phone equipment and working method | |
| JP4560513B2 (en) | Method and apparatus for sharing resources via handset terminal | |
| CN106790629A (en) | Data synchronization unit and its realize the method for data syn-chronization, client access system | |
| EP2492860B1 (en) | Forwarding data from server to device | |
| WO2013085739A1 (en) | Techniques to manage remote events | |
| CN112527520A (en) | Method and device for deploying message middleware | |
| CN109783151B (en) | Method and device for rule change | |
| WO2017174026A1 (en) | Client connection method and system | |
| CN108712457A (en) | Back-end server dynamic load method of adjustment and device based on Nginx reverse proxys | |
| CN110062004A (en) | A kind of message handling system and method based on Internet of Things fidonetFido | |
| US20090133036A1 (en) | Coordinating resources using a volatile network intermediary | |
| CN100459556C (en) | Method for data sharing | |
| JP2005530258A (en) | System and method for resynchronization while refreshing a client device from a server | |
| US10425778B2 (en) | Distributed transactions on mobile devices via a messaging service provided by a mobile network operator | |
| CN201854301U (en) | Middleware system for data sharing on mobile devices | |
| CN110661857B (en) | Data synchronization method and device | |
| WO2025158261A1 (en) | Request processing method and apparatus, and task execution method and apparatus | |
| CN102137158A (en) | Method for sharing information equipment resources by utilizing equipment agent system | |
| US20060020708A1 (en) | System and method for peer-to-peer communication | |
| CN112187916B (en) | A cross-system data synchronization method and device | |
| CN113973135A (en) | Data caching processing method and device, caching grid platform and storage medium | |
| US20130138751A1 (en) | Role-independent context exchange | |
| WO2018132557A1 (en) | Dynamic protocol switching | |
| CN102523271A (en) | Terminal and communication method and system thereof | |
| CN114885020B (en) | Data transmission system and method |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| C06 | Publication | ||
| PB01 | Publication | ||
| C10 | Entry into substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| C14 | Grant of patent or utility model | ||
| GR01 | Patent grant | ||
| C17 | Cessation of patent right | ||
| CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20130320 Termination date: 20130613 |