WO2012126301A1 - 一种消息发送、接收处理的方法及其装置 - Google Patents

一种消息发送、接收处理的方法及其装置 Download PDF

Info

Publication number
WO2012126301A1
WO2012126301A1 PCT/CN2012/071219 CN2012071219W WO2012126301A1 WO 2012126301 A1 WO2012126301 A1 WO 2012126301A1 CN 2012071219 W CN2012071219 W CN 2012071219W WO 2012126301 A1 WO2012126301 A1 WO 2012126301A1
Authority
WO
WIPO (PCT)
Prior art keywords
message
dictionary
child node
information
parsed
Prior art date
Application number
PCT/CN2012/071219
Other languages
English (en)
French (fr)
Inventor
翁建钢
闫新成
张佰林
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2012126301A1 publication Critical patent/WO2012126301A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L51/00User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
    • H04L51/06Message adaptation to terminal or network requirements
    • H04L51/066Format adaptation, e.g. format conversion or compression

Definitions

  • the present invention relates to the field of communications, and in particular, to a message transmission processing method and apparatus thereof, a message receiving processing method, and an apparatus therefor.
  • Background technique
  • the cross-CPU (central processing unit) communication interface (such as the socket interface) provided by the operating system is usually encapsulated to realize the message communication method distributed by the message ID; Communication mode, the application only needs to care about the message ID and the message content itself interface, and does not need to care about the underlying socket creation and maintenance process.
  • This communication method is referred to as "communication by message structure”.
  • a unified software platform is used among communication nodes in a distributed system, so communication between communication nodes (ie, communication between CPUs) and different processes within communication nodes in a distributed system Communication (that is, CPU internal communication) is the same, the transceiver and the two sides only need to define a message structure and message ID, which can realize communication between CPUs.
  • the present invention provides a message sending and receiving method and a device thereof to provide a new message compatibility mechanism, so that communication messages can be implemented between communication nodes based on different software versions. To ensure that messages are correctly delivered between communication nodes based on different software versions in a distributed system.
  • a message sending processing method applied to a distributed system, comprising:
  • a message sending processing apparatus including:
  • a message dictionary obtaining unit configured to search a message dictionary corresponding to the to-be-sent message from the locally stored message dictionary library, the message dictionary is used to describe the structure information of the to-be-sent message, and the message sending unit is configured to The message dictionary acquired by the message dictionary obtaining unit is set in the to-be-sent message, and sends the to-be-sent message.
  • a message receiving processing method is applied to a distributed system, including:
  • the first message dictionary is used to describe structure information of the message;
  • an embodiment of the present invention further provides a message receiving and processing apparatus, including: a message dictionary extracting unit, configured to receive a message, and extract a first message dictionary from the message, where the first message dictionary is used to describe The structure information of the message;
  • a message dictionary obtaining unit configured to acquire a second message dictionary corresponding to the message from a locally stored message dictionary library, where the second message dictionary is used to describe structure information of the message; Comparing the first message dictionary extracted by the message dictionary extracting unit with the version of the second message dictionary acquired by the message dictionary acquiring unit, and extracting the application information from the message according to the comparison result.
  • a communication node in a distributed system comprising: the foregoing message transmission processing device, and/or the aforementioned message reception processing device.
  • the first message dictionary for describing the structure information of the message is extracted from the message, and the message dictionary library stored locally is used to describe the message.
  • a second message dictionary of the structure information comparing the versions of the first message dictionary and the second message dictionary, and extracting application information from the message according to the comparison result.
  • the versions of the dictionary are compared, and corresponding application information is extracted from the message according to the comparison result, thereby realizing message compatibility between communication nodes based on different software versions, and ensuring communication between different communication nodes based on different software versions in the distributed system Ability to deliver messages correctly.
  • FIG. 1 is a flowchart of a method for message sending processing according to an embodiment of the present invention
  • FIG. 2 is a flowchart of a method for receiving a message according to an embodiment of the present invention
  • FIG. 3 is a flowchart of a method for generating a message dictionary in an embodiment of the present invention.
  • FIG. 4 is a flowchart of a method for specifically transmitting a message by a communication node in a distributed system according to an embodiment of the present invention
  • FIG. 5 is a flowchart of a specific method for a message receiving process performed by a communication node in a distributed system according to an embodiment of the present invention
  • FIG. 6 is a schematic structural diagram of a message sending and processing apparatus according to an embodiment of the present invention.
  • FIG. 7 is a schematic structural diagram of a message receiving and processing apparatus according to an embodiment of the present invention. detailed description
  • the present invention provides a method for transmitting and receiving a message and a device thereof to provide a new message compatibility mechanism, so that communication nodes based on different software versions can be implemented.
  • Message compatibility from ensuring that messages are correctly delivered between communication nodes based on different software versions in a distributed system.
  • the message sending processing method may include: searching a message dictionary corresponding to the to-be-sent message from the locally stored message dictionary library, where the message dictionary is used to describe the structure information of the to-be-sent message; A message dictionary is set in the to-be-sent message, and the to-be-sent message is sent.
  • the message receiving processing method may include: when receiving the message, extracting a first message dictionary for describing structure information of the message from the message, and acquiring, from the locally stored message dictionary library, the message for describing the message.
  • the second message dictionary of the structure information compares the versions of the first message dictionary and the second message dictionary, and extracts the application information from the message according to the comparison result.
  • FIG. 1 is a flowchart of a method for sending a message according to an embodiment of the present invention.
  • the method is applied to a distributed system, and the communication node A sends a message as an example, including: Step 101:
  • the communication node A searches for a message dictionary corresponding to the message to be sent from the locally stored message dictionary database, and the message dictionary is used to describe the structure information of the message to be sent.
  • Step 102 The communication node A sets a message dictionary corresponding to the to-be-sent message in the to-be-sent message, and sends the to-be-sent message.
  • the communication node A sets the message dictionary acquired in step 101 at the head of the message to be transmitted.
  • the step 101 of the foregoing process may further include the following steps:
  • the communication node A generates a message dictionary corresponding to the message to be sent, the message dictionary is a data structure for describing structure information of the message to be sent, and includes at least one child node for describing field information.
  • the communication node A generates the message dictionary corresponding to the message to be sent, and may adopt the following manner: extract global symbol table information of the message structure of the message to be sent, and generate global symbol table debugging information according to the global symbol table information;
  • FIG. 2 is a flowchart of a method for receiving a message according to an embodiment of the present invention. The method is described by using a message sent by a communication node B by a communication node A as an example. The method includes:
  • Step 201 The communication node A receives the message sent by the communication node B, and extracts a first message dictionary from the message, where the first message dictionary is used to describe the structure information of the message.
  • Step 202 The communication node A obtains a second message dictionary corresponding to the message from a locally stored message dictionary library, where the second message dictionary is used to describe structure information of the message.
  • Step 203 The communication node A compares versions of the first message dictionary and the second message dictionary, and extracts application information from the message according to the comparison result.
  • the communication node A extracts information from the message according to the comparison result, including: when the version of the first message dictionary is consistent with the version of the second message dictionary, the communication node A receives the message. Extracting an application data payload; when the version of the first message dictionary is inconsistent with a version of the second message dictionary, the message is from the message according to the first version of the lower version of the first message dictionary or the second message dictionary Extracting application information, such as: when the version of the first message dictionary is lower than the version of the second message dictionary, the communication node A extracts application information from the message according to the first message dictionary; When the version of the first message dictionary is higher than the version of the second message dictionary, the communication node A extracts the application information from the message according to the second message dictionary.
  • the first message dictionary and the second message dictionary may be set as data for describing the structure information of the message.
  • Structure and the data structure includes at least one child node for describing field information.
  • a message dictionary consists of a plurality of child nodes to form a tree data structure.
  • the message dictionary may include one or more of the following types of child nodes: a primitive type child node, a primitive array type child node, a structure type child node, and a structure array type child node, where: a continuous primitive type member field in memory
  • the independent child node is a primitive type child node, and the primitive type may include char, unsigned char, short, unsigned short, int, unsigned int, long, unsigned long, float, double, enum, union, etc.;
  • the independent child node is the original array type child node; the independent child node composed of the custom structure type member field is the structure type child node; the independent child node formed by the structure array member field is the structure array type child node.
  • the application can modify the internal information of the child nodes according to the following trailing append field principle: After a primitive type child node is generated, subsequent modifications will only be in the original The original data type field is added to the end of the type child node, and the operation of deleting the existing field of the original type child node, modifying the type, or inserting a new field is prohibited.
  • the application can increase the array length of the original array type child node, but it is prohibited to reduce the array length of the original array type child node.
  • the application can modify the structure field itself, so the description information of the structure type child node and the structure array type child node needs to be expanded:
  • the memory description information of the node and structure array type child nodes is filled in the message dictionary as the next-level child node information, and is recursively calculated according to this principle until the child nodes of the last layer node are all primitive type child nodes or original array type children. node.
  • the end of the original type child node applied to the lower level of the structure type child node is modified according to the tail append field principle; for the structure body group type child node, the application can modify the array length, and can also The end of the primitive type child node of the subordinate of the structure group type sub-node is modified according to the tail append field original n 'j.
  • extracting the application information from the message according to the first message dictionary may specifically include: determining, for each of the to-be-parsed child nodes in the first message dictionary, the to-be-parsed child node and the Whether the corresponding child nodes in the second message dictionary are consistent. If they are consistent, the corresponding application information is extracted from the message payload of the message corresponding to the to-be-parsed child node; if not, according to the to-be-parsed child The type of node extracts the corresponding application information from the message.
  • Extracting corresponding application information from the message according to the type of the to-be-parsed child node may be as follows: when the to-be-parsed child node is a primitive type child node or an original type array type child node, according to the first message
  • the length of the to-be-parsed child node recorded in the dictionary extracts corresponding application information from a location corresponding to the to-be-parsed child node in a message payload of the message; when the child node to be resolved is a structure type And a recursive call of the message-compatible processing to the to-be-parsed child node and the corresponding message part according to the length of the to-be-parsed child node recorded in the first message dictionary; Subsection for structure array type At the time of the point, the recursive call of the message-compatible processing is performed on the to-be-parsed child node and the corresponding message part according to the length of the array of the to-be-parsed child node recorded in the first message dictionary.
  • extracting the application information from the message according to the second message dictionary may include: determining, for each to-be-parsed child node in the second message dictionary, the child node to be resolved and the Whether the corresponding child nodes in the first message dictionary are consistent, if they are consistent, extract corresponding application information from a location corresponding to the to-be-parsed child node in the message payload of the message; if not, according to the to-be-parsed child The type of node extracts the corresponding application information from the message.
  • Extracting the corresponding application information from the message according to the type of the to-be-parsed child node including: when the child node to be resolved is a primitive type child node or an original type array type child node, according to the second message dictionary
  • the length of the to-be-parsed child node recorded in the message payload is extracted from the message payload of the message corresponding to the to-be-parsed child node; when the child node to be resolved is a structure type child node Recursively invoking message compatibility processing on the to-be-parsed child node and its corresponding message part according to the length of the to-be-parsed child node recorded in the second message dictionary;
  • the structure array type child node is used, the recursive call of the message compatibility processing is performed on the to-be-parsed child node and the corresponding message part according to the array length of the to-be-parsed child node recorded in the second message dictionary.
  • the method may further include:
  • the communication node A searches for a message dictionary corresponding to the message to be sent from the locally stored message dictionary library when determining that the message needs to be sent; the communication node A searches the message dictionary library for the message dictionary corresponding to the message to be sent. And setting a searched message dictionary in the to-be-sent message, and sending the message through the message sending interface; and, when the communication node A cannot find the message dictionary corresponding to the to-be-sent message in the message dictionary library, The to-be-sent message is sent through a message sending interface.
  • the correspondence between the message ID number and the message dictionary is stored in the message dictionary library, and when the corresponding message dictionary of the corresponding message needs to be searched from the message dictionary library, the message is extracted.
  • the ID number, and the message dictionary corresponding to the extracted ID number is obtained from the correspondence in the message dictionary library.
  • a message dictionary is generated, which can be implemented by using the flow shown in FIG. 3.
  • 3 is a flowchart of a method for generating a message dictionary according to an embodiment of the present invention.
  • the method includes: Step 301: Record application registration information of a message structure of a message that needs to be subjected to message compatibility processing to a specified source file StmctReg.c , and compile the source file StmctReg.c to get the compiled file StructReg.o.
  • a message transmitted between different boards in a distributed system is determined as a message requiring message compatibility processing.
  • information about a message-consistent message structure is required, which may include: a header file path defined by the message structure body, a message ID number, and a message structure body.
  • Step 302 Parse the compiled file StructReg.o, extract global symbol table information corresponding to each message structure, and separately sort the global symbol table information corresponding to each extracted message structure to obtain each message structure. Corresponding global symbol table debugging information, get the data file StructReg.dat.
  • Step 303 Perform global symbol table debugging information corresponding to each message structure in the data file StructReg.dat, and obtain available structure description information corresponding to each message.
  • Step 304 Generate, according to the available structure description information corresponding to each message in the StructReg.dat, a message description dictionary library source file MsgMap.c, where the dictionary library source file MsgMap.c includes a message dictionary corresponding to each message, and each message dictionary The corresponding child nodes for describing the field information of the corresponding structure are included.
  • the message dictionary includes at least one child node, and the child node is a data structure used to describe the memory distribution of the message structure field; when defining the child node, the child node type and the next sibling child node of the child node may be defined.
  • the ID number, the number of child nodes included in the child node, and the memory size occupied by the child nodes can be defined as follows:
  • the length of the dictionary information required by a message structure is short.
  • the description information of the struct tag syn hdr message structure can be clearly described by only two child nodes.
  • the original type child node and the structure array type child node are described as follows:
  • Step 305 Write the message ID and its corresponding message dictionary association into the message dictionary registration table of the dictionary library source file MsgMap.c.
  • Step 306 Compile the dictionary library source file MsgMap.c to obtain a binary object file MsgMap.o, and then link the binary object file MsgMap.o with the existing object file TmpProject.o to generate a final binary target.
  • FIG. 4 is a flowchart of a method for specifically transmitting a message by a communication node in a distributed system according to an embodiment of the present invention, where the method includes:
  • Step 401 Receive a message sending request, where the message sending request carries a message to be sent. ID number.
  • Step 402 From the message dictionary registration table of the locally stored message dictionary library, find whether there is a message dictionary registration table entry corresponding to the ID number of the message to be sent, and if yes, execute step 403; otherwise, execute step 405.
  • Step 403 Obtain a message dictionary corresponding to the ID number from the message dictionary database according to the found message dictionary registration table entry, and set the message dictionary in the to-be-sent message.
  • the message dictionary can be set at the head of the message to be sent.
  • Step 404 Call the ordinary message sending interface to output the to-be-sent message set with the message dictionary.
  • Step 405 Call an ordinary message sending interface to output the to-be-sent message.
  • the message sending interface is set as a universal message sending interface for message compatibility processing, and the format of the sending message may be as follows: MsgSendEx(MsgID, MsgBuf, ).
  • FIG. 5 is a flowchart of a method for a message receiving process performed by a communication node in a distributed system according to an embodiment of the present invention. The method is described by using a message sent by the communication node B to the communication node A as an example. The method includes:
  • Step 500 The communication node B receives the message sent by the communication node B.
  • Step 501 The communication node B extracts the message dictionary A corresponding to the message from the received message, and acquires a message dictionary corresponding to the ID number of the message from the locally stored message dictionary library according to the ID number of the message.
  • the communication node B first obtains a message dictionary registration table entry corresponding to the ID number of the message from the message dictionary registration table of the locally stored message dictionary library, and according to the message word step 502, the communication node B The local message cache is cleared to store the application information obtained by processing the received message.
  • Step 503 The communication node B determines the version of the message dictionary A and the message dictionary B. Whether the versions are consistent, if yes, step 504 is performed, otherwise step 505 is performed.
  • Step 504 The communication node B directly extracts the application data payload from the message, and stores the extracted application data payload into the local message cache, and performs step 522.
  • Step 505 The communication node B determines whether the version of the message dictionary A is lower than the version of the message dictionary B. If yes, step 506 is performed; otherwise, step 514 is performed.
  • Step 506 Determine whether the communication node B has traversed all the child nodes in the message dictionary A. If otherwise, perform step 507, otherwise step 522 is performed.
  • Step 507 Determine whether the current traversal child node and the child node corresponding to the current traversal child node in the message dictionary B are consistent. If yes, step 508 is performed; otherwise, step 509 is performed.
  • Step 508 The communication node B extracts corresponding application information from the message payload of the message and the corresponding location of the current traversal child node according to the current traversal information of the child node, and stores the application information to the local message cache. , and step 506 is performed.
  • Step 509 The communication node B determines whether the current traversal child node is a structure type child node or a structure array type child node. If otherwise, step 510 is performed, otherwise step 511 is performed.
  • Step 510 The communication node B determines that the current traversal child node is a primitive type child node or a primitive type array child node, and according to the length of the current traversal child node recorded in the message dictionary A, the message from the message is net.
  • the location corresponding to the current traversing child node extracts corresponding application information, stores the application information into the local message cache, and performs step 506.
  • the modification of the original type child node and the original array type child node is a tail new field, and therefore, the original type child node or the original array type child node in the high version message dictionary B is low.
  • a field is added at the end of the child node; therefore, when the communication node B extracts the corresponding application information from the message according to the message dictionary A, Fill in the default value of 0 for the remaining field parts.
  • Step 511 The communication node B determines whether the current traversal sub-node is a structural type sub-node. If yes, step 512 is performed; otherwise, step 513 is performed.
  • Step 512 The communication node B performs a recursive call of the message compliant processing on the current traversal child node and its corresponding message part according to the length of the current traversal child node recorded in the message dictionary A, and performs step 506.
  • Step 513 The communication node B performs recursive calling of the message compatibility processing on the current traversing child node and the corresponding message part according to the array length of the current traversing child node recorded in the message dictionary A, and the remaining The field part is filled in with the default value of 0, and step 506 is performed.
  • Step 514 Whether the communication node B has traversed all the sub-nodes in the message dictionary B, if yes, step 522 is performed, otherwise step 515 is performed.
  • Step 515 Determine whether the current traversal child node and the child node corresponding to the current traversal child node in the message dictionary A are consistent. If yes, execute step 516; otherwise, perform step 517.
  • Step 516 The communication node B extracts corresponding application information from the message payload of the message and the corresponding location of the current traversal child node according to the current traversal information of the child node, and stores the application information to the local message cache. , and step 522 is performed.
  • Step 517 The communication node B determines whether the current traversal child node is a structure type child node or a structure array type child node. If otherwise, step 518 is performed, otherwise step 519 is performed.
  • Step 518 The communication node B determines that the currently traversed child node is a primitive type child node or a primitive type array child node, according to the length of the current traversal child node recorded in the message dictionary B, the message from the message Corresponding application information is extracted from the location corresponding to the current traversal sub-node in the payload, and the application information is stored in the local message cache, and the remaining field portions are filled in with the default value of 0, and step 514 is performed.
  • Step 519 The communication node B determines whether the currently traversed child node is a structure type child node, and if yes, performs step 520; otherwise, step 521 is performed.
  • Step 520 The communication node B performs a recursive call of the message compatibility processing on the current traversal child node and the corresponding message part according to the length of the current traversal child node recorded in the message dictionary B, and performs step 514.
  • Step 521 The communication node B performs recursive calling of the message compatibility processing on the current traversing child node and the corresponding message part according to the array length of the current traversing child node recorded in the message dictionary B, and the remaining The field part is uniformly filled in with the default value of 0, and step 514 is performed.
  • Step 522 The communication node B sorts the application information cached in the local message cache, sends the application information to the upper layer application, and ends the process.
  • an embodiment of the present invention further provides a message sending processing apparatus and a message receiving processing apparatus.
  • FIG. 6 is a schematic structural diagram of a message sending and processing apparatus according to an embodiment of the present invention, where the apparatus includes:
  • a message dictionary obtaining unit 61 configured to search, from a locally stored message dictionary library, a message dictionary corresponding to the message to be sent, where the message dictionary is used to describe the structure message sending unit 62 of the message to be sent,
  • the message dictionary acquired by the message dictionary obtaining unit 61 is set in the to-be-sent message, and sends the to-be-sent message.
  • FIG. 7 is a schematic structural diagram of a message receiving and processing apparatus according to an embodiment of the present invention, where the apparatus includes:
  • the message dictionary extracting unit 71 is configured to receive a message, and extract a first message dictionary from the message, where the first message dictionary is used to describe structure information of the message.
  • the message dictionary obtaining unit 72 is configured to obtain a second message dictionary corresponding to the message from a locally stored message dictionary library, where the second message dictionary is used to describe structure information of the message.
  • the message processing unit 73 is configured to compare the version of the second message dictionary obtained by the first message dictionary extracted by the message dictionary obtaining unit 72 with the message dictionary extracting unit 71, and extract the application information from the message according to the comparison result.
  • the message processing unit 73 is specifically configured to:
  • the first message dictionary is a data structure for describing structure information of a message, and includes at least one child node for describing field information; a message processing unit 73 according to the first message dictionary from the The application information is extracted from the message, and is used to: determine, for each of the to-be-parsed child nodes in the first message dictionary, whether the to-be-parsed child node is consistent with the corresponding child node in the second message dictionary, and if they are consistent, Extracting corresponding application information from a location corresponding to the to-be-parsed child node in the message payload of the message; if not, extracting corresponding application information from the message according to the type of the to-be-parsed child node.
  • the message processing unit 73 extracts corresponding application information from the message according to the type of the to-be-parsed child node, including: when the child node to be resolved is a primitive type child node or a primitive type array type child node And extracting, according to the length of the to-be-parsed child node recorded in the first message dictionary, corresponding application information from a location corresponding to the to-be-parsed child node in a message payload of the message;
  • the child node is a structural type child node, according to the length of the to-be-parsed child node recorded in the first message dictionary, the child node to be resolved and The corresponding message part performs a recursive call of the message compatibility processing; when the to-be-parsed child node is a structure array type child node, according to the length of the array of the to-be-parsed child node recorded in the first message dictionary, The to-be-parsed child node and its corresponding message part perform recursive call of message
  • the second message dictionary is a data structure for describing structure information of the message, and includes at least one child node for describing field information; the message processing unit 73 is configured according to the second message dictionary.
  • Extracting the application information in the message including: determining, for each of the to-be-parsed child nodes in the second message dictionary, whether the child node to be resolved is consistent with a corresponding child node in the first message dictionary, and if they are consistent, And corresponding to the location of the to-be-parsed child node in the message payload of the message, the corresponding application information is extracted; if not, the corresponding application information is extracted from the message according to the type of the to-be-parsed child node.
  • the message processing unit 73 extracts corresponding application information from the message according to the type of the to-be-parsed child node, and is specifically configured to: when the child node to be resolved is a primitive type child node or an original type array type a node, according to the length of the to-be-parsed child node recorded in the second message dictionary, extract corresponding application information from a location corresponding to the to-be-parsed child node in a message payload of the message;
  • the sub-node to be parsed is a sub-node of the structure type, recursively processing the message-compatible processing of the to-be-parsed child node and its corresponding message part according to the length of the to-be-parsed child node recorded in the second message dictionary Calling; when the child node to be parsed is a child of a structure array type, according to the length of the array of the child node to be resolved recorded in the second message dictionary, the child node to be resolved and its corresponding message Partial re
  • the embodiment of the present invention further provides a communication node in a distributed system, and the communication node may include the message transmission processing device shown in FIG. 6, and/or includes the foregoing message reception processing device.
  • the message carries a message dictionary for describing the structure information of the message, and when the receiving end receives the message, the message dictionary carried in the message is The locally stored version of the message dictionary corresponding to the message is compared, and the corresponding application information is extracted from the message according to the comparison result, thereby realizing message compatibility between the communication nodes based on different software versions, and ensuring the distributed system Messages can be correctly delivered between communication nodes based on different software versions.
  • the present invention carries a message dictionary for describing structure information of the message in the message, and when the receiving end receives the message, the receiving end carries the message dictionary carried in the message and the locally stored message dictionary corresponding to the message.
  • the versions are compared, and the corresponding application information is extracted from the message according to the comparison result, thereby realizing message compatibility between communication nodes based on different software versions, and ensuring communication nodes based on different software versions in the distributed system can Deliver the message correctly.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)
  • Stored Programmes (AREA)

