Message conversion method, device, equipment and storage medium
By acquiring and processing field types and parameters in gateway devices, generating instance resources, and unifying field processing logic, the problem of inconsistent field processing logic in traditional gateways is solved, improving code development efficiency and system stability, and reducing operation and maintenance costs.
Patent Information
- Application Number
- CN202310427583.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-12
- Publication Date
- 2025-12-09
- Estimated Expiration
- 2043-04-12
AI Technical Summary
When traditional gateways handle differences in field data values between different systems, existing technologies suffer from bloated code, high system maintenance costs, and an inability to effectively address inconsistent field processing logic, leading to blurred boundaries between systems, poor runtime robustness, and high maintenance costs in the later stages.
By obtaining the type and field processing parameters of the field to be configured, determining the instantiation rules based on the type, performing instantiation processing, generating instance resources, unifying the injection process of field processing logic, and achieving isolated processing of fields of different types.
It improved code development efficiency, reduced development and maintenance costs, and enhanced system stability and performance.
Smart Images

Figure CN116436989B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of communication, and in particular to a message conversion method and device, an electronic device, and a storage medium. BACKGROUND
[0002] A gateway is a computer system or device that acts as a conversion server, which is used between two systems with different communication protocols, data formats or languages, or even completely different architectures. When systems are interconnected, the gateway generally undertakes the responsibilities of message conversion, security authentication and message forwarding. Among them, the message forwarding is the most core and basic function.
[0003] Traditional gateway message forwarding generally only involves message format conversion and field name conversion. However, with the vigorous development of the Internet, the docking scene is increasingly rich, the data dictionaries of various systems are different, and more and more differentiated conversion of field data values is needed. However, the commonly used gateway in the industry focuses on message format conversion, and the support for field value processing is very weak. Most of them need to be developed invasively at the business code level, and the conversion logic is constantly added to the original business code, and code development may exist in the gateway system and the business layer system, resulting in bloated code, blurred boundaries between systems, poor runtime robustness, and high maintenance cost. SUMMARY
[0004] The present application provides at least a message conversion method, a message conversion device, an electronic device, and a computer readable storage medium.
[0005] The first aspect of the present application provides a message conversion method, comprising: obtaining a type to which a to-be-configured field belongs and a field processing parameter corresponding to the to-be-configured field; determining an instantiation rule corresponding to the to-be-configured field based on the type to which the to-be-configured field belongs; performing instantiation processing on the field processing parameter corresponding to the to-be-configured field based on the instantiation rule, to obtain an instance resource corresponding to each to-be-configured field; and performing message conversion on a network message to be converted based on the instance resource corresponding to each to-be-configured field.
[0006] In an embodiment, obtaining the type to which the to-be-configured field belongs and the field processing parameter corresponding to the to-be-configured field comprises: obtaining the field processing parameter corresponding to the to-be-configured field in response to a field processing parameter input operation in a configuration data input interface; performing complexity calculation on the field processing parameter to obtain a processing complexity corresponding to the to-be-configured field; and determining the type to which the to-be-configured field belongs based on the processing complexity.
[0007] In an embodiment, the field processing parameter is composed of one or more processing steps; the complexity calculation is performed on the field processing parameter to obtain the processing complexity corresponding to the to-be-configured field, including: extracting the processing steps contained in the field processing parameter, and obtaining the type and step content of each processing step; obtaining the complexity weight corresponding to the type of each processing step, and obtaining the step complexity of each processing step based on the step content; performing weighted calculation on the step complexity of each processing step based on the complexity weight corresponding to the type of each processing step to obtain the processing complexity corresponding to the to-be-configured field.
[0008] In an embodiment, the field processing parameter is composed of one or more processing steps; the instantiation rule corresponding to the to-be-configured field is determined based on the type to which the to-be-configured field belongs, including: obtaining a code template matching the type to which the to-be-configured field belongs from a preset code template set to obtain a candidate code template corresponding to the field processing parameter, and extracting the step type of each processing step in the field processing parameter; obtaining a code template matching the step type of each processing step from the candidate code template to obtain a target code template corresponding to each processing step; and combining the target code templates corresponding to each processing step to obtain the instantiation rule corresponding to the to-be-configured field.
[0009] In an embodiment, the field processing parameter corresponding to the to-be-configured field is instantiated based on the instantiation rule to obtain the instance resource corresponding to each to-be-configured field, including: obtaining an instance code template based on the instantiation rule; filling the field processing parameter corresponding to the to-be-configured field into the instance code template to obtain an instance code; and obtaining the instance resource corresponding to the to-be-configured field based on the instance code.
[0010] In an embodiment, the network message is sent by the first communication device to the second communication device; the network message to be converted is converted based on the instance resource, including: extracting the to-be-converted field in the network message; performing mapping processing on the field name of the to-be-converted field based on a preset field mapping table to obtain a target field name; wherein the field mapping table is used to store the mapping relationship between the field name corresponding to the first communication device and the field name corresponding to the second communication device; obtaining the instance resource matching the target field name from the instance resource corresponding to each to-be-configured field to obtain a target instance resource; and converting the network message to be converted based on the target instance resource.
[0011] In an embodiment, the network message to be converted is converted based on the target instance resource, including: calculating the target field value corresponding to the target field name based on the target instance resource; replacing the field name of the to-be-converted field based on the target field name, and replacing the field value corresponding to the to-be-converted field based on the target field value to obtain a replaced target field; and obtaining the converted network message based on the target field.
[0012] The second aspect of the present application provides a message conversion device, comprising: an acquisition module configured to acquire a type to which a to-be-configured field belongs and field processing parameters corresponding to the to-be-configured field; a rule determination module configured to determine an instantiation rule corresponding to the to-be-configured field based on the type to which the to-be-configured field belongs; an instantiation module configured to perform instantiation processing on the field processing parameters corresponding to the to-be-configured field based on the instantiation rule to obtain an instance resource corresponding to each to-be-configured field; and a conversion module configured to perform message conversion on a to-be-converted network message based on the instance resource corresponding to each to-be-configured field.
[0013] The third aspect of the present application provides an electronic device comprising a memory and a processor, wherein the processor is configured to execute program instructions stored in the memory to implement the message conversion method described above.
[0014] The fourth aspect of the present application provides a computer-readable storage medium having program instructions stored thereon, wherein the program instructions are executed by a processor to implement the message conversion method described above.
[0015] The above scheme unifies the injection process of the field processing logic, standardizes the injection of the field processing logic, isolates the processing logic between the system interfaces and the fields from each other, and uses different instantiation methods for different types of fields, thereby greatly improving the code development efficiency and reducing the development and operation costs.
[0016] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, but not limiting the present application. BRIEF DESCRIPTION OF DRAWINGS
[0017] The accompanying drawings, which are incorporated into and form part of the specification, illustrate embodiments consistent with the present application and, together with the specification, serve to explain the technical solutions of the present application.
[0018] Figure 1 is a network architecture diagram of an exemplary embodiment of the message conversion method of the present application;
[0019] Figure 2 is a flowchart of an exemplary embodiment of the message conversion method of the present application;
[0020] Figure 3 is a schematic diagram of acquiring a type to which a to-be-configured field belongs and field processing parameters corresponding to the to-be-configured field in the message conversion method of the present application;
[0021] Figure 4 is a schematic diagram of acquiring an instantiation rule in the message conversion method of the present application;
[0022] Figure 5 is a schematic diagram of acquiring an instance resource in the message conversion method of the present application;
[0023] Figure 6 is a schematic diagram of message conversion in the message conversion method of the present application;
[0024] Figure 7 is a block diagram of a message conversion device according to an example embodiment of the present application;
[0025] Figure 8 is a structural schematic diagram of an electronic device according to an embodiment of the present application;
[0026] Figure 9 is a structural schematic diagram of a computer readable storage medium according to an embodiment of the present application. DETAILED DESCRIPTION
[0027] The scheme of the embodiments of the present application will be described in detail below with reference to the accompanying drawings.
[0028] In the following description, specific details are set forth in order to provide a thorough understanding of the present application. The present application can be practiced without resorting to the details specifically set forth.
[0029] The term "and / or" herein is merely an associated relationship between associated objects, which means that there can be three relationships, for example, A and / or B can represent three cases: A exists alone, A and B exist together, and B exists alone. In addition, the character " / " herein generally represents an "or" relationship between the front and rear associated objects. In addition, "multiple" herein means two or more than two. In addition, the term "at least one" herein means any one of multiple or any combination of at least two of multiple, for example, including at least one of A, B and C can mean including any one or more elements selected from the set consisting of A, B and C.
[0030] The message conversion method provided by the embodiment can be applied to a gateway device or other server device. If applied to a gateway device, the network architecture of the message conversion method provided by the embodiment is as shown in Figure 1 , which includes at least one first communication device 100, a second communication device 200 and a gateway device 300. The first communication device 100 and the second communication device 200 communicate through the gateway device 300.
[0031] Among them, the message conversion method provided by the embodiment is deployed in the gateway device, and is integrated with the function of the gateway device itself. When it is necessary to inject the field processing logic, the gateway device can be requested to add the field processing logic, that is, the field processing logic is added according to the obtained field processing parameter corresponding to the to-be-configured field, the instantiation rule is determined through the type to which the to-be-configured field belongs, and the field processing parameter corresponding to the to-be-configured field is instantiated based on the instantiation rule. After the instantiation processing, the instance resource obtained by the instantiation processing is used to perform message conversion on the network message to be converted received by the gateway device, so as to unify the injection process of the field processing logic, improve the code development efficiency, and reduce the development and operation cost.
[0032] The first communication device 100 and the second communication device 200 can be terminal devices or servers. The terminal device can be a mobile phone, a computer, a smart voice interaction device, a smart home appliance, a vehicle-mounted terminal, an aircraft, etc., but is not limited thereto. The server can be a physical server, a server cluster or a distributed system composed of multiple physical servers, a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content distribution networks (CDN), and big data and artificial intelligence platforms, etc. basic cloud computing services.
[0033] Please refer to Figure 2 , Figure 2 is a flowchart of a message conversion method according to an example embodiment of the present application. The message conversion method can be applied to Figure 1 the implementation environment shown in the figure and is specifically executed by the gateway device in the implementation environment. It should be understood that the method can also be applied to other example implementation environments and specifically executed by devices in other implementation environments, and the embodiment does not limit the implementation environment to which the method is applied.
[0034] The message conversion method proposed by the embodiment of the present application will be described in detail below with the gateway device as a specific execution subject.
[0035] As shown in Figure 2 , in an example embodiment, the message conversion method includes at least steps S210 to S240, which are described in detail as follows:
[0036] Step S210: Obtain the type to which the to-be-configured field belongs and the field processing parameter corresponding to the to-be-configured field.
[0037] The type of the to-be-configured field is obtained by classifying the to-be-configured field, and the field processing parameter corresponding to the to-be-configured field is logical data required for obtaining a field value of the to-be-configured field in a packet conversion process, such as steps required for obtaining the field value and specific execution content of each step. Among them, the fields can be classified according to the complexity of the field value obtaining logic corresponding to the fields, so that subsequent appropriate data injection methods can be selected according to field value obtaining logics of different complexities.
[0038] Exemplarily, please refer to Figure 3 , Figure 3 The schematic diagram provided by an exemplary embodiment of the present application for obtaining the type to which the to-be-configured field belongs and the field processing parameter corresponding to the to-be-configured field is shown. As shown in Figure 3 , the terminal A is a management terminal corresponding to the first network system, the gateway device provides the terminal A with an injection interface of the type to which the to-be-configured field belongs and the field processing parameter corresponding to the to-be-configured field, the terminal A initiates a field configuration request to the gateway device by calling the injection interface, and the gateway device displays a configuration data input interface to the terminal A according to the received field configuration request. The configuration data input interface contains configurable fields, wherein the configurable fields are fields that can be contained in a network packet received by the first system.
[0039] By responding to the field selection operation in the configuration data input interface, the selected field is taken as the to-be-configured field, as Figure 3 in which the to-be-configured field includes field a and field b. Then, the configuration data input interface displays the selectable field types corresponding to the to-be-configured field, and responds to the type selection operation in the configuration data input interface to determine the type to which the to-be-configured field belongs. For example, the selectable field types corresponding to field a include type 1, type 2 and type 3, and if the type selection operation corresponding to field a indicates that the selected type is type 1, then the type to which field a belongs is type 1. Among them, the selectable field types corresponding to each field can be the same or different. For example, field b cannot be instantiated using the instantiation rule corresponding to type 3, so the selectable field types corresponding to field b include type 1 and type 2, so as to avoid wasting subsequent processes due to type marking errors.
[0040] Then, the field processing parameter corresponding to the to-be-configured field is obtained in response to the field processing parameter input operation in the configuration data input interface, and the type to which the to-be-configured field belongs and the field processing parameter corresponding to the to-be-configured field are obtained in response to the submission operation in the configuration data input interface.
[0041] In some embodiments, on the basis of the above embodiments, the terminal A can provide only the field processing parameter corresponding to the to-be-configured field to the gateway device, and the gateway device can automatically assign a type to which the to-be-configured field belongs based on attribute information of the to-be-configured field (such as a security level corresponding to the field, a network message type corresponding to the field, etc.), attribute information of the field processing parameter (such as a parameter quantity of the field processing parameter, a calculation amount contained in the field processing parameter, etc.), and the like, to simplify the process of field processing configuration on the terminal side and improve development efficiency.
[0042] It can be understood that other ways can also be used to obtain the type to which the to-be-configured field belongs and the field processing parameter corresponding to the to-be-configured field, which are not limited in the present application.
[0043] Step S220: determining the instantiation rule corresponding to the to-be-configured field based on the type to which the to-be-configured field belongs.
[0044] The instantiation rule refers to a related rule parameter required in the process of instantiating the field processing parameter corresponding to the to-be-configured field.
[0045] It can be understood that the logic of obtaining the field value is different for different types of fields, that is, the complexity of the field processing parameter corresponding to different types of fields is different, and thus the instantiation manner of the field processing parameter of different complexity is different.
[0046] Exemplarily, a plurality of code templates are pre-stored in the gateway device, and a required code template can be extracted from the pre-stored plurality of code templates according to the type to which the to-be-configured field belongs, and then the instantiation rule corresponding to the to-be-configured field is obtained based on the required code template.
[0047] For example, the code template required to be used is determined according to the field processing parameter corresponding to the to-be-configured field, and the code generation tool generates the framework code of the field value acquisition instance corresponding to the to-be-configured field according to the code template required to be used and the field processing parameter, and uses the framework code as the instantiation rule, so as to facilitate subsequent instantiation processing according to the field processing parameter corresponding to the to-be-configured field and the instantiation rule, and obtain the instance resource corresponding to each to-be-configured field, which can not only improve the development efficiency, but also help to enhance the stability and performance of the developed service.
[0048] Please refer to Figure 4 , Figure 4 Exemplarily, a schematic diagram of obtaining the instantiation rule through the code generation tool is shown.
[0049] As Figure 4As shown, the field processing parameter corresponding to the to-be-configured field contains one or more processing steps, first, each processing step is read in turn, then the currently read processing step is matched with each code template, and the code template that matches successfully is added to the framework code, wherein the matching success means that the corresponding code template meets the functional requirement of the currently read processing step. For example, each code template is marked with a template label, such as template 1 marked as an assignment step, template 2 marked as a database query step, and template 3 marked as a formula 1 calculation step. By analyzing the functional requirement of the currently read processing step "assign a fixed value θ to field a", it is obtained that the code template matched with the currently read processing step is template 1.
[0050] The determination of the code template for each processing step in the field processing parameter is then combined with the code template of each processing step to obtain the framework code, and then the framework code is used as the instantiation rule. Note that, Figure 4 The order of the determination of the code template between each processing step in the above embodiment can be executed in an order different from that shown.
[0051] Step S230: Based on the instantiation rule, the field processing parameter corresponding to the to-be-configured field is instantiated to obtain the instance resource corresponding to each to-be-configured field.
[0052] The instantiation processing means that the field processing parameter corresponding to the to-be-configured field is converted into a code file, and these converted code files are used as the instance resource corresponding to each to-be-configured field, and the subsequent field value obtaining step corresponding to the instance resource can be directly called.
[0053] For example, based on the instantiation rule, an instance code template is obtained; the field processing parameter corresponding to the to-be-configured field is filled into the instance code template to obtain an instance code; and based on the instance code, the instance resource corresponding to the to-be-configured field is obtained.
[0054] For example, the field processing parameter of field a contains "assign a fixed value θ to field a", the parameter extraction of the field processing parameter of field a obtains the field name parameter of the assignment as "field a" and the value parameter of the assignment as "θ", the code template corresponding to "assign a fixed value θ to field a" in the framework code corresponding to field a is template 1, and template 1 contains a field name parameter filling position and a value parameter filling position. "Field a" is filled into the field name parameter filling position of template 1 in the framework code, and "θ" is filled into the value parameter filling position of template 1 in the framework code.
[0055] After the parameter filling of the framework code is completed, a code file is obtained, and the code file is taken as the instance resource corresponding to the to-be-configured field.
[0056] The instantiation process of the field processing parameter is actually an object creation process. In some embodiments, the instantiation process of the field processing parameter can be based on the Spring technology. The Spring is a lightweight Java development framework that uses basic JavaBeans to create objects. It should be understood that although Java is used as the programming language in the above examples, various methods proposed in the present application can also be implemented in various programming languages such as C, C++, PHP (Hypertext Preprocessor), Python, and the like, and the present application does not limit this.
[0057] Exemplarily, refer to Figure 5 , Figure 5 The schematic diagram for obtaining an instance resource is provided for an example embodiment of the present application. As shown in Figure 5 , the type to which the field belongs and the field processing parameter corresponding to the field are taken as the field configuration data of the field. The value processing resource library stores the field configuration data corresponding to each field. The terminal can upload the field configuration data corresponding to the to-be-configured field to the value processing resource library. The terminal can also delete or modify the field configuration data stored in the value processing resource library. The value processing resource library can be set independently of the gateway device or integrated with the gateway device, and the present application does not limit this. The gateway device is provided with a change listener and an instance resource manager. The instance resource manager stores and manages the instance resources of each field. The change listener is used to monitor the data in the value processing resource library. If the change listener detects a change in the field configuration data in the value processing resource library, a corresponding change event is triggered to enable the instance resource manager to execute the change event.
[0058] Taking the uploading of the field configuration data corresponding to the to-be-configured field by the terminal to the value processing resource library as an example, for example, the value processing resource library stores the field configuration data of field a uploaded by the terminal. The change listener detects that there is an increase in the field configuration data in the value processing resource library, and a data increase event is triggered. The instance resource manager obtains the field configuration data of field a, performs instantiation processing based on the field configuration data of field a, obtains the instance resource of field a, and adds the instance resource of field a to the instance resource manager.
[0059] Taking deleting the field configuration data stored in the terminal pair value processing repository as an example, for example, the terminal pair value processing repository deletes the field configuration data of field b, the change listener detects that the field configuration data is deleted in the value processing repository, and then the data deletion event is triggered. The instance resource manager obtains the field name of field b, and deletes the instance resource of field b from the instance resource manager.
[0060] Taking modifying the field configuration data stored in the terminal pair value processing repository as an example, for example, the terminal pair value processing repository modifies the field configuration data of field c, the change listener detects that the field configuration data is modified in the value processing repository, and then the data modification event is triggered. The instance resource manager obtains the modified field configuration data of field c, and performs instantiation processing based on the modified field configuration data to obtain new instance resources of field c, and replaces the original instance resources of field c in the instance resource manager with the new instance resources.
[0061] Step S240: performing packet conversion on the network packet to be converted based on the instance resources corresponding to each field to be configured.
[0062] In actual application, after the gateway device receives the network packet to be converted, the instance resources of the fields to be converted are called to obtain the field values of these fields, so as to complete the packet conversion of the network packet to be converted.
[0063] By unifying the injection process of the field processing logic, the standardization of the field processing logic injection is achieved, the processing logic between each system interface and field is isolated from each other, different instantiation methods are adopted for different types of fields, the code development efficiency is greatly improved, and the development and operation cost is reduced.
[0064] On the basis of the above embodiment, the type to which the field to be configured belongs and the field processing parameter corresponding to the field to be configured are obtained, including: in response to a field processing parameter input operation in the configuration data input interface, obtaining the field processing parameter corresponding to the field to be configured; performing complexity calculation on the field processing parameter to obtain the processing complexity corresponding to the field to be configured; and determining the type to which the field to be configured belongs based on the processing complexity.
[0065] The processing complexity refers to the implementation difficulty of obtaining the field value of the field based on the field processing parameter. The lower the processing complexity, the lower the implementation difficulty of obtaining the field value of the field based on the field processing parameter. The higher the processing complexity, the higher the implementation difficulty of obtaining the field value of the field based on the field processing parameter.
[0066] The processing complexity corresponding to the to-be-configured field can be determined by the parameter type, the parameter quantity, and the calculation amount corresponding to the parameter in the field processing parameter. The specific implementation of the complexity calculation on the field processing parameter can be flexibly selected according to actual application conditions, and the present application does not limit this.
[0067] For example, the field processing parameter is composed of one or more processing steps; the complexity calculation on the field processing parameter obtains the processing complexity corresponding to the to-be-configured field, including: extracting the processing steps contained in the field processing parameter, and obtaining the type and step content of each processing step; obtaining the complexity weight corresponding to the type of each processing step, and obtaining the step complexity of each processing step based on the step content; and performing weighted calculation on the step complexity of each processing step based on the complexity weight corresponding to the type of each processing step to obtain the processing complexity corresponding to the to-be-configured field.
[0068] The type of each processing step can be key information extraction on the step content of the processing step, and then matching the extracted key information with a pre-set step type, and taking the step type with the highest matching degree as the type of the processing step. For example, the processing step is "assign a fixed value θ to field a", the key information obtained by key information extraction on the processing step is "assignment", the step type with the highest matching degree obtained by matching the key information with each pre-set step type is "assignment", and the type of the processing step is "assignment". Then, the complexity weight corresponding to the type of the processing step is obtained, which can be pre-set for each type of step.
[0069] Further, the step complexity of each processing step is obtained based on the step content, such as the calculation amount required to execute the step according to the step content, and the step complexity is obtained by the calculation amount. The larger the calculation amount is, the higher the step complexity is. For example, the step content "perform 10 times of loop calculation on data 1 using formula 1" contains 10 times of calculation process, and the step content "perform 50 times of loop calculation on data 1 using formula 1" contains 50 times of calculation process, so the calculation amount of the latter is obviously larger than that of the former.
[0070] Then, the step complexity of each processing step is weighted calculated based on the complexity weight corresponding to the type of each processing step to obtain the processing complexity corresponding to the to-be-configured field.
[0071] The processing complexity corresponding to the to-be-configured field is calculated by the complexity weight corresponding to the type of each processing step, which improves the accuracy of the calculated processing complexity and facilitates subsequent field classification.
[0072] The type to which the to-be-configured field belongs is determined based on the processing complexity, for example, processing steps with a processing complexity in a range of 0 to 0.3 are classified as configuration type fields, processing steps with a processing complexity in a range of 0.3 to 0.7 are classified as lightweight type fields, and processing steps with a processing complexity in a range of 0.7 to 1 are classified as heavy type fields, so as to obtain the type to which the to-be-configured field belongs and the corresponding field processing parameter of the to-be-configured field.
[0073] The complexity of the to-be-configured field is calculated based on the corresponding field processing parameter, and the to-be-configured field is automatically assigned a field type according to the calculated processing complexity of the to-be-configured field, which reduces the workload of the developer and avoids the situation that the field type is incorrectly determined by human judgment, thereby improving the development efficiency.
[0074] Based on the above embodiment, the field processing parameter is composed of one or more processing steps, and the step of obtaining the instantiation rule corresponding to the to-be-configured field based on the type to which the to-be-configured field belongs can include the following steps: obtaining a code template matching the type to which the to-be-configured field belongs from a code template set to obtain a candidate code template corresponding to the field processing parameter, and extracting the step type of each processing step in the field processing parameter; obtaining a code template matching the step type of each processing step from the candidate code template to obtain a target code template corresponding to each processing step; and combining the target code templates corresponding to each processing step to obtain the instantiation rule corresponding to the to-be-configured field.
[0075] The code template can be pre-stored in the gateway device.
[0076] The following three types of the type to which the to-be-configured field belongs are taken as examples to describe the process of obtaining the instantiation rule.
[0077] (1) Configuration type field: There is no calculation step and business logic processing step, and the field value can be obtained by simple parameter configuration, for example, a fixed value θ is assigned to field a.
[0078] The following is an example of obtaining the instantiation rule of the configuration type field.
[0079] Field a belongs to the configuration type field, and the field processing parameter corresponding to field a is "assign a fixed value θ to field a".
[0080] The code templates that can be used for the configuration type field include template 1 and template 2, the field processing parameter corresponding to field a is analyzed, it is found that the field value obtaining step contained in the field processing parameter belongs to the assignment step, and then the code template that can be used for assignment is selected from template 1 and template 2 as template 1, so template 1 is taken as the instantiation rule corresponding to field a.
[0081] Exemplarily, the field processing parameter corresponding to the configuration type field can be a configuration file.
[0082] (2) Lightweight field; there is a simple calculation step, for example, the original value of field b is calculated by using a specified calculation formula to realize the acquisition of the field value.
[0083] Next, an example of obtaining the instantiation rule of the lightweight field is introduced as follows:
[0084] Field b belongs to a lightweight field, and the field processing parameter corresponding to field b is "obtain the original value of field b from the network message to be converted, calculate the intermediate value by using formula 1, and calculate the final field value by using formula 2".
[0085] The code templates that can be used to query the lightweight field contain template 3, template 4 and template 5. By analyzing the field processing parameter corresponding to field b, it is obtained that the field value acquisition step in the field processing parameter includes formula 1 calculation step and formula 2 calculation step. Therefore, the code template that can be used for formula 1 calculation is template 3, and the code template that can be used for formula 2 calculation is template 5. Therefore, template 3 and template 5 are both used as the instantiation rule corresponding to the field b.
[0086] Exemplarily, the field processing parameter corresponding to the lightweight field can be an expression file.
[0087] (3) Heavy field; there is a complex calculation step or business logic processing step, for example, field c needs to query a third-party data source (such as cache, data file or third-party system) and then judge and process to realize the acquisition of the field value.
[0088] Next, an example of obtaining the instantiation rule of the heavy field is introduced as follows:
[0089] Field c belongs to a heavy field, and the field processing parameter corresponding to field c is "query the value of a specified data item from table 1 of the database, and if the value of the specified data item is greater than 0, calculate the final field value of field c by using formula 3 and the value of the specified data item".
[0090] The code template that can be used for querying the weight type field contains template 6, template 7 and template 8, the field processing parameters corresponding to the field c are analyzed, it is obtained that the field value obtaining step in the field processing parameters includes a database table 1 query step and a formula 3 calculation step, then the code template that can be used for database table 1 query is selected from template 6, template 7 and template 8 as template 7, the code template that can be used for formula 3 calculation is selected as template 8, therefore, template 7 and template 8 are both used as the instantiation rule corresponding to the field c.
[0091] Exemplarily, the field processing parameters corresponding to the weight type field can be a code file, such as a JAR (Java Archive File) package.
[0092] It can be understood that the specific division of the type to which the to-be-configured field belongs can be set according to different application scenarios, and the embodiments of the present application do not limit this.
[0093] By determining the code template corresponding to the to-be-configured field according to the type to which the to-be-configured field belongs, code generation is achieved, development cost is reduced, development efficiency is improved, the development process is unified, and subsequent development and operation are facilitated.
[0094] On the basis of the above-mentioned embodiments, the network message is sent by the first communication device to the second communication device; the network message to be converted is converted based on the instance resource, including: extracting the to-be-converted field in the network message to be converted; mapping the field name of the to-be-converted field based on the preset field mapping table to obtain the target field name; wherein the field mapping table is used to store the mapping relationship between the field name corresponding to the first communication device and the field name corresponding to the second communication device; obtaining the target instance resource from the instance resource corresponding to each to-be-configured field that matches the target field name; and converting the network message to be converted based on the target instance resource.
[0095] The to-be-converted field in the network message to be converted is a field required by the second communication device, which can be a field required by the second communication device stored in the gateway device, and the to-be-converted field is obtained by selecting the field in the network message to be converted through these fields. Wherein the first communication device and the second communication device are respectively in different networks.
[0096] The field mapping table is used to store the mapping relationship between the field name corresponding to the first communication device and the field name corresponding to the second communication device, for example, the field name of the field a contained in the network message generated by the first communication device is "a1", and the field mapping table stores that the field name "a1" of the field a of the first communication device needs to be mapped to the field name "a2".
[0097] The field name of each field to be converted is mapped by a preset field mapping table to obtain a target field name of each field to be converted.
[0098] Then, an instance resource matching the target field name is obtained from the instance resource corresponding to each field to be configured to obtain a target instance resource, and the target instance resource is called to perform packet conversion.
[0099] For example, packet conversion is performed on the network packet to be converted based on the target instance resource, including: calculating a target field value corresponding to the target field name based on the target instance resource; replacing the field name of the field to be converted based on the target field name, and replacing the field value corresponding to the field to be converted based on the target field value to obtain a replaced target field; and obtaining a converted network packet based on the target field.
[0100] The target field value refers to an actual value of the field to be converted in the converted network packet.
[0101] The field value of the field to be converted is calculated based on the preset target instance resource, and then the target field value of the field to be converted is obtained. The field name of the field to be converted is replaced based on the target field name, and the field value corresponding to the field to be converted is replaced based on the target field value to obtain a replaced target field. The above processing is performed on each field to be converted to obtain a converted network packet, so as to realize the conversion process of the network packet.
[0102] In some embodiments, after packet conversion is performed on the network packet to be converted based on the target instance resource, the method further includes: obtaining a communication address corresponding to the second communication device; and sending the converted network packet to the second communication device based on the communication address. For example, the gateway device queries a communication address of the second communication device from a domain name server (DNS), and then sends the converted network packet to the second communication device according to the queried communication address, so as to realize the forwarding of the network packet between different networks.
[0103] For example, please refer to Figure 6 , Figure 6 The schematic diagram of packet conversion shown in the embodiment of the present application is as follows Figure 6As shown, the first communication device terminal A in the first network system sends a request message to the second communication device terminal B in the second network system, the gateway device between the first network system and the second network system receives the request message, performs message format conversion processing and field conversion processing on the request message, the field conversion processing includes field name lookup to obtain a target field name recognizable by terminal B, then performs instance resource acquisition according to the target field name to obtain a target instance resource, and then performs target field value acquisition on the target instance resource to obtain a target field value, and performs new value re-injection processing on the target field value to replace the original field value corresponding to the field to be converted according to the target field value. After the message format conversion processing and the field conversion processing are performed on the request message, a converted network message is obtained, and the gateway device forwards the converted network message to terminal B.
[0104] The message conversion method provided in the application obtains the type to which the to-be-configured field belongs and the field processing parameter corresponding to the to-be-configured field, obtains the instantiation rule corresponding to the to-be-configured field based on the type to which the to-be-configured field belongs, performs instantiation processing on the field processing parameter corresponding to the to-be-configured field based on the instantiation rule, obtains the instance resource corresponding to each to-be-configured field, and then performs message conversion on the network message to be converted based on the instance resource corresponding to each to-be-configured field. The injection process of the field processing logic is unified, the standardization of the field processing logic injection is achieved, the processing logic between each system interface and field is isolated from each other, different instantiation methods are adopted for different types of fields, the code development efficiency is greatly improved, and the development and operation cost is reduced.
[0105] Figure 7 is a block diagram of a message conversion device according to an example embodiment of the application. As shown, the example message conversion device 700 includes an acquisition module 710, a rule determination module 720, an instantiation module 730, and a conversion module 740. Specifically: Figure 7 The acquisition module 710 is configured to acquire the type to which the to-be-configured field belongs and the field processing parameter corresponding to the to-be-configured field.
[0106] The rule determination module 720 is configured to obtain the instantiation rule corresponding to the to-be-configured field based on the type to which the to-be-configured field belongs.
[0107] The instantiation module 730 is configured to perform instantiation processing on the field processing parameter corresponding to the to-be-configured field based on the instantiation rule to obtain the instance resource corresponding to each to-be-configured field.
[0108] The conversion module 740 is configured to perform message conversion on the network message to be converted based on the instance resource corresponding to each to-be-configured field.
[0109]
[0110] In the exemplary message conversion device, the injection process of the unified field processing logic achieves the standardization of the injection of the field processing logic, so that the processing logic between various system interfaces and fields is isolated from each other, and different instantiation methods are used for different types of fields, which greatly improves the code development efficiency and reduces the development and operation cost.
[0111] The functions of the modules can be understood from the message conversion method embodiments, which will not be described here.
[0112] Please refer to Figure 8 , Figure 8 is a structural schematic diagram of an embodiment of the electronic device. The electronic device 800 includes a memory 801 and a processor 802. The processor 802 is configured to execute program instructions stored in the memory 801 to implement the steps in any of the above message conversion method embodiments. In a specific implementation scenario, the electronic device 800 can include but is not limited to a microcomputer, a server, and in addition, the electronic device 800 can also include a notebook computer, a tablet computer, and the like, without limitation.
[0113] Specifically, the processor 802 is configured to control itself and the memory 801 to implement the steps in any of the above message conversion method embodiments. The processor 802 can also be referred to as a CPU (Central Processing Unit, central processing unit). The processor 802 can be an integrated circuit chip with signal processing capability. The processor 802 can also be a general-purpose processor, a digital signal processor (Digital Signal Processor, DSP), an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), a field programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware component. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. In addition, the processor 802 can be implemented by an integrated circuit chip together.
[0114] The above scheme, by unifying the injection process of the field processing logic, achieves the standardization of the injection of the field processing logic, so that the processing logic between various system interfaces and fields is isolated from each other, and different instantiation methods are used for different types of fields, which greatly improves the code development efficiency and reduces the development and operation cost.
[0115] Please refer to Figure 9 , Figure 9FIG. 9 is a structural schematic diagram of an embodiment of the computer readable storage medium of the present application. The computer readable storage medium 900 stores program instructions 910 capable of being executed by a processor, the program instructions 910 being used to implement the steps in any of the packet conversion method embodiments described above.
[0116] The above scheme, by obtaining the type to which the to-be-configured field belongs and the field processing parameter corresponding to the to-be-configured field, obtaining the instantiation rule corresponding to the to-be-configured field based on the type to which the to-be-configured field belongs, and performing instantiation processing on the field processing parameter corresponding to the to-be-configured field based on the instantiation rule to obtain the instance resource corresponding to each to-be-configured field, the packet conversion of the to-be-converted network packet is performed based on the instance resource corresponding to each to-be-configured field, which can unify the injection process of the field processing logic, achieve the standardization of the injection of the field processing logic, improve the code development efficiency, and reduce the development and operation cost.
[0117] In some embodiments, the apparatus provided by the embodiments of the present disclosure has functions or includes modules that can be used to execute the methods described in the above method embodiments, and the specific implementation can refer to the description of the above method embodiments. For brevity, details are not repeated here.
[0118] The above description of each embodiment tends to emphasize the differences between the embodiments, and the same or similar parts can be mutually referred to. For brevity, details are not repeated here.
[0119] In several embodiments provided in the present application, it should be understood that the disclosed method and device can be implemented by other means. For example, the above-described device implementation is only schematic, for example, the division of modules or units is only a logical function division, and actual implementation can have another division manner, for example, a unit or component can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the displayed or discussed each other can be indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.
[0120] In addition, each of the function units in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software function unit. When the integrated unit is realized in the form of a software function unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application, essentially or in the form of a contribution to the prior art, or all or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes several instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor execute all or part of the steps of the methods in each embodiment of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes.
Claims
1. A message conversion method characterized by, The method comprises: In response to a field processing parameter input operation in a configuration data input interface, obtaining a field processing parameter corresponding to a to-be-configured field, performing complexity calculation on the field processing parameter to obtain processing complexity corresponding to the to-be-configured field, and determining a type to which the to-be-configured field belongs based on the processing complexity; Obtaining a code template matching the type to which the to-be-configured field belongs from a preset code template set, obtaining a candidate code template corresponding to the field processing parameter, and extracting a step type of each processing step in the field processing parameter; Obtaining a code template matching the step type of each processing step from the candidate code template, and obtaining a target code template corresponding to each processing step; Combining the target code templates corresponding to each processing step to obtain an instantiation rule corresponding to the to-be-configured field; Performing instantiation processing on the field processing parameter corresponding to the to-be-configured field based on the instantiation rule to obtain an instance resource corresponding to each to-be-configured field; Performing packet conversion on a to-be-converted network packet based on the instance resource corresponding to each to-be-configured field.
2. The method of claim 1, wherein, The field processing parameter is composed of one or more processing steps; the complexity calculation on the field processing parameter to obtain the processing complexity corresponding to the to-be-configured field comprises: Extracting the processing steps contained in the field processing parameter, and obtaining the type and step content of each processing step; Respectively obtaining a complexity weight corresponding to the type of each processing step, and obtaining a step complexity of each processing step based on the step content; Performing weighted calculation on the step complexity of each processing step based on the complexity weight corresponding to the type of each processing step to obtain the processing complexity corresponding to the to-be-configured field.
3. The method of claim 1, wherein, The instantiation processing on the field processing parameter corresponding to the to-be-configured field based on the instantiation rule to obtain an instance resource corresponding to each to-be-configured field comprises: Obtaining an instance code template based on the instantiation rule; Filling the field processing parameter corresponding to the to-be-configured field into the instance code template to obtain an instance code; Obtaining the instance resource corresponding to the to-be-configured field based on the instance code.
4. The method according to any one of claims 1 to 3, characterized in that, The network packet is sent by a first communication device to a second communication device; the packet conversion on the to-be-converted network packet based on the instance resource comprises: Extracting a to-be-converted field in the to-be-converted network packet; Performing mapping processing on a field name of the to-be-converted field based on a preset field mapping table to obtain a target field name; wherein the field mapping table is used to store a mapping relationship between a field name corresponding to the first communication device and a field name corresponding to the second communication device; Obtaining an instance resource matching the target field name from the instance resource corresponding to each to-be-configured field to obtain a target instance resource; Performing packet conversion on the to-be-converted network packet based on the target instance resource.
5. The method of claim 4, wherein, The packet conversion on the to-be-converted network packet based on the target instance resource comprises: calculating a target field value corresponding to the target field name based on the target instance resource; replacing a field name of the field to be converted based on the target field name, and replacing a field value corresponding to the field to be converted based on the target field value, to obtain a replaced target field; obtaining a converted network packet based on the target field.
6. A message conversion device, characterized by The method comprises the following steps: obtaining a field processing parameter corresponding to a field to be configured in response to a field processing parameter input operation in a configuration data input interface, performing complexity calculation on the field processing parameter to obtain a processing complexity corresponding to the field to be configured, determining a type to which the field to be configured belongs based on the processing complexity; determining a code template matching the type to which the field to be configured belongs from a preset code template set to obtain a candidate code template corresponding to the field processing parameter, extracting a step type of each processing step in the field processing parameter, obtaining a code template matching the step type of each processing step from the candidate code template to obtain a target code template corresponding to each processing step, and combining the target code templates corresponding to each processing step to obtain an instantiation rule corresponding to the field to be configured; instantiating the field processing parameter corresponding to the field to be configured based on the instantiation rule to obtain an instance resource corresponding to each field to be configured; performing packet conversion on a network packet to be converted based on the instance resource corresponding to each field to be configured.
7. An electronic device, comprising: The method comprises the following steps:
8. A computer-readable storage medium having stored thereon program instructions, wherein, The program instruction is executed by the processor to realize the method of any one of claims 1 to 5. The program instruction is executed by the processor to realize the method of any one of claims 1 to 5.
Citation Information
Patent Citations
Heterogeneous protocol message forwarding method and device, and network exchange equipment
CN108521378A
Code file generation method and device
CN110399128A