A cross-service message conversion method, device, equipment and storage medium
Through historical rule base matching and target parser calls, cross-service message conversion is realized, solving the problem of message conversion difficulties during communication between multiple services, improving the flexibility and adaptability of the system, and reducing development costs.
Patent Information
- Application Number
- CN202410857481.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2044-06-28
AI Technical Summary
In modern software development, when communication and collaboration between multiple services, message conversion is difficult due to different programming languages, data formats and communication protocols. Traditional methods require customized development, resulting in code duplication, high maintenance costs, and flexible Poor sex.
Match the conversion messages through the historical rule base, determine the target conversion rules and obtain the target parser, realize cross-service message conversion, and support the conversion of multiple programming languages, data formats and communication protocols.
Reduces repetitive function development, reduces development costs, improves system flexibility and adaptability, and adapts to changes in service interfaces and data formats without modifying message conversion code.
Smart Images

Figure CN118869807B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a cross-service message conversion method, device, equipment and storage medium. Background Art
[0002] In modern software development, it is often necessary to communicate and collaborate between multiple services. These services may use different programming languages, data formats, and communication protocols, which leads to the need for message conversion when communicating across services.
[0003] Traditional message conversion methods are usually customized for specific services and scenarios, that is, each service needs to develop its own message conversion logic, resulting in code duplication and increased maintenance costs. When the service interface or data format changes, the corresponding message conversion code needs to be modified, which increases the difficulty and risk of system maintenance and has poor flexibility. In addition, for some complex message conversion requirements, traditional methods may require multiple data parsing and conversion, resulting in performance degradation. Summary of the invention
[0004] The present invention provides a cross-service message conversion method, device, equipment and storage medium, which enable the conversion process of message data to be shared to the greatest extent, and can be flexibly customized according to the business, reducing repetitive function development.
[0005] According to one aspect of the present invention, a cross-service message conversion method is provided, the method comprising:
[0006] Obtaining a message to be converted and a historical rule base, wherein the historical rule base includes various historical conversion rules;
[0007] Matching the message to be converted through the historical rule base and determining the matching status of the message to be converted, wherein the matching status includes matching and non-matching;
[0008] The target conversion rule of the message to be converted is determined according to the matching situation, and the target parser is obtained based on the target conversion rule, and the target parser is called to perform cross-service conversion on the message to be converted.
[0009] Optionally, the message to be converted is matched through a historical rule base, including: determining whether the message to be converted carries a timestamp, if so, obtaining a first hash value of the message to be converted, and matching each historical conversion rule in the historical rule base with the message to be converted based on the first hash value, wherein the first hash value is a hash value of the message attribute; otherwise, obtaining a second hash value of the message to be converted, and matching each historical conversion rule in the historical rule base with the message to be converted based on the second hash value, wherein the second hash value is a hash value of the message itself.
[0010] Optionally, the target conversion rule of the message to be converted is determined according to the matching situation, including: judging whether the matching situation is a match, if so, taking the historical conversion rule that matches the message to be converted as the target conversion rule; otherwise, determining the target conversion rule of the message to be converted according to a preset rule matching model.
[0011] Optionally, a target conversion rule for the message to be converted is determined according to a preset rule matching model, including: performing field parsing on the message to be converted in a specified manner to generate a first set; obtaining each matching sub-rule, and generating a second set according to each matching sub-rule; matching the first set and the second set through the preset rule matching model to generate a matching result, and determining the target conversion rule according to the matching result, wherein the rule matching model includes preset matching conditions.
[0012] Optionally, determining the target conversion rule based on the matching result includes: determining whether the number of matching sub-rules in the matching result is one, and if so, directly using the matching result as the target conversion rule; otherwise, determining the length value of each matching sub-rule in the matching result, and using the matching sub-rule with the longest length value as the target conversion rule.
[0013] Optionally, obtaining a target parser based on a target conversion rule includes: determining a target rule type corresponding to the target conversion rule, and obtaining a special rule list, wherein the special rule list includes preset special rule types; judging whether the target rule type is in the special rule list, and if so, determining the target parser based on a preset dynamic configuration; otherwise, obtaining the target parser according to the target rule type.
[0014] Optionally, obtaining a target parser according to a target rule type includes: obtaining a parser configuration list, wherein the parser configuration list includes a correspondence between each rule type and a parser; matching the target rule type through the parser configuration list to obtain a target parser that matches the target rule type.
[0015] According to another aspect of the present invention, a cross-service message conversion device is provided, the device comprising:
[0016] A message and rule base acquisition module is used to acquire the message to be converted and acquire the historical rule base, wherein the historical rule base includes various historical conversion rules;
[0017] A message matching module, used to match the message to be converted through the historical rule base and determine the matching status of the message to be converted, wherein the matching status includes matching and non-matching;
[0018] The conversion rule and parser determination module is used to determine the target conversion rule according to the matching situation, obtain the target parser based on the target conversion rule, and call the target parser to perform cross-service conversion on the message to be converted.
[0019] According to another aspect of the present invention, an electronic device is provided, the electronic device comprising:
[0020] at least one processor; and
[0021] a memory communicatively connected to the at least one processor; wherein,
[0022] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can execute a cross-service message conversion method described in any embodiment of the present invention.
[0023] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement a cross-service message conversion method described in any embodiment of the present invention when executed.
[0024] The technical solution of the embodiment of the present invention matches the message to be converted through the historical rule library, which can accelerate the matching efficiency for scenarios with large data volumes. When no historical rules are matched, matching is performed through the preset rule matching model, which can support message conversion between multiple programming languages, data formats and communication protocols. It can adapt to changes in service interfaces and data formats without modifying the message conversion code, has greater versatility and flexibility, reduces repeated development of conversion logic, and reduces development costs.
[0025] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0027] Figure 1 is a flowchart of a cross-service message conversion method provided according to Embodiment 1 of the present invention;
[0028] Figure 2is a flowchart of another cross-service message conversion method provided according to the first embodiment of the present invention;
[0029] Figure 3 is a structural diagram of a conversion service system provided according to Embodiment 1 of the present invention;
[0030] Figure 4 is a flowchart of another cross-service message conversion method provided according to Embodiment 2 of the present invention;
[0031] Figure 5 This is a schematic diagram of the structure of a cross-service message conversion device provided according to Embodiment 3 of the present invention;
[0032] Figure 6 It is a structural schematic diagram of an electronic device for implementing a cross-service message conversion method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0033] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0034] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0035] Embodiment 1
[0036] Figure 1 A flowchart of a cross-service message conversion method is provided for embodiment 1 of the present invention. This embodiment is applicable to the case of multi-service message conversion. The method can be executed by a cross-service message conversion device, and the cross-service message conversion device can be implemented in the form of hardware and / or software.
[0037] like Figure 1 As shown, the method includes:
[0038] S110: Obtain a message to be converted, and obtain a historical rule base, wherein the historical rule base includes various historical conversion rules.
[0039] The message to be converted refers to the information that needs to be converted from one service format to another service format. The historical rule base is a collection of various conversion rules that have been used in the past.
[0040] It should be noted that the historical rule base contains conversion rules that have been established and used in various scenarios in the past. By directly using existing rules, you can avoid duplication of work and starting from scratch, quickly determine the appropriate conversion method, thereby reducing the consumption of time and energy, and also reducing the risk of conversion errors caused by human errors. In addition, the historical rule base can adapt to changing needs and environments. As the business develops and updates, new rules can be continuously incorporated into the historical rule base to continuously enrich and improve it.
[0041] S120: Match the message to be converted using a historical rule library, and determine a matching condition of the message to be converted, wherein the matching condition includes a match and a mismatch.
[0042] The matching situation represents the correspondence between the message to be converted and the historical rules, which is divided into two states: matching and mismatching.
[0043] Specifically, the conversion service system will compare and match the messages to be converted one by one through the historical rule base to determine the specific matching situation of the messages to be converted.
[0044] Optionally, the message to be converted is matched through a historical rule base, including: determining whether the message to be converted carries a timestamp, if so, obtaining a first hash value of the message to be converted, and matching each historical conversion rule in the historical rule base with the message to be converted based on the first hash value, wherein the first hash value is a hash value of the message attribute; otherwise, obtaining a second hash value of the message to be converted, and matching each historical conversion rule in the historical rule base with the message to be converted based on the second hash value, wherein the second hash value is a hash value of the message itself.
[0045] Specifically, the conversion service system will determine whether the message to be converted carries a timestamp. If the message to be converted carries a timestamp, then the first hash value of the message to be converted is further obtained. The first hash value is a hash value calculated based on the message attributes, and then the various historical conversion rules in the historical rule base are matched with the message to be converted through the first hash value. If it is determined that the message to be converted does not carry a timestamp, then the service conversion system will determine the second hash value of the message to be converted. The second hash value is a hash value calculated for the message itself. Then, based on the second hash value, the various historical conversion rules in the historical rule base are matched with the message to be converted.
[0046] Exemplarily, historical rule matching is performed on the message payload transmitted by a service. That is, if there is a rule that has been matched, the rule ID can be used directly to find the corresponding rule details in the rule library and then used directly. There are two main ways to match historical rules: the first is to match the hash value of the message attribute, which is very efficient for rules that only match attributes; the second is to match the hash value of the message itself, which is a message mapping and is also extremely effective for repetitive message value conversion mapping. Historical matching can greatly improve the matching efficiency for processes that require a large amount of rule data to match.
[0047] S130 , determining a target conversion rule for the message to be converted according to the matching situation, obtaining a target parser based on the target conversion rule, and calling the target parser to perform cross-service conversion on the message to be converted.
[0048] Among them, the target conversion rule refers to the specific rules for performing specific conversion operations on the converted message. The target parser is a tool for performing conversion operations, which has the ability to perform specific processing and conversion on messages to achieve cross-service conversion. Cross-service conversion refers to the conversion and transmission of messages between different services to adapt to the needs and processing methods of different services.
[0049] Specifically, the conversion service system will further clarify the target conversion rules corresponding to the message to be converted based on the matching situation, and obtain the corresponding target parser based on the target conversion rules. The target parser can be called to perform actual cross-service conversion processing on the message to be converted, thereby achieving effective conversion and transmission of messages between different services.
[0050] Figure 2 A flowchart of a cross-service message conversion method is provided for the first embodiment of the present invention, and step S130 mainly includes the following steps S131 to S134:
[0051] S131, determine whether the matching situation is a match, if so, execute S132, otherwise, execute S133.
[0052] S132: Use the historical conversion rule that matches the message to be converted as the target conversion rule.
[0053] S133: Determine a target conversion rule for the message to be converted according to a preset rule matching model.
[0054] Specifically, the conversion service system will determine whether the message to be converted matches the rules in the historical rule base. If the match is successful, the matched historical conversion rule is directly used as the target conversion rule. If the message to be converted does not match the rules in the historical rule base, the target conversion rule needs to be determined according to the preset rule matching model.
[0055] Optionally, a target conversion rule for the message to be converted is determined according to a preset rule matching model, including: performing field parsing on the message to be converted in a specified manner to generate a first set; obtaining each matching sub-rule, and generating a second set according to each matching sub-rule; matching the first set and the second set through the preset rule matching model to generate a matching result, and determining the target conversion rule according to the matching result, wherein the rule matching model includes preset matching conditions.
[0056] Specifically, the conversion service system will disassemble and analyze the fields of the message to be converted to generate a first set, and will generate a second set based on the matching sub-rule, which is a specific rule fragment for matching. The preset rule matching model will match the first set and the second set to determine the target conversion rule.
[0057] It should be noted that the preset rule matching model is designed to find the corresponding conversion rules, mainly using relational algebra and set matching operations. The first set is the data after the message to be converted is parsed, using the xpath method to parse each data field, represented by P = {p|p∈message xpath fields}, and the attributes of its data elements are xpath and the value pointed to by xpath itself, such as: person.name:pong. The second set is the content of the conversion rule, represented by R = {rule, dest, name, pos, operation}, which includes the rule content used for matching conversion (rule, which may contain multiple matching sub-rules, for example: matching containing multiple fields), the content after conversion (dest, which is mainly in json format, which is compatible with structured message data), name (name, if it is " / ", it means no name) and the corresponding position (pos, if it is " / ", it means at the root), operation type (including deletion, addition, modification, etc.).
[0058] The rule matching model is mainly based on relational algebra expressions and is expressed using the following formula (1):
[0059]
[0060] Among them, the first set and the second set are used as the result of the Cartesian product for matching selection, and the matching condition is the matching rule set of each element in the second set. If it can be mapped according to a certain business logic function f and is a subset of the first set of message parameters (can be equal), then the matching selection is successful. Further, if the selection is successful, the projection attribute includes the matching rule (rule), the content of the conversion (dest), and the location and name of the conversion. The content of this attribute is the conversion rule that needs to be followed after the match.
[0061] Optionally, determining the target conversion rule based on the matching result includes: determining whether the number of matching sub-rules in the matching result is one, and if so, directly using the matching result as the target conversion rule; otherwise, determining the length value of each matching sub-rule in the matching result, and using the matching sub-rule with the longest length value as the target conversion rule.
[0062] Specifically, if there is only one matching sub-rule, the matching sub-rule can be directly used as the target conversion rule. If the number of matching sub-rules is not one, it is necessary to further determine the length value of each matching sub-rule. The length value can be the number of characters, the number of conditions, or other indicators that measure the complexity of the rule contained in the matching sub-rule. After determining the length value of each matching sub-rule, the conversion service system will use the matching sub-rule with the longest length value as the target conversion rule. This is because generally, a longer matching sub-rule may contain more specific and detailed conditions, and thus is more likely to be accurately applied to the message to be converted.
[0063] S134. Obtain a target parser based on the target conversion rule, and call the target parser to perform cross-service conversion on the message to be converted.
[0064] Specific application scenarios: Figure 3 The first embodiment of the present invention provides a structural diagram of a conversion service system, which has multiple execution units, including: agent communication, message conversion, history library, conversion rules and rule parser. The arrows indicate the direction of data transmission.
[0065] Specifically, proxy communication is the basis for converting service systems to communicate with other service systems across services. Message conversion is generally a logical process performed during the sending or receiving of messages. Therefore, there must be a powerful and efficient proxy communication mechanism, such as reverse proxy: nginx, or other communication modules. The existence of proxy communication also strengthens the processing function after data conversion, such as: http communication to https communication, rest communication to websocket communication, etc. Proxy communication usually uses a combination of messages and topics for communication, where the topic represents the service in which the business logic of the message processing is located. For example, the url in the reverse proxy nginx indicates the corresponding message processing service logic. Other types of proxy communication can be in the form of other types of topics.
[0066] Specifically, message conversion is to use the corresponding conversion rules and rule parsers to perform corresponding message conversion. The execution unit is more responsible for scheduling, matching different rules according to different messages, and calling different rule parsers for processing. The execution unit will generate conversion history data and write it into the history library.
[0067] Specifically, the conversion rules should include various matching rule descriptions, matching process, content and form after conversion, and conversion type. The execution unit is the core of the conversion process. It expresses a general configuration and logic of structured data conversion. Various businesses can modify the logic of conversion data by configuring the content of the rule. It is a very easy to expand module that can flexibly customize rules according to the business. The function of the execution unit is scheduled by the message conversion execution unit.
[0068] Specifically, the rule parser mainly includes the parser for matching rules in the conversion rule module and the parser for parsing the converted content after the rule is successfully matched. The main function of the execution unit is to parse the matching and use of rules, and the parsed data is called the target rule data, and is used in the message conversion module.
[0069] Specifically, the history database contains relevant data in the message conversion process, including: the hash value of the message attribute, the hash value of the message itself, as well as the conversion rule ID, conversion time, conversion status, etc.
[0070] The technical solution of the embodiment of the present invention matches the message to be converted through the historical rule library, which can accelerate the matching efficiency for scenarios with large data volumes. When no historical rules are matched, matching is performed through the preset rule matching model, which can support message conversion between multiple programming languages, data formats and communication protocols. It can adapt to changes in service interfaces and data formats without modifying the message conversion code, has greater versatility and flexibility, reduces repeated development of conversion logic, and reduces development costs.
[0071] Embodiment 2
[0072] Figure 4 This is a flowchart of a cross-service message conversion method provided in the second embodiment of the present invention. This embodiment adds a specific process of obtaining a target parser based on a target conversion rule on the basis of the above-mentioned first embodiment. Among them, the specific contents of steps S210-S220 are roughly the same as steps S110-S120 in the first embodiment, so they will not be repeated in this embodiment. Figure 4 As shown, the method includes:
[0073] S210: Obtain a message to be converted, and obtain a historical rule base, wherein the historical rule base includes various historical conversion rules.
[0074] S220: Match the message to be converted through a historical rule base, and determine the matching status of the message to be converted, where the matching status includes matching and mismatching.
[0075] Optionally, the message to be converted is matched through a historical rule base, including: determining whether the message to be converted carries a timestamp, if so, obtaining a first hash value of the message to be converted, and matching each historical conversion rule in the historical rule base with the message to be converted based on the first hash value, wherein the first hash value is a hash value of the message attribute; otherwise, obtaining a second hash value of the message to be converted, and matching each historical conversion rule in the historical rule base with the message to be converted based on the second hash value, wherein the second hash value is a hash value of the message itself.
[0076] S230: Determine a target conversion rule for the message to be converted according to the matching situation.
[0077] Optionally, the target conversion rule of the message to be converted is determined according to the matching situation, including: judging whether the matching situation is a match, if so, taking the historical conversion rule that matches the message to be converted as the target conversion rule; otherwise, determining the target conversion rule of the message to be converted according to a preset rule matching model.
[0078] Optionally, a target conversion rule for the message to be converted is determined according to a preset rule matching model, including: performing field parsing on the message to be converted in a specified manner to generate a first set; obtaining each matching sub-rule, and generating a second set according to each matching sub-rule; matching the first set and the second set through the preset rule matching model to generate a matching result, and determining the target conversion rule according to the matching result, wherein the rule matching model includes preset matching conditions.
[0079] Optionally, determining the target conversion rule based on the matching result includes: determining whether the number of matching sub-rules in the matching result is one, and if so, directly using the matching result as the target conversion rule; otherwise, determining the length value of each matching sub-rule in the matching result, and using the matching sub-rule with the longest length value as the target conversion rule.
[0080] S240: Determine the target rule type corresponding to the target conversion rule, and obtain a special rule list, wherein the special rule list includes various preset special rule types.
[0081] S250. Determine whether the target rule type is in the special rule list. If so, execute S260. Otherwise, execute S270.
[0082] S260. Determine a target parser based on a preset dynamic configuration.
[0083] S270. Obtain a target parser according to the target rule type.
[0084] Specifically, the service conversion system will identify the target rule type corresponding to the target conversion rule, and then determine whether the target rule type exists in the special rule list. If so, the target parser is determined based on the pre-set dynamic configuration. If the target rule type is not in the special rule list, the corresponding target parser can be obtained based on the target rule type.
[0085] It can be known that the rule parser can be dynamically configured and expanded, and can parse the corresponding rule data into target rule data according to the message data. Among them, the main reason why the rule parser needs to be dynamically expanded is that when it needs to be parsed into special business data according to the corresponding rule description, it can be dynamically adapted. For example: for rules containing placeholders, the original data needs to replace the placeholders; and for rules containing regular expressions, the relevant character parsing of the rule expression needs to be applied. The rule parser can also perform different operations on the target rule data according to the operation type (operation), such as modification, deletion, addition, etc., to adapt to different business conversion requirements.
[0086] Optionally, obtaining a target parser according to a target rule type includes: obtaining a parser configuration list, wherein the parser configuration list includes a correspondence between each rule type and a parser; matching the target rule type through the parser configuration list to obtain a target parser that matches the target rule type.
[0087] Specifically, the correspondence between various rule types and corresponding parsers is preconfigured in the parser configuration list. The service conversion system can match the target rule type through the parser configuration list to match the target parser corresponding to the target rule type.
[0088] S280 , calling the target parser to perform cross-service conversion on the message to be converted.
[0089] For example, when the target rule data has been parsed, the message data conversion logic can be executed according to the corresponding position and name. For example, the message data: {"person":{"name":"pong"}}, its target is to add data: {"id":"001"}, the position is: "person", the name is: " / ", then it will become: {"person":{"name":"pong","id":"001"}}.
[0090] The technical solution of the embodiment of the present invention matches the message to be converted through the historical rule library, which can accelerate the matching efficiency for scenarios with large data volumes. When no historical rules are matched, matching is performed through the preset rule matching model, which can support message conversion between multiple programming languages, data formats and communication protocols. It can adapt to changes in service interfaces and data formats without modifying the message conversion code, has greater versatility and flexibility, reduces repeated development of conversion logic, and reduces development costs.
[0091] Embodiment 3
[0092] Figure 5 This is a schematic diagram of the structure of a cross-service message conversion device provided by Embodiment 3 of the present invention. Figure 5 As shown, the device includes: a message and rule base acquisition module 310, which is used to acquire a message to be converted and acquire a historical rule base, wherein the historical rule base includes various historical conversion rules;
[0093] The message matching module 320 is used to match the message to be converted through the historical rule base and determine the matching status of the message to be converted, wherein the matching status includes matching and non-matching;
[0094] The conversion rule and parser determination module 330 is used to determine the target conversion rule according to the matching situation, obtain the target parser based on the target conversion rule, and call the target parser to perform cross-service conversion on the message to be converted.
[0095] Optionally, the message matching module 320 is specifically used to: determine whether the message to be converted carries a timestamp, and if so, obtain a first hash value of the message to be converted, and match each historical conversion rule in the historical rule base with the message to be converted based on the first hash value, wherein the first hash value is a hash value of the message attribute; otherwise, obtain a second hash value of the message to be converted, and match each historical conversion rule in the historical rule base with the message to be converted based on the second hash value, wherein the second hash value is the hash value of the message itself.
[0096] Optionally, the conversion rule and parser determination module 330 specifically includes: a target conversion rule determination unit, used to: determine whether the match is a match, if so, use the historical conversion rule that matches the message to be converted as the target conversion rule; otherwise, determine the target conversion rule of the message to be converted according to a preset rule matching model.
[0097] Optionally, the target conversion rule determination unit specifically includes: a first set generation subunit, used to: perform field parsing on the message to be converted in a specified manner to generate a first set; a second set generation subunit, used to: obtain each matching sub-rule, and generate a second set according to each matching sub-rule; a target conversion rule determination subunit, used to: match the first set and the second set through a preset rule matching model to generate a matching result, and determine the target conversion rule according to the matching result, wherein the rule matching model includes preset matching conditions.
[0098] Optionally, the target conversion rule determination subunit is specifically used to: determine whether the number of matching sub-rules in the matching result is one, and if so, directly use the matching result as the target conversion rule; otherwise, determine the length value of each matching sub-rule in the matching result, and use the matching sub-rule with the longest length value as the target conversion rule.
[0099] Optionally, the conversion rule and parser determination module 330 specifically includes: a parser determination unit, used to: determine the target rule type corresponding to the target conversion rule, and obtain a special rule list, wherein the special rule list includes preset special rule types; determine whether the target rule type is in the special rule list, and if so, determine the target parser based on a preset dynamic configuration; otherwise, obtain the target parser according to the target rule type.
[0100] Optionally, the parser determination unit specifically includes: a type matching subunit, used to: obtain a parser configuration list, wherein the parser configuration list includes the correspondence between each rule type and the parser; match the target rule type through the parser configuration list to obtain a target parser that matches the target rule type.
[0101] The technical solution of the embodiment of the present invention matches the message to be converted through the historical rule library, which can accelerate the matching efficiency for scenarios with large data volumes. When no historical rules are matched, matching is performed through the preset rule matching model, which can support message conversion between multiple programming languages, data formats and communication protocols. It can adapt to changes in service interfaces and data formats without modifying the message conversion code, has greater versatility and flexibility, reduces repeated development of conversion logic, and reduces development costs.
[0102] A cross-service message conversion device provided by an embodiment of the present invention can execute a cross-service message conversion method provided by any embodiment of the present invention, and has functional modules and beneficial effects corresponding to the execution method.
[0103] Embodiment 4
[0104] Figure 6 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or required herein.
[0105] like Figure 6 As shown, the electronic device 10 includes at least one processor 11, and a memory connected to the at least one processor 11, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., wherein the memory stores a computer program that can be executed by at least one processor, and the processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 to the random access memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 can also be stored. The processor 11, the ROM 12, and the RAM 13 are connected to each other through a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0106] A number of components in the electronic device 10 are connected to the I / O interface 15, including: an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0107] The processor 11 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as a cross-service message conversion method.
[0108] In some embodiments, a cross-service message conversion method may be implemented as a computer program, which is tangibly contained in a computer-readable storage medium, such as a storage unit 18. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 10 via the ROM 12 and / or the communication unit 19. When the computer program is loaded into the RAM 13 and executed by the processor 11, one or more steps of the cross-service message conversion method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform a cross-service message conversion method in any other appropriate manner (e.g., by means of firmware).
[0109] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0110] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that when the computer program is executed by the processor, the functions / operations specified in the flow chart and / or block diagram are implemented. The computer program may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.
[0111] In the context of the present invention, a computer-readable storage medium may be a tangible medium that may contain or store a computer program for use by or in combination with an instruction execution system, device or equipment. A computer-readable storage medium may include, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, a computer-readable storage medium may be a machine-readable signal medium. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0112] To provide interaction with a user, the systems and techniques described herein may be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and a pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices may also be used to provide interaction with the user; for example, the feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form (including acoustic input, voice input, or tactile input).
[0113] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0114] A computing system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and server relationship is generated by computer programs running on the corresponding computers and having a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, which is a host product in the cloud computing service system to solve the defects of difficult management and weak business scalability in traditional physical hosts and VPS services.
[0115] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps described in the present invention can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solution of the present invention can be achieved, and this document does not limit this.
[0116] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A cross-service message conversion method, applied to a conversion service system, characterized in that: include: Obtaining a message to be converted and obtaining a historical rule base, wherein the historical rule base includes various historical conversion rules; Matching the message to be converted by using the historical rule base, and determining a matching condition of the message to be converted, wherein the matching condition includes a match and a mismatch; Determine a target conversion rule for the message to be converted according to the matching situation, obtain a target parser based on the target conversion rule, and call the target parser to perform cross-service conversion on the message to be converted; The step of determining a target conversion rule for the message to be converted according to the matching situation includes: Determine whether the matching situation is a match, and if so, use the historical conversion rule that matches the message to be converted as the target conversion rule; Otherwise, determining the target conversion rule of the message to be converted according to a preset rule matching model; The determining the target conversion rule of the message to be converted according to the preset rule matching model includes: Performing field parsing on the message to be converted in a specified manner to generate a first set; Obtain each matching sub-rule, and generate a second set according to each matching sub-rule; Matching the first set and the second set by a preset rule matching model to generate a matching result, and determining the target conversion rule according to the matching result, wherein the rule matching model includes a preset matching condition; Determining the target conversion rule according to the matching result includes: Determine whether the number of matching sub-rules in the matching result is one, and if so, directly use the matching result as the target conversion rule; Otherwise, the length value of each matching sub-rule in the matching result is determined, and the matching sub-rule with the longest length value is used as the target conversion rule.
2. The method according to claim 1, characterized in that The matching the message to be converted by using the historical rule base includes: Determine whether the message to be converted carries a timestamp, and if so, obtain a first hash value of the message to be converted, and match each historical conversion rule in the historical rule base with the message to be converted based on the first hash value, wherein the first hash value is a hash value of a message attribute; Otherwise, a second Hash value of the message to be converted is obtained, and each historical conversion rule in the historical rule base is matched with the message to be converted based on the second Hash value, wherein the second Hash value is a Hash value of the message itself.
3. The method according to claim 1, characterized in that The step of obtaining a target parser based on the target conversion rule comprises: Determine the target rule type corresponding to the target conversion rule, and obtain a special rule list, wherein the special rule list includes preset special rule types; Determine whether the target rule type is in the special rule list, and if so, determine the target parser based on a preset dynamic configuration; Otherwise, a target parser is obtained according to the target rule type.
4. The method according to claim 3, characterized in that The step of obtaining a target parser according to the target rule type includes: Obtaining a parser configuration list, wherein the parser configuration list includes a correspondence between each rule type and a parser; The target rule type is matched through the parser configuration list to obtain a target parser that matches the target rule type.
5. A cross-service message conversion device, characterized in that: include: A message and rule base acquisition module, used to acquire a message to be converted and a historical rule base, wherein the historical rule base includes various historical conversion rules; A message matching module, used to match the message to be converted through the historical rule base, and determine the matching status of the message to be converted, wherein the matching status includes matching and non-matching; A conversion rule and parser determination module, used to determine a target conversion rule according to the matching situation, obtain a target parser based on the target conversion rule, and call the target parser to perform cross-service conversion on the message to be converted; The conversion rule and parser determination module specifically includes: a target conversion rule determination unit, which is used to: determine whether the matching situation is a match, and if so, use the historical conversion rule that matches the message to be converted as the target conversion rule; otherwise, determine the target conversion rule of the message to be converted according to a preset rule matching model; The target conversion rule determination unit specifically includes: a first set generation subunit, which is used to: perform field parsing on the message to be converted in a specified manner to generate a first set; a second set generation subunit, which is used to: obtain each matching sub-rule, and generate a second set according to each matching sub-rule; a target conversion rule determination subunit, which is used to: match the first set and the second set through a preset rule matching model to generate a matching result, and determine the target conversion rule according to the matching result, wherein the rule matching model includes a preset matching condition; The target conversion rule determination subunit is specifically used to: determine whether the number of matching sub-rules in the matching result is one, and if so, directly use the matching result as the target conversion rule; otherwise, determine the length value of each matching sub-rule in the matching result, and use the matching sub-rule with the longest length value as the target conversion rule.
6. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively connected to the at least one processor; wherein, The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor so that the at least one processor can perform the method according to any one of claims 1 to 4.
7. A computer storage medium, characterized in that: The computer storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the method according to any one of claims 1 to 4 when executed.
Citation Information
Patent Citations
Database conversion method and device, equipment, medium and program product
CN116756173A
Database access code conversion method and device and electronic equipment
CN117555925A