Abstract

本发明公开了一种消息发送、接收方法及其装置,本发明在消息中携带有用于描述该消息的结构体信息的消息字典,并且接收端在接收到该消息时,将消息中携带的消息字典与本地存储的与该消息对应的消息字典的版本进行比较,根据比较结果从消息中提取相应的应用信息,从而实现了基于不同软件版本的通信节点之间能够实现消息兼容,从确保分布式系统中基于不同软件版本的通信节点之间能够正确的传递消息。

Description

一种消息发送、 接收处理的方法及其装置 技术领域
本发明涉及通信领域, 尤其涉及一种消息发送处理方法及其装置、 一 种消息接收处理方法及其装置。 背景技术
目前, 随着通信业务的快速发展, 通信业务种类和用户数量等都呈现 出爆炸式增长的发展趋势, 随之而来的是需要传递处理海量的信息, 这对 通信设备的业务能力带来较大的挑战; 为处理海量的信息, 目前将通信设 备的内部架构调整为更科学的分布式处理模型, 分布式系统中各通信节点 之间分工合作、 流水化作业, 从而使通信设备的整体性能得到最大限度的 利用。
随着分布式系统中通信设备内部的通信节点数变得越来越多, 各通信 节点的分工更趋细化; 在运作过程中, 分布系统中的通信节点间需要经常 交流种类繁多的内部控制信息, 为简化上层应用的通信节点间通信, 通常 都会对操作系统提供的跨 CPU (中央处理器)通信接口 (如 socket接口) 进行封装, 以实现按消息 ID分发的消息通信方式; 采用该种通信方式, 应 用只需要关心消息 ID和消息内容本身接口, 无需关心底层的 socket创建、 维护等过程, 此通信方式简称 "按消息结构通信"。 根据软件集成化的基本 要求, 分布式系统中的各通信节点间使用统一的软件平台, 因此分布式系 统中的各通信节点间的通信(即 CPU之间的通信)与通信节点内部不同进 程间通信(即 CPU内部通信)一样, 收发两端只需要定义一个消息结构体 和消息 ID, 即可实现 CPU之间的通信。
随着新功能的加入, 已有消息结构体不能满足日益增长的需求, 当分 布式系统中的部分通信节点使用新功能时, 需要对已有的公用消息结构体 进行修改, 因此, 为保证分布系统中的各通信节点间能够正常使用该公用 消息结构体, 对分布系统中的所有通信节点的软件版本进行升级。 这种确 保分布式系统中的各通信节点间能够正常使用公共消息结构体的方式, 虽 然具有一定的效力, 但是一般情况下分布式系统中的通信节点的数量繁多, 若对每个通信节点的软件版本进行升级将带来较大的工作量, 甚至可能会 带来不必要的工程风险。 发明内容
针对现有技术存在的上述技术问题, 本发明实施例提供一种消息发送、 接收方法及其装置 , 以提供一种新的消息兼容机制 , 使得基于不同软件版 本的通信节点之间能够实现消息兼容, 从而确保分布式系统中基于不同软 件版本的通信节点之间能够正确的传递消息。
一种消息发送处理方法, 应用于分布式系统, 包括:
从本地存储的消息字典库中查找与待发送消息对应的消息字典, 所述 消息字典用于描述所述待发送消息的结构体信息;
将所述待发送消息对应的消息字典设置在所述待发送消息中, 并发送 所述待发送消息。
相应地, 还提供一种消息发送处理装置, 包括:
消息字典获取单元, 用于从本地存储的消息字典库中查找与待发送消 息对应的消息字典, 所述消息字典用于描述所述待发送消息的结构体信息; 消息发送单元, 用于将所述消息字典获取单元获取的所述消息字典设 置在所述待发送消息中, 并发送所述待发送消息。
一种消息接收处理方法, 应用于分布式系统, 包括:
接收消息, 并从所述消息中提取第一消息字典, 所述第一消息字典用 于描述所述消息的结构体信息; 从本地存储的消息字典库中获取与所述消息对应的第二消息字典, 所 述第二消息字典用于描述所述消息的结构体信息;
比较所述第一消息字典和第二消息字典的版本, 根据比较结果从所述 消息中提取应用信息。
相应地, 本发明实施例还提供一种消息接收处理装置, 包括: 消息字典提取单元, 用于接收消息, 并从所述消息中提取第一消息字 典, 所述第一消息字典用于描述所述消息的结构体信息;
消息字典获取单元, 用于从本地存储的消息字典库中获取与所述消息 对应的第二消息字典, 所述第二消息字典用于描述所述消息的结构体信息; 消息处理单元, 用于比较所述消息字典提取单元提取得到的第一消息 字典与所述消息字典获取单元获取的第二消息字典的版本, 并根据比较结 果从所述消息中提取应用信息。
一种分布式系统中的通信节点, 包括: 前述消息发送处理装置, 和 /或 前述消息接收处理装置。
本发明实施例中, 在接收到消息时, 从该消息中提取用于描述所述消 息的结构体信息的第一消息字典, 并从本地存储的消息字典库中获取用于 描述所述消息的结构体信息的第二消息字典, 再比较所述第一消息字典和 第二消息字典的版本, 根据比较结果从所述消息中提取应用信息。 采用本 发明技术方案, 在消息中携带有用于描述该消息的结构体信息的消息字典, 并且接收端在接收到该消息时, 将消息中携带的消息字典与本地存储的与 该消息对应的消息字典的版本进行比较, 根据比较结果从消息中提取相应 的应用信息, 从而实现了基于不同软件版本的通信节点之间能够实现消息 兼容, 从确保分布式系统中基于不同软件版本的通信节点之间能够正确的 传递消息。 附图说明
图 1为本发明实施例中消息发送处理的方法流程图;
图 2为本发明实施例中消息接收处理的方法流程图;
图 3为本发明实施例中生成消息字典的方法流程图;
图 4 为本发明实施例中分布式系统中通信节点具体进行消息发送处理 的方法流程图;
图 5 为本发明实施例中分布式系统中通信节点具体进行消息接收处理 的具体方法流程图;
图 6为本发明实施例中消息发送处理装置的结构示意图;
图 7为本发明实施例中消息接收处理装置的结构示意图。 具体实施方式
针对现有技术存在的上述技术问题, 本发明实施例提供一种消息发送、 接收处理的方法及其装置, 以提供一种新的消息兼容机制, 使得基于不同 软件版本的通信节点之间能够实现消息兼容, 从确保分布式系统中基于不 同软件版本的通信节点之间能够正确的传递消息。 消息发送处理方法可包 括: 从本地存储的消息字典库中查找与待发送消息对应的消息字典, 所述 消息字典用于描述所述待发送消息的结构体信息; 将所述待发送消息对应 的消息字典设置在所述待发送消息中, 并发送所述待发送消息。 消息接收 处理方法可包括: 在接收到消息时, 从该消息中提取用于描述所述消息的 结构体信息的第一消息字典, 并从本地存储的消息字典库中获取用于描述 所述消息的结构体信息的第二消息字典, 再比较所述第一消息字典和第二 消息字典的版本, 根据比较结果从所述消息中提取应用信息。
下面结合说明书附图对本发明技术方案进行详细的描述。
参见图 1 , 为本发明实施例中消息发送处理的方法流程图, 该方法应用 于分布式系统, 以通信节点 A发送消息为例, 包括: 步驟 101、 通信节点 A从本地存储的消息字典库中查找与待发送消息 对应的消息字典, 所述消息字典用于描述所述待发送消息的结构体信息。
步驟 102、 通信节点 A将所述待发送消息对应的消息字典设置在所述 待发送消息中, 并发送所述待发送消息。
该步驟中, 通信节点 A将步驟 101 中获取的消息字典设置在所述待发 送消息的头部。
较佳地, 上述流程的步驟 101之前还可包括步驟:
通信节点 A生成所述待发送消息对应的消息字典, 所述消息字典为用 于描述所述待发送消息的结构体信息的数据结构, 且包括至少一个用于描 述字段信息的子节点。
通信节点 A生成所述待发送消息对应的消息字典, 可采用以下方式: 提取所述待发送消息的消息结构体的全局符号表信息, 并根据所述全 局符号表信息生成全局符号表调试信息;
根据所述全局符号表调试信息生成至少一个用于描述所述消息结构体 的字段信息的子节点;
根据所述至少一个用于描述所述消息结构体的字段信息的子节点和所 述待发送消息的应用登记信息, 生成与所述待发送消息对应的消息字典, 所述应用登记信息包括所述待发送消息的标识信息 (如 ID号)、 名称和所 述消息结构体的头文件路径。
参见图 2, 为本发明实施例中消息接收处理的方法流程图, 该方法以通 信节点 A接收通信节点 B发送的消息为例进行说明, 该方法包括:
步驟 201、 通信节点 A接收通信节点 B发送的消息, 并从所述消息中 提取第一消息字典, 所述第一消息字典用于描述所述消息的结构体信息。
步驟 202、 通信节点 A从本地存储的消息字典库中获取与所述消息对 应的第二消息字典, 所述第二消息字典用于描述所述消息的结构体信息。 步驟 203、 通信节点 A比较所述第一消息字典和第二消息字典的版本, 根据比较结果从所述消息中提取应用信息。
上述流程步驟 203中, 通信节点 A根据比较结果从所述消息中提取信 息, 包括: 当所述第一消息字典的版本与所述第二消息字典的版本一致时, 通信节点 A从所述消息中提取应用数据净荷; 当所述第一消息字典的版本 与所述第二消息字典的版本不一致时, 根据较低版本的所述第一消息字典 或所述第二消息字典从所述消息中提取应用信息, 如: 当所述第一消息字 典的版本低于所述第二消息字典的版本时, 通信节点 A根据所述第一消息 字典从所述消息中提取应用信息; 当所述第一消息字典的版本高于所述第 二消息字典的版本时, 通信节点 A根据所述第二消息字典从所述消息中提 取应用信息。
较佳地, 为进一步提高通信节点对接收到的消息进行解析, 本发明实 施例中, 所述第一消息字典和所述第二消息字典均可以设置为用于描述消 息的结构体信息的数据结构, 且该数据结构包括至少一个用于描述字段信 息的子节点。 如消息字典由多个子节点构成树状数据结构。 消息字典中可 包括以下一类或多类子节点: 原始类型子节点、 原始数组类型子节点、 结 构体类型子节点和结构体数组型子节点, 其中: 内存中连续的原始类型成 员字段构成的独立子节点为原始类型子节点, 原始类型可包括 char、 unsigned char、 short、 unsigned short、 int、 unsigned int, long, unsigned long, float, double, enum、 union等; 原始类型成员字段的数组构成的独立子节 点为原始数组类型子节点; 自定义的结构体类型成员字段构成的独立子节 点为结构体类型子节点; 结构体数组成员字段构成的独立子节点为结构体 数组型子节点。
针对原始类型子节点, 应用可按照以下尾部追加字段原则对子节点内 部信息进行修改: 一个原始类型子节点生成之后, 后续修改将只能在原始 类型子节点尾部新增原始数据类型字段, 而禁止对原始类型子节点的已有 字段进行删除、 修改类型或插入新字段等操作。 针对原始数组类型子节点, 应用可以增加原始数组类型子节点的数组长度, 但是禁止缩小原始数组类 型子节点的数组长度。
针对结构体类型子节点和结构体数组类型子节点, 应用可对结构体字 段本身进行修改, 因此需要对结构体类型子节点和结构体数组类型子节点 的描述信息进行扩展: 将结构体类型子节点和结构体数组类型子节点的内 存描述信息作为下一级子节点信息填入消息字典中, 依此原则递归计算, 直到最末层节点的子节点全部是原始类型子节点或者原始数组类型子节 点。 针对结构体类型子节点, 应用在结构体类型子节点的下级的原始类型 子节点末端按照尾部追加字段原则进行修改; 针对结构体属组类型子节点, 应用既可以修改数组长度, 同时也可以在结构体属组类型子节点的下级的 原始类型子节点末端按照尾部追加字段原 n 'j进行修改。
上述步驟 203中, 根据所述第一消息字典从所述消息中提取应用信息, 具体可包括: 针对所述第一消息字典中的每个待解析子节点, 判断该待解 析子节点与所述第二消息字典中相应子节点是否一致, 若一致, 则从所述 消息的消息净荷中与所述待解析子节点对应的位置提取相应的应用信息; 若不一致, 则根据所述待解析子节点的类型从所述消息中提取相应的应用 信息。 根据所述待解析子节点的类型从所述消息中提取相应的应用信息, 可如下: 当所述待解析子节点为原始类型子节点或原始类型数组型子节点 时, 根据所述第一消息字典中记录的所述待解析子节点的长度, 从所述消 息的消息净荷中与所述待解析子节点对应的位置提取相应的应用信息; 当 所述待解析子节点为结构体类型子节点时 , 根据所述第一消息字典中记录 的所述待解析子节点的长度, 对所述待解析子节点及其对应的消息部分进 行消息兼容处理的递归调用; 当所述待解析子节点为结构体数组类型子节 点时, 根据所述第一消息字典中记录的所述待解析子节点的数组长度, 对 所述待解析子节点及其对应的消息部分进行消息兼容处理的递归调用。
上述步驟 203中, 根据所述第二消息字典从所述消息中提取应用信息, 具体可包括: 针对所述第二消息字典中的每个待解析子节点, 判断该待解 析子节点与所述第一消息字典中相应子节点是否一致, 若一致, 则从所述 消息的消息净荷中与所述待解析子节点对应的位置提取相应的应用信息; 若不一致, 则根据所述待解析子节点的类型从所述消息中提取相应的应用 信息。 根据所述待解析子节点的类型从所述消息中提取相应的应用信息, 包括: 当所述待解析子节点为原始类型子节点或原始类型数组型子节点时, 根据所述第二消息字典中记录的所述待解析子节点的长度, 从所述消息的 消息净荷中与所述待解析子节点对应的位置提取相应的应用信息; 当所述 待解析子节点为结构体类型子节点时, 根据所述第二消息字典中记录的所 述待解析子节点的长度, 对所述待解析子节点及其对应的消息部分进行消 息兼容处理的递归调用; 当所述待解析子节点为结构体数组类型子节点时, 根据所述第二消息字典中记录的所述待解析子节点的数组长度, 对所述待 解析子节点及其对应的消息部分进行消息兼容处理的递归调用。
较佳地, 上述流程的任意步驟之前或之后, 还可包括:
通信节点 A在确定需要发送消息时, 从本地存储的消息字典库中查找 与待发送消息对应的消息字典; 通信节点 A在所述消息字典库中查找到与 所述待发送消息对应的消息字典时, 将查找的消息字典设置在所述待发送 消息中, 并通过消息发送接口发送; 以及, 通信节点 A在所述消息字典库 中不能查找到与所述待发送消息对应的消息字典时, 通过消息发送接口发 送所述待发送消息。
本发明实施例中,消息字典库中存储消息 ID号与消息字典的对应关系, 当需要从消息字典库中查找相应消息的对应的消息字典时, 提取该消息的 ID号, 并从消息字典库中的对应关系中获取与提取的 ID号对应的消息字 典。
本发明实施例中, 生成消息字典, 可采用如图 3所示的流程实现。 参见图 3 ,为本发明实施例中生成消息字典的方法流程图,该方法包括: 步驟 301、将需要进行消息兼容处理的消息的消息结构体的应用登记信 息记录到指定的源文件 StmctReg.c中, 并对该源文件 StmctReg.c进行编译 得到编译文件 StructReg.o。
本发明实施例中, 将分布式系统中在不同单板间传输的消息确定为需 要进行消息兼容处理的消息。 该步驟 301 中, 需要进行消息兼容的消息结 构体的相关信息, 可包括: 消息结构体定义的头文件路径、 消息 ID号和消 息结构体本体。
步驟 302、 对所述编译文件 StructReg.o进行解析, 从中提取各消息结 构体各自对应的全局符号表信息, 并对提取的各消息结构体对应的全局符 号表信息分别进行整理得到各消息结构体对应的全局符号表调试信息, 得 到数据文件 StructReg.dat。
步驟 303、对所述数据文件 StructReg.dat中的各消息结构体对应的全局 符号表调试信息进行整理 , 得到各消息对应的可用结构体描述信息。
步驟 304、根据 StructReg.dat中各消息对应的可用结构体描述信息, 生 成消息描述字典库源文件 MsgMap.c, 该字典库源文件 MsgMap.c中包含各 消息分别对应的消息字典, 各消息字典中包括相应的用于描述相应结构体 的字段信息的子节点。
本发明实施例中, 消息字典包括至少一个子节点, 子节点为用于描述 消息结构体字段内存分布的数据结构; 在定义子节点时, 可定义子节点类 型、 子节点的下一个兄弟子节点的 ID号、 该子节点所包含的子节点数和子 节点所占用的内存大小等, 具体可定义如下:
typedef struct StructNode {
type; /* 子节点类型 */
Brother; /* 该子节点的下一个兄弟子节点的 ID号 */ ChildNum; /* 此子节点所拥有的孩子节点数 */
Len; /* 此子节点所占用的内存的大小 */
}T— StructNode。
由于对消息结构体的调试信息进行了压缩整合, 一个消息结构体所需 要的字典信息长度较短, 如 struct tag syn hdr消息结构体的描述信息仅需 要两个子节点就即可描述清楚, 可采用原始类型子节点和结构体数组类型 子节点进行描述, 具体可如下:
typedef struct tag syn hdr
{
BYTE operate;
BYTE ucNum;
BYTE ucPad[2]; //前三个变量为一个原始类型子节点
cfg_info data[5]; 〃结构体数组类型子节点
} syn— hdr。
步驟 305、 将消息 ID 及其对应的消息字典关联写入字典库源文件 MsgMap.c的消息字典登记表中。
步驟 306、 对所述字典库源文件 MsgMap.c进行编译, 得到二进制目标 文件 MsgMap.o , 再将该二进制目标文件 MsgMap.o 与已有的目标文件 TmpProject.o进行链接, 生成最终的二进制目标文件 Project.o。 参见图 4,为本发明实施例中分布式系统中通信节点具体进行消息发送 处理的方法流程图, 该方法包括:
步驟 401、接收消息发送请求, 该消息发送请求中携带有待发送消息的 ID号。
步驟 402、从本地存储的消息字典库的消息字典登记表中, 查找是否存 在与待发送消息的 ID号对应的消息字典登记表条目,若有则执行步驟 403 , 否则执行步驟 405。
步驟 403、根据查找到的消息字典登记表条目,从消息字典库中获取与 所述 ID号对应的消息字典, 并将该消息字典设置在所述待发送消息中。
该步驟中, 可将消息字典设置在待发送消息的头部。
步驟 404、调用普通的消息发送接口输出设置有消息字典的所述待发送 消息。
步驟 405、 调用普通的消息发送接口输出所述待发送消息。
较佳地, 上述消息发送接口设置为消息兼容处理的通用消息发送接口, 发送消息的格式可如下: MsgSendEx(MsgID, MsgBuf, ... ... )。
参见图 5,为本发明实施例中分布式系统中通信节点进行消息接收处理 的方法流程图, 该方法以通信节点 B接收通信节点 A发送的消息为例进行 说明, 方法包括:
步驟 500、 通信节点 B接收通信节点 B发送的消息。
步驟 501、 通信节点 B从接收到的消息中提取与该消息对应的消息字 典 A, 并根据所述消息的 ID号从本地存储的消息字典库中获取与所述消息 的 ID号对应的消息字典 B。
该步驟中, 通信节点 B先从本地存储的消息字典库的消息字典登记表 中, 获取与所述消息的 ID号对应的消息字典登记表条目, 并根据该消息字 步驟 502、 通信节点 B将本地消息緩存清零, 以便存储此次对接收到 的所述消息进行处理得到的应用信息。
步驟 503、 通信节点 B判断所述消息字典 A的版本与所述消息字典 B 的版本是否一致, 若一致则执行步驟 504, 否则执行步驟 505。 步驟 504、 通信节点 B直接从所述消息中提取应用数据净荷, 并将提 取的应用数据净荷存储至所述本地消息緩存中, 并执行步驟 522。
步驟 505、 通信节点 B判断所述消息字典 A的版本是否低于所述消息 字典 B的版本, 若是则执行步驟 506, 否则执行步驟 514。
步驟 506、 判断通信节点 B是否已经遍历完所述消息字典 A中的所有 子节点, 若否则执行步驟 507, 否则执行步驟 522。
步驟 507、 判断当前遍历子节点与消息字典 B 中与该当前遍历子节点 相应的子节点是否一致, 若一致则执行步驟 508, 否则执行步驟 509。
步驟 508、 通信节点 B根据当前遍历子节点的信息, 从所述消息的消 息净荷中与所述当前遍历子节点对应位置提取相应的应用信息, 并将该应 用信息存储至所述本地消息緩存中, 并执行步驟 506。
步驟 509、 通信节点 B判断所述当前遍历子节点是否为结构体类型子 节点或结构体数组类型子节点, 若否则执行步驟 510, 否则执行步驟 511。
步驟 510、 通信节点 B确定所述当前遍历子节点为原始类型子节点或 原始类型数组子节点, 按照所述消息字典 A中记录的所述当前遍历子节点 的长度, 从所述消息的消息净荷中与所述当前遍历子节点对应的位置提取 相应的应用信息, 并将该应用信息存储至所述本地消息緩存中, 并执行步 驟 506。
较佳地, 本发明实施例中, 针对原始类型子节点和原始数组类型子节 点的修改为尾部新增字段, 因此, 高版本消息字典 B中的原始类型子节点 或原始数组类型子节点与低版本消息字典 A中相应原始类型子节点和原始 数组类型子节点相比, 至多就是在子节点尾部新增了字段; 因此, 通信节 点 B在根据消息字典 A从消息中提取相应的应用信息时, 对剩余的字段部 分统一填写默认值 0。 步驟 511、通信节点 B判断所述当前遍历子节点是否为结构体类型子节 点, 若是则执行步驟 512, 否则执行步驟 513。
步驟 512、 通信节点 B根据所述消息字典 A中记录的所述当前遍历子 节点的长度, 对所述当前遍历子节点及其对应的消息部分进行消息兼容处 理的递归调用, 并执行步驟 506。
步驟 513、 通信节点 B根据所述消息字典 A中记录的所述当前遍历子 节点的数组长度, 对所述当前遍历子节点及其对应的消息部分进行消息兼 容处理的递归调用, 并对剩余的字段部分同一填写默认值 0, 并执行步驟 506。
步驟 514、 通信节点 B是否已经遍历完所述消息字典 B中的所有子节 点, 若是则执行步驟 522, 否则执行步驟 515。
步驟 515、 判断当前遍历子节点与消息字典 A中与该当前遍历子节点 相应的子节点是否一致, 若一致则执行步驟 516, 否则执行步驟 517。
步驟 516、 通信节点 B根据所述当前遍历子节点的信息, 从所述消息 的消息净荷中与所述当前遍历子节点对应位置提取相应的应用信息, 并将 该应用信息存储至本地消息緩存中, 并执行步驟 522。
步驟 517、 通信节点 B判断所述当前遍历子节点是否为结构体类型子 节点或结构体数组类型子节点, 若否则执行步驟 518, 否则执行步驟 519。
步驟 518、 通信节点 B确定所述当前遍历的子节点为原始类型子节点 或原始类型数组子节点, 按照所述消息字典 B中记录的所述当前遍历子节 点的长度, 从所述消息的消息净荷中与所述当前遍历子节点对应的位置提 取相应的应用信息, 并将该应用信息存储至本地消息緩存中, 并对剩余的 字段部分同一填写默认值 0, 并执行步驟 514。
步驟 519、 通信节点 B判断所述当前遍历的子节点是否为结构体类型 子节点, 若是则执行步驟 520, 否则执行步驟 521。 步驟 520、 通信节点 B根据所述消息字典 B中记录的所述当前遍历子 节点的长度, 对所述当前遍历子节点及其对应的消息部分进行消息兼容处 理的递归调用, 并执行步驟 514。
步驟 521、 通信节点 B根据所述消息字典 B中记录的所述当前遍历子 节点的数组长度, 对所述当前遍历子节点及其对应的消息部分进行消息兼 容处理的递归调用, 并对剩余的字段部分统一填写默认值 0, 并执行步驟 514。
步驟 522、 通信节点 B将本地消息緩存中緩存的应用信息进行整理后, 发送给上层应用, 并结束流程。
基于前述方法的相同构思, 本发明实施例还提供一种消息发送处理装 置和一种消息接收处理装置。
参见图 6, 为本发明实施例中消息发送处理装置的结构示意图, 该装置 包括:
消息字典获取单元 61 , 用于从本地存储的消息字典库中查找与待发送 消息对应的消息字典, 所述消息字典用于描述所述待发送消息的结构体信 消息发送单元 62,用于将所述消息字典获取单元 61获取的所述消息字 典设置在所述待发送消息中, 并发送所述待发送消息。
参见图 7, 为本发明实施例中消息接收处理装置的结构示意图, 该装置 包括:
消息字典提取单元 71 , 用于接收消息, 并从所述消息中提取第一消息 字典, 所述第一消息字典用于描述所述消息的结构体信息。
消息字典获取单元 72, 用于从本地存储的消息字典库中获取与所述消 息对应的第二消息字典, 所述第二消息字典用于描述所述消息的结构体信 息。 消息处理单元 73 ,用于比较所述消息字典获取单元 72提取得到的第一 消息字典与消息字典提取单元 71获取的第二消息字典的版本, 并根据比较 结果从所述消息中提取应用信息。
较佳地, 消息处理单元 73 , 具体用于:
当所述第一消息字典的版本与所述第二消息字典的版本一致时, 从所 述消息中提取应用数据净荷;
当所述第一消息字典的版本与所述第二消息字典的版本不一致时, 根 据较低版本的所述第一消息字典或所述第二消息字典从所述消息中提取应 用信息, 如: 当所述第一消息字典的版本低于所述第二消息字典的版本时, 根据所述第一消息字典从所述消息中提取应用信息; 当所述第一消息字典 的版本高于所述第二消息字典的版本时, 根据所述第二消息字典从所述消 息中提取应用信息。
较佳地, 所述第一消息字典为用于描述消息的结构体信息的数据结构 , 且包括至少一个用于描述字段信息的子节点; 消息处理单元 73根据所述第 一消息字典从所述消息中提取应用信息, 具体用于: 针对所述第一消息字 典中的每个待解析子节点, 判断该待解析子节点与所述第二消息字典中相 应子节点是否一致, 若一致, 则从所述消息的消息净荷中与所述待解析子 节点对应的位置提取相应的应用信息; 若不一致, 则根据所述待解析子节 点的类型从所述消息中提取相应的应用信息。
较佳地, 消息处理单元 73根据所述待解析子节点的类型从所述消息中 提取相应的应用信息, 包括: 当所述待解析子节点为原始类型子节点或原 始类型数组型子节点时, 根据所述第一消息字典中记录的所述待解析子节 点的长度, 从所述消息的消息净荷中与所述待解析子节点对应的位置提取 相应的应用信息; 当所述待解析子节点为结构体类型子节点时, 根据所述 第一消息字典中记录的所述待解析子节点的长度, 对所述待解析子节点及 其对应的消息部分进行消息兼容处理的递归调用; 当所述待解析子节点为 结构体数组类型子节点时, 根据所述第一消息字典中记录的所述待解析子 节点的数组长度, 对所述待解析子节点及其对应的消息部分进行消息兼容 处理的递归调用。
较佳地, 所述第二消息字典为用于描述消息的结构体信息的数据结构, 且包括至少一个用于描述字段信息的子节点; 消息处理单元 73根据所述第 二消息字典从所述消息中提取应用信息, 包括: 针对所述第二消息字典中 的每个待解析子节点, 判断该待解析子节点与所述第一消息字典中相应子 节点是否一致, 若一致, 则从所述消息的消息净荷中与所述待解析子节点 对应的位置提取相应的应用信息; 若不一致, 则根据所述待解析子节点的 类型从所述消息中提取相应的应用信息。
较佳地, 消息处理单元 73根据所述待解析子节点的类型从所述消息中 提取相应的应用信息, 具体用于: 当所述待解析子节点为原始类型子节点 或原始类型数组型子节点时, 根据所述第二消息字典中记录的所述待解析 子节点的长度, 从所述消息的消息净荷中与所述待解析子节点对应的位置 提取相应的应用信息; 当所述待解析子节点为结构体类型子节点时, 根据 所述第二消息字典中记录的所述待解析子节点的长度, 对所述待解析子节 点及其对应的消息部分进行消息兼容处理的递归调用; 当所述待解析子节 点为结构体数组类型子节点时, 根据所述第二消息字典中记录的所述待解 析子节点的数组长度, 对所述待解析子节点及其对应的消息部分进行消息 兼容处理的递归调用。
本发明实施例还提供一种分布式系统中的通信节点, 该通信节点可包 括图 6所示的消息发送处理装置, 和 /或, 包括前述消息接收处理装置。
采用本发明技术方案, 在消息中携带有用于描述该消息的结构体信息 的消息字典, 并且接收端在接收到该消息时, 将消息中携带的消息字典与 本地存储的与该消息对应的消息字典的版本进行比较, 根据比较结果从消 息中提取相应的应用信息, 从而实现了基于不同软件版本的通信节点之间 能够实现消息兼容, 从确保分布式系统中基于不同软件版本的通信节点之 间能够正确的传递消息。
显然, 本领域的技术人员可以对本发明进行各种改动和变型而不脱离 本发明的精神和范围。 这样, 倘若本发明的这些修改和变型属于本发明权 利要求及其等同技术的范围之内, 则本发明也意图包含这些改动和变型在 内。 工业实用性 本发明在消息中携带有用于描述该消息的结构体信息的消息字典, 并 且接收端在接收到该消息时, 将消息中携带的消息字典与本地存储的与该 消息对应的消息字典的版本进行比较, 根据比较结果从消息中提取相应的 应用信息, 从而实现了基于不同软件版本的通信节点之间能够实现消息兼 容, 从确保分布式系统中基于不同软件版本的通信节点之间能够正确的传 递消息。

