A TCP message conversion method, device, system and computer storage medium
By obtaining and parsing TCP messages and converting them into multiple target data formats using the conversion rules generated in graphical mode, the problem of poor compatibility of TCP messages conversion in the existing technology is solved, and more efficient data format conversion is achieved and lower development complexity, suitable for a variety of business scenarios.
Patent Information
- Application Number
- CN202010509110.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-07
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2040-06-07
AI Technical Summary
The prior art has poor compatibility in TCP message conversion, resulting in duplicate development and code implementation irregularities, and introduces potential bugs, especially when the TCP message needs to be converted to multiple different data formats.
By obtaining the conversion rules between the TCP packet to be converted and multiple target data formats, parsing the packet and generating intermediate data objects, and then converting them into target data formats based on these rules, generating conversion rules in graphical way, using DB2 database storage and reading conversion rules realize the conversion of multiple target data formats, and send the converted data to the corresponding service interface according to the category of the target data format.
It improves the compatibility and diversity of TCP message conversion, reduces development difficulty, reduces code writing complexity, enhances application applicability, can be applied to a variety of business scenarios, and reduces the occurrence of bugs.
Smart Images

Figure CN111782882B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a TCP message conversion method, device, system and computer storage medium. Background Art
[0002] The software industry converts TCP messages by developing code for specific communication information to achieve specific format conversion. Different communication formats require the development of corresponding structured data conversion code, which leads to duplicate development and potential bugs due to non-standard and incorrect code implementation.
[0003] Traditional message conversion technology has poor compatibility and is targeted. For example, if XML data structure is used in the system TCP communication process, then a corresponding XML conversion device needs to be developed. There is a lack of technology that can convert TCP messages into a variety of different data formats. Summary of the invention
[0004] In order to improve the deficiencies in the related art, the present invention is committed to providing a TCP message conversion method, comprising the following steps:
[0005] Obtain conversion rules between the TCP message to be converted and multiple target data formats;
[0006] Receive the TCP message to be converted and parse it, and output the intermediate data object after parsing;
[0007] The intermediate data object is converted into target data in at least one target data format according to a conversion rule between the TCP message to be converted and a plurality of target data formats.
[0008] Wherein, the conversion rule is generated in a graphical manner.
[0009] Wherein, obtaining the conversion rules between the TCP message to be converted and the multiple target data formats includes obtaining the conversion rules between the TCP message to be converted and the multiple target data formats from a DB2 database.
[0010] Further, the converted target data is sent to the corresponding service interface according to the type of the target data format.
[0011] The TCP message to be converted is obtained through socket processing.
[0012] A second aspect of the present invention provides a TCP message conversion device, comprising:
[0013] A TCP message acquisition module, used to acquire the TCP message to be converted;
[0014] TCP message parsing module, parses the TCP message to be converted and outputs the intermediate data object;
[0015] The conversion module converts the intermediate data object into target data of at least one target data format according to the conversion rules between the TCP message to be converted and multiple target data formats.
[0016] The conversion module includes a plurality of conversion engines, each of which can convert the intermediate data object into target data in a target data format.
[0017] It further includes a DB2 database for storing conversion rules between TCP messages to be converted and various target data formats.
[0018] Furthermore, it includes a sending module, which is used to send the converted target data to the corresponding service interface according to the type of the target data format.
[0019] A third aspect of the present invention provides a computer storage medium, wherein the computer storage medium stores a computer program, wherein the computer program implements any of the above-described methods when executed by a processor.
[0020] A fourth aspect of the present invention provides a TCP message conversion system, comprising:
[0021] A client, wherein the client generates conversion rules between the TCP message to be converted and a plurality of target data formats by graphically configuring;
[0022] DB2 database, used for storing the conversion rules sent by the client;
[0023] A conversion device reads the conversion rule, converts the TCP message to be converted into target data in at least one format according to the conversion rule, and sends the target data to a corresponding service interface.
[0024] By adopting the technical solution of any aspect of the present disclosure, the TCP message to be converted can be converted into target data in a variety of different data formats, thereby improving the compatibility of the TCP message conversion method and making it applicable to a variety of business scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 Schematic diagram of the TCP message conversion process of the present invention
[0026] Figure 2 The schematic diagram of the structure of the TCP message conversion device of the present invention is
[0027] Figure 3 The schematic diagram of the TCP message conversion system of the present invention is DETAILED DESCRIPTION
[0028] The embodiments of the present invention are described in detail below with reference to the accompanying drawings, but the present invention can be implemented in many different ways as defined and covered by the claims.
[0029] Embodiment 1:
[0030] The following is with the help of Figure 1 The technical solution of this example is schematically described. The TCP message conversion method of this example includes the following steps:
[0031] Step S101, obtaining conversion rules between a TCP message to be converted and a plurality of target data formats;
[0032] The TCP message to be converted is obtained through socket processing, and the multiple target data formats may include communication data formats used by various applications, such as XML format, JSON format, fixed-length format, variable-length format, standard ISO8583 format, namespaced XML format, non-standard XML format, etc.
[0033] Step S102, receiving the TCP message to be converted and parsing it, and outputting the intermediate data object after parsing;
[0034] The TCP message to be converted is parsed to obtain the contents of each field in the TCP message to be converted. All or part of the above fields are used as intermediate data objects according to the conversion needs. The intermediate data objects can be customized. The parsing process can include parsing the rules itself, checking the encryption and decryption expressions, parsing the encoding format, etc., and then the above contents can be used to generate intermediate data objects.
[0035] Step S103: convert the intermediate data object into target data in at least one target data format according to the conversion rule between the TCP message to be converted and multiple target data formats.
[0036] For example, if the TCP message to be converted needs to be converted into the target data in XML format, the conversion rule is to first intercept the first 71 bits of the TCP message byte stream, and parse the 71 bits into the unique identifier of the subsequent conversion rule, which contains six elements: area code, business type, business unit, entrusting unit, channel, and transaction code. The corresponding conversion rule is queried from the cache or database through the unique identifier, and then. Check the encoding format (UTF-8, GBK, etc.) configured in the conversion rule, and convert the message byte stream into text information according to the encoding format. Further check whether the encryption and decryption expression or transcoding expression is configured in the conversion rule. If so, transcode or decrypt the TCP message according to the configured expression. Then, you can also check the message type configured in the conversion rule (taking XML as an example). If the message type is XML, read the XML tag in the message according to the relationship between the tag and the intermediate object variable defined in the conversion rule, match the intermediate object variable through the tag name, and if there is a matching intermediate object variable, assign the value of the XML tag to the intermediate object variable.
[0037] Wherein, the conversion rule is generated in a graphical manner.
[0038] Development or operation and maintenance personnel can add or modify the information required for TCP message TCP conversion on the graphical client on Windows, such as configuration format conversion type, encoding format, encryption and decryption expression, and message format. Generate conversion rules based on this graphical configuration. Graphical TCP message conversion configuration does not require code development, shields the tedious code writing of the message format conversion part, greatly reduces the difficulty of application development, and can speed up the application launch.
[0039] Acquiring conversion rules between TCP messages and multiple target data formats includes acquiring conversion rules between the TCP messages and multiple target data formats from a DB2 database.
[0040] After the conversion rules are generated through various configurations of the graphical interface, they can be sent by the client to the DB2 database for storage, which can be permanent storage or non-permanent storage. When performing conversion, the conversion rules in the DB2 database can be read and used to convert the TCP message into the required format.
[0041] Step S104: Send the converted target data to the corresponding service interface for processing according to the type of the target data format.
[0042] In the application, the call data across systems or platforms is required to realize the system docking. For this purpose, the TCP message data needs to be converted into the target data of the required target format according to the requirements of each system or platform for data. Then, the converted target data is sent to the corresponding service interface for processing according to the category of the target data format. Here, the service interface refers to the interface of different systems or platforms. One feasible way is to define the association relationship between different types of target data formats and related service interfaces in a graphical interface. The association relationship data can be stored in the DB2 data together with the conversion rules as part of the content in the conversion rules for reading and calling during conversion. The association relationship can also be stored separately in the DB2 database, and read and call when the target data needs to be sent to the application service interface. In a specific embodiment of the present implementation, the association relationship can be a relationship table, for example, the target data of the target data format 1 corresponds to the service interface 1, and the target data of the target data format 2 corresponds to the service interface 2. The conversion engine 231 is used to convert the TCP message into the target data a of the target data format 1, and the conversion engine 232 is used to convert the TCP message into the target data b of the target data format 2, and then the above target data a is sent to the service interface 1 according to the association relationship table, and the target data b is sent to the service interface b.
[0043] This embodiment can define the relationship between the target data and the service interface, so that the converted target data is preferentially distributed to the corresponding service interface through the interface service for business processing. Through the interface service management, this embodiment can be seamlessly connected with the connected business system.
[0044] Example 2
[0045] like Figure 2 As shown, this embodiment provides a TCP message conversion device 2, including:
[0046] The TCP message acquisition module 21 is used to obtain the TCP message to be converted; wherein the TCP message to be converted is obtained through processing by the socket component 4, and the multiple target data formats may include communication data formats used by various applications, such as XML format, JSON format, fixed-length format, variable-length format, standard ISO8583 format, XML format with namespace, non-standard XML format, etc.
[0047] A TCP message parsing module 22, which parses the TCP message to be converted;
[0048] The TCP message to be converted is parsed to obtain the contents of each field in the TCP message to be converted. All or part of the above fields are used as intermediate data objects according to the conversion needs. The intermediate data objects can be customized. The parsing process can include parsing the rules itself, checking the encryption and decryption expressions, parsing the encoding format, etc., and then the above contents can be used to generate intermediate data objects.
[0049] The conversion module 23 converts the intermediate data object generated after parsing by the parsing module 22 into target data in at least one target data format according to the conversion rules between the TCP message and multiple target data formats.
[0050] For example, if the TCP message to be converted needs to be converted into the target data in XML format, the conversion rule is to first intercept the first 71 bits of the TCP message byte stream, and parse the 71 bits into the unique identifier of the subsequent conversion rule, which contains six elements: area code, business type, business unit, entrusting unit, channel, and transaction code. The corresponding conversion rule is queried from the cache or database through the unique identifier, and then. Check the encoding format (UTF-8, GBK, etc.) configured in the conversion rule, and convert the message byte stream into text information according to the encoding format. Further check whether the encryption and decryption expression or transcoding expression is configured in the conversion rule. If so, transcode or decrypt the TCP message according to the configured expression. Then, you can also check the message type configured in the conversion rule (taking XML as an example). If the message type is XML, read the XML tag in the message according to the relationship between the tag and the intermediate object variable defined in the conversion rule, match the intermediate object variable through the tag name, and if there is a matching intermediate object variable, assign the value of the XML tag to the intermediate object variable.
[0051] The conversion module 23 includes a plurality of conversion engines 231 (232...23n), each of which can convert the parsed TCP message into target data in a target data format.
[0052] The conversion module 23 integrates multiple message conversion engines 231. The conversion rules in each conversion engine 231 are generated by the configuration of the graphical user interface. For example, when the TCP message protocol is converted to the XML data interface target data, the value mode, internal variables, external message path, description, parent node, data type and domain value processing are configured in the graphical interface. The value mode includes variables, expressions, enumerations, sub-messages, sub-cell conversion, loop domains, etc.; data types include strings, integers, arrays, bytes, high-precision floating point numbers, etc.
[0053] The value-taking method is used to specify how to process the value of this part of the message. The internal variable refers to which specific intermediate data object variable this part of the message is assigned to. The external message path refers to where in the message the value is obtained. The parent node refers to the outermost node of the variable in the loop domain value-taking method. The data type refers to the data type of the intermediate object variable to which the data in the message is converted. The domain value processing refers to the processing required for the data in the message after it is assigned to the intermediate object. For example, the message format is " <root> <stddate> 20200422 <stddate>< / stddate> < / stddate> < / root> ", select variable for value setting, internal variable can be set to date, external message path is set to ROOT.stddate, data type is selected as string, and other settings are not made. The data in the message can be converted into a date variable of string type and passed to the system. The TCP message is converted into XML structured data through the above rules.
[0054] In this embodiment, the conversion device 2 further includes a DB2 database 24 for storing conversion rules between TCP messages and various target data formats.
[0055] Furthermore, it includes a sending module 25 for sending the converted target data to the corresponding service interface 3 according to the type of the target data format.
[0056] In this embodiment, in the graphical interface, different types of target data formats can be defined with related service interfaces 3. The association relationship data can be stored in the DB2 data 24 together with the conversion rules as part of the conversion rules for reading and calling during conversion. The association relationship can also be stored separately in the DB2 database 24, and read and called when the target data needs to be sent to the application service interface 3. In a specific example of this embodiment, the association relationship can be a relationship table, for example, the target data of the target data format 1 corresponds to the service interface 31, and the target data of the target data format 2 corresponds to the service interface 32. The conversion engine 231 is used to convert the TCP message into the target data a of the target data format 1, and the conversion engine 232 is used to convert the TCP message into the target data b of the target data format 2, and then send the above target data a to the service interface 31 and the target data b to the service interface 32 according to the association relationship table.
[0057] This embodiment can define the relationship between the target data and the service interface 30, so that the converted target data is preferentially distributed to the corresponding service interface 30 for business processing through the service interface 30. Through the service interface management, this embodiment can be seamlessly connected with the connected business system.
[0058] Example 3
[0059] A third aspect of the present invention provides a computer storage medium, wherein the computer storage medium stores a computer program, and when the computer program is executed by a processor, any of the above methods is implemented.
[0060] Example 4
[0061] This embodiment provides a TCP message conversion system, including:
[0062] Client 1, the client 1 generates conversion rules between TCP messages and multiple target data formats through graphical configuration. Client 1 can be an application interface or APP, for example, the client can run on a computer, a pad, a mobile terminal, and a dedicated electronic device, presenting a graphical configuration interface without any code changes, avoiding the risk of new BUGs introduced by developers due to irregular development.
[0063] DB2 database 24, used to store the conversion rules sent by the client 1;
[0064] The conversion device 2 reads the conversion rule, converts the TCP message into target data in at least one target data format according to the conversion rule, and sends the target data to the corresponding service interface 3.
[0065] In this embodiment, in the graphical interface, different types of target data formats can also be defined with related service interfaces 3. The association relationship data can be stored in the DB2 data 24 together with the conversion rules as part of the conversion rules for reading and calling during conversion. The association relationship can also be stored separately in the DB2 database 24, and read and called when the target data needs to be sent to the application service interface 3. In a specific example of this embodiment, the association relationship can be a relationship table, for example, the target data of the target data format 1 corresponds to the service interface 31, and the target data of the target data format 2 corresponds to the service interface 32. The conversion engine 231 is used to convert the TCP message into the target data a of the target data format 1, and the conversion engine 232 is used to convert the TCP message into the target data b of the target data format 2, and then send the above target data a to the service interface 31 and the target data b to the service interface 32 according to the association relationship table.
[0066] By adopting the technical solution of any aspect of the present disclosure, TCP messages can be converted into target data in a variety of different formats, thereby improving the diversity of TCP message conversion and being applicable to a variety of business scenarios.
[0067] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0068] The above are only some implementation methods of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A TCP message conversion method, characterized in that: The following steps are involved: Obtain conversion rules between the TCP message to be converted and multiple target data formats; Receive the TCP message to be converted and parse it, and output the intermediate data object after parsing; Converting the intermediate data object into target data in at least one target data format according to a conversion rule between the TCP message to be converted and a plurality of target data formats; The conversion rules are generated in a graphical manner, and different types of target data formats are associated with related service interface definitions in a graphical interface, and the associated relationship data is stored in a DB2 database together with the conversion rules as part of the content in the conversion rules; The TCP message to be converted is parsed to obtain the content of each field in the TCP message to be converted, and all or part of the above fields are used as intermediate data objects. The parsing process includes parsing the rules itself, checking the encryption and decryption expressions and parsing the encoding format; The step of obtaining the conversion rules between the TCP message to be converted and the multiple target data formats includes obtaining the conversion rules between the TCP message to be converted and the multiple target data formats from a DB2 database.
2. The TCP message conversion method according to claim 1, wherein: The converted target data is sent to the corresponding service interface according to the type of the target data format.
3. A TCP message conversion device, characterized in that: include: A TCP message acquisition module, used to acquire the TCP message to be converted; A TCP message parsing module parses the TCP message to be converted into an intermediate data object; A conversion module, converting the intermediate data object into target data of at least one target data format according to the conversion rules between the TCP message to be converted and multiple target data formats; The conversion rules are generated in a graphical manner, and different types of target data formats are associated with related service interface definitions in a graphical interface, and the associated relationship data is stored in a DB2 database together with the conversion rules as part of the content in the conversion rules; The TCP message to be converted is parsed to obtain the content of each field in the TCP message to be converted, and all or part of the above fields are used as intermediate data objects. The parsing process includes parsing the rules itself, checking the encryption and decryption expressions and parsing the encoding format; The DB2 database is used to store the conversion rules between the TCP messages to be converted and various target data formats.
4. The TCP message conversion device according to claim 3, characterized in that: The conversion module includes a plurality of conversion engines, each of which converts the intermediate data object into target data in a target data format.
5. The TCP message conversion device according to claim 3, characterized in that: It includes a sending module, which is used to send the converted target data to the corresponding service interface according to the type of the target data format.
6. A computer storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 2 is implemented.
Citation Information
Patent Citations
Information extraction and audit method of DB2 database operation, device and system thereof
CN101561806A
Wind energy electric field communication controller, system and centralized control method
CN102231072A
Data exchange platform
CN108964971A
Data transmission method and device
CN109547474A
File format conversion method and device and computer readable storage medium
CN111191422A