Claims

权利要求书
1、 一种消息发送处理方法, 应用于分布式系统, 该方法包括: 从本地存储的消息字典库中查找与待发送消息对应的消息字典, 所述 消息字典用于描述所述待发送消息的结构体信息;
将所述待发送消息对应的消息字典设置在所述待发送消息中, 并发送 所述待发送消息。
2、 如权利要求 1所述的方法, 所述方法还包括: 生成所述待发送消息 对应的消息字典, 所述消息字典为用于描述所述待发送消息的结构体信息 的数据结构, 且包括至少一个用于描述字段信息的子节点。
3、 如权利要求 2所述的方法, 其中, 所述生成所述待发送消息对应的 消息字典, 包括:
提取所述待发送消息的消息结构体的全局符号表信息, 并根据所述全 局符号表信息生成全局符号表调试信息;
根据所述全局符号表调试信息生成至少一个用于描述所述消息结构体 的字段信息的子节点;
根据所述至少一个用于描述所述消息结构体的字段信息的子节点和所 述待发送消息的应用登记信息, 生成与所述待发送消息对应的消息字典, 所述应用登记信息包括所述待发送消息的标识信息、 名称和所述消息结构 体的头文件路径。
4、 一种消息接收处理方法, 应用于分布式系统, 该方法包括: 接收消息, 并从所述消息中提取第一消息字典, 所述第一消息字典用 于描述所述消息的结构体信息;
从本地存储的消息字典库中获取与所述消息对应的第二消息字典, 所 述第二消息字典用于描述所述消息的结构体信息; 比较所述第一消息字典和第二消息字典的版本, 根据比较结果从所述 消息中提取应用信息。
5、 如权利要求 4所述的方法, 其中, 所述根据比较结果从所述消息中 提取应用信息, 包括:
当所述第一消息字典的版本与所述第二消息字典的版本一致时, 从所 述消息中提取应用数据净荷;
当所述第一消息字典的版本与所述第二消息字典的版本不一致时, 根 据较低版本的所述第一消息字典或所述第二消息字典从所述消息中提取应 用信息。
6、 如权利要求 5所述的方法, 其中, 所述第一消息字典和所述第二消 息字典均为用于描述消息的结构体信息的数据结构, 且分别包括至少一个 用于描述字段信息的子节点;
根据所述第一消息字典或所述第二消息字典从所述消息中提取应用信 息, 包括:
针对所述第一消息字典或所述第二消息字典中的每个待解析子节点, 判断该待解析子节点与所述第二消息字典或第一消息字典中相应子节点是 否一致, 若一致, 则从所述消息的消息净荷中与所述待解析子节点对应的 位置提取相应的应用信息; 若不一致, 则根据所述待解析子节点的类型从 所述消息中提 iM目应的应用信息。
7、 如权利要求 6所述的方法, 其中, 所述根据所述待解析子节点的类 型从所述消息中提取相应的应用信息, 包括:
当所述待解析子节点为原始类型子节点或原始类型数组型子节点时, 根据所述第一消息字典或第二消息字典中记录的所述待解析子节点的长 度, 从所述消息的消息净荷中与所述待解析子节点对应的位置提取相应的 应用信息; 当所述待解析子节点为结构体类型子节点时, 根据所述第一消息字典 或第二消息字典中记录的所述待解析子节点的长度, 对所述待解析子节点 及其对应的消息部分进行消息兼容处理的递归调用;
当所述待解析子节点为结构体数组类型子节点时 , 根据所述第一消息 字典或第二消息字典中记录的所述待解析子节点的数组长度, 对所述待解 析子节点及其对应的消息部分进行消息兼容处理的递归调用。
8、 一种消息发送处理装置, 该装置包括:
消息字典获取单元, 用于从本地存储的消息字典库中查找与待发送消 息对应的消息字典, 所述消息字典用于描述所述待发送消息的结构体信息; 消息发送单元, 用于将所述消息字典获取单元获取的所述消息字典设 置在所述待发送消息中, 并发送所述待发送消息。
9、 一种消息接收处理装置, 该装置包括:
消息字典提取单元, 用于接收消息, 并从所述消息中提取第一消息字 典, 所述第一消息字典用于描述所述消息的结构体信息;
消息字典获取单元, 用于从本地存储的消息字典库中获取与所述消息 对应的第二消息字典, 所述第二消息字典用于描述所述消息的结构体信息; 消息处理单元, 用于比较所述消息字典提取单元提取得到的第一消息 字典与所述消息字典获取单元获取的第二消息字典的版本, 并根据比较结 果从所述消息中提取应用信息。
10、 如权利要求 9所述的装置, 其中, 所述消息处理单元, 具体用于: 当所述第一消息字典的版本与所述第二消息字典的版本一致时, 从所 述消息中提取应用数据净荷;
当所述第一消息字典的版本与所述第二消息字典的版本不一致时, 根 据较低版本的所述第一消息字典或所述第二消息字典从所述消息中提取应 用信息。
11、 如权利要求 10所述的装置, 其中, 所述第一消息字典和所述第二 消息字典均为用于描述消息的结构体信息的数据结构, 且分别包括至少一 个用于描述字段信息的子节点;
消息处理单元根据所述第一消息字典或所述第二消息字典从所述消息 中提取应用信息, 具体用于:
针对所述第一消息字典或所述第二消息字典中的每个待解析子节点, 判断该待解析子节点与所述第二消息字典或第一消息字典中相应子节点是 否一致, 若一致, 则从所述消息的消息净荷中与所述待解析子节点对应的 位置提取相应的应用信息; 若不一致, 则根据所述待解析子节点的类型从 所述消息中提 iM目应的应用信息。
12、 如权利要求 11所述的装置, 其中, 所述消息处理单元根据所述待 解析子节点的类型从所述消息中提取相应的应用信息, 具体用于:
当所述待解析子节点为原始类型子节点或原始类型数组型子节点时, 根据所述第一消息字典或第二消息字典中记录的所述待解析子节点的长 度, 从所述消息的消息净荷中与所述待解析子节点对应的位置提取相应的 应用信息;
当所述待解析子节点为结构体类型子节点时 , 根据所述第一消息字典 或第二消息字典中记录的所述待解析子节点的长度, 对所述待解析子节点 及其对应的消息部分进行消息兼容处理的递归调用;
当所述待解析子节点为结构体数组类型子节点时 , 根据所述第一消息 字典或第二消息字典中记录的所述待解析子节点的数组长度, 对所述待解 析子节点及其对应的消息部分进行消息兼容处理的递归调用。
13、 一种分布式系统中的通信节点, 其中, 包括如权利要求 8所述的 消息发送处理装置, 和 /或如权利要求 9~12 任一项所述的消息接收处理装 置。
PCT/CN2012/071219 2011-03-23 2012-02-16 一种消息发送、接收处理的方法及其装置 WO2012126301A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201110070754.0A CN102195895B (zh) 2011-03-23 2011-03-23 一种消息发送、接收处理的方法及其装置
CN201110070754.0 2011-03-23

Publications (1)

Publication Number Publication Date
WO2012126301A1 true WO2012126301A1 (zh) 2012-09-27

Family

ID=44603301

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2012/071219 WO2012126301A1 (zh) 2011-03-23 2012-02-16 一种消息发送、接收处理的方法及其装置

Country Status (2)

Country Link
CN (1) CN102195895B (zh)
WO (1) WO2012126301A1 (zh)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102195895B (zh) * 2011-03-23 2014-12-17 中兴通讯股份有限公司 一种消息发送、接收处理的方法及其装置
CN102495739B (zh) * 2011-11-03 2017-05-24 中兴通讯股份有限公司 一种数据的兼容方法、板间消息的兼容方法及相应系统
US11080244B2 (en) * 2014-05-28 2021-08-03 Hewlett Packard Enterprise Development Lp Inter-version mapping of distributed file systems
CN105635230B (zh) * 2014-11-07 2018-12-25 阿里巴巴集团控股有限公司 一种消息传输方法及装置
CN105677402B (zh) * 2015-12-31 2019-06-11 华为技术有限公司 一种消息转换方法和装置
CN105893512A (zh) * 2016-03-30 2016-08-24 北京忆唐创元文化有限公司 一种基于元数据的任意版本兼容数据结构存取方法及装置
CN106506331B (zh) * 2016-10-26 2019-10-22 宁波菊风系统软件有限公司 一种低延迟的文本信息传输方法
CN108667710B (zh) * 2017-03-28 2022-03-11 腾讯科技(深圳)有限公司 一种信息处理方法及设备
CN109660577B (zh) * 2017-10-10 2020-10-16 中国移动通信有限公司研究院 信息传输方法、通信设备及计算机可读存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101008894A (zh) * 2007-01-26 2007-08-01 华为技术有限公司 实现系统新旧版本兼容的方法及装置
CN101155050A (zh) * 2006-09-29 2008-04-02 华为技术有限公司 一种处理通知消息的方法、终端、服务器及系统
CN101901220A (zh) * 2009-05-27 2010-12-01 北京启明星辰信息技术股份有限公司 一种数据通用显示方法及设备
CN102195895A (zh) * 2011-03-23 2011-09-21 中兴通讯股份有限公司 一种消息发送、接收处理的方法及其装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101155050A (zh) * 2006-09-29 2008-04-02 华为技术有限公司 一种处理通知消息的方法、终端、服务器及系统
CN101008894A (zh) * 2007-01-26 2007-08-01 华为技术有限公司 实现系统新旧版本兼容的方法及装置
CN101901220A (zh) * 2009-05-27 2010-12-01 北京启明星辰信息技术股份有限公司 一种数据通用显示方法及设备
CN102195895A (zh) * 2011-03-23 2011-09-21 中兴通讯股份有限公司 一种消息发送、接收处理的方法及其装置

Also Published As

Publication number Publication date
CN102195895B (zh) 2014-12-17
CN102195895A (zh) 2011-09-21

Similar Documents

Publication Publication Date Title
WO2012126301A1 (zh) 一种消息发送、接收处理的方法及其装置
CN111835786B (zh) 一种对多规约设备数据采集、设备控制的系统
JP4509916B2 (ja) Snmp基盤のネットワーク管理装置および方法
RU2419986C2 (ru) Объединение многострочных протокольных вхождений
CN109768970B (zh) 一种基于可配置的通用协议生成方法
CN107589952A (zh) 智能升级方法、装置和系统
CN101902473B (zh) 基于网格gis的数据同步更新实现方法
CN111683066B (zh) 异构系统集成方法、装置、计算机设备和存储介质
US10445079B2 (en) Mapping and formatting input commands to a third party protocol
WO2020062959A1 (zh) 配置数据的方法及装置
CN109388417A (zh) 一种通信协议的更新方法、系统及终端设备
WO2016201988A1 (zh) 配置数据推送方法及装置
CN103729189A (zh) 基于lua的播放协议转换方法、系统、终端
CN113381870B (zh) 报文处理方法和设备
CN108365976B (zh) 网络服务的优化方法及装置
KR20160103110A (ko) 네트워크 요소 데이터 액세스 방법, 액세스 장치, 및 네트워크 관리 시스템
WO2004075048A1 (ja) ネイティブコンパイル方法、ネイティブコンパイル前処理方法、コンピュータプログラム、およびサーバ
CN111131373B (zh) 呼吸机数据同步系统、方法、装置及存储介质
JP2009265718A (ja) ネットワーク管理情報の差分データのみを送信するネットワーク装置、サーバ、プログラム及び方法
US20100262951A1 (en) System and method for generating a wireless application from a web service definition
JP4049653B2 (ja) プロトコル変換プログラム,プロトコル変換方法並びにプロトコル変換装置
JP6893568B2 (ja) データインタラクションの方法、装置および機器
CN113973135A (zh) 数据缓存处理方法、装置、缓存网格平台和存储介质
CN103856396B (zh) 插件间的报文传递方法及装置、代理插件
CN116346711B (zh) 基于行为树的路由协议表征方法、介质及通信方法

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 12761226

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 12761226

Country of ref document: EP

Kind code of ref document: A1