A method and apparatus for message processing
By processing external system call requests through a unified gateway server, and using the gateway configuration information of the configuration center to parse and convert request data, it solves the problem in the existing technology that each additional business party requires a new coded Controller, and achieves efficient message processing and system maintenance. , which improves the robustness and reusability of the system.
Patent Information
- Application Number
- CN202111220761.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-20
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2041-10-20
AI Technical Summary
In the existing technology, when an external business system calls the gateway system, each additional business party or business scenario requires a new coding of a Controller, which increases the development workload and is not conducive to system maintenance. It violates the SOLID principle of code design and access standards. They are different and difficult to manage uniformly.
The unified gateway server processes call requests from external systems, parses and converts the request data based on the gateway configuration information obtained from the configuration center, and sends it to the corresponding client, avoiding repeated business development and improving the robustness and reliability of the system. Reusability.
It avoids repeated development, reduces the code development workload, improves the flexibility and maintainability of the system, complies with the SOLID principle of code design, supports multiple protocol conversions, and is easy to expand business.
Smart Images

Figure CN113973139B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a message processing method and device. Background Art
[0002] The gateway system connects with external business systems such as external ERP systems to implement message processing. When the message system cannot be directly connected with the external business system, the external business system asynchronously calls the gateway system HTTP interface, and the gateway system converts the HTTP request into a message and sends it.
[0003] In the prior art, the external business system calls the gateway system, and each business party or business scenario corresponds to a Controller (gateway controller), so that the gateway system processes HTTP requests. When each business party or business scenario is added, a new Controller needs to be coded to receive the HTTP request of the business party, and convert the content of the HTTP request into the corresponding message body and send it. However, the increase in business parties leads to an increase in the workload of development, and is also not conducive to the maintenance of the gateway system. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a message processing method and device, which can use a unified gateway server to process call requests from external systems, convert request data in the call request into a data object based on the gateway configuration information obtained from the configuration center, and send it to the client corresponding to the caller. When adding new services, it is only necessary to change the gateway configuration information, thereby avoiding duplicate business development and improving the robustness of the system.
[0005] To achieve the above object, according to one aspect of an embodiment of the present invention, a message processing method is provided, including:
[0006] Parse the request data and request path information from the call request sent by the caller;
[0007] Acquire gateway configuration information corresponding to the caller and the request path information from a configuration center, and convert the request data into a data object according to the gateway configuration information;
[0008] The data object is sent to a client corresponding to the caller.
[0009] Optionally, the gateway configuration information includes authentication configuration information; before converting the request data into a data object according to the gateway configuration information, the method further includes:
[0010] The call request is verified according to the authentication configuration information, and confirmation is made that the verification is successful.
[0011] Optionally, the gateway configuration information includes message body information; converting the request data into a data object according to the gateway configuration information includes:
[0012] Obtaining the field name, field type and parent node of the field attribute from the message body information;
[0013] The request data is deserialized according to the field name, the field type and the parent node of the field attribute to obtain the data object.
[0014] Optionally, before deserializing the request data, the following steps are included:
[0015] Determine whether a field in the request data is an unconfigured field;
[0016] If so, filter the field;
[0017] If not, determining whether the field type of the field matches the configured field type;
[0018] If yes, keep the field; if no, filter the field.
[0019] Optionally, after deserializing the request data, the method further includes:
[0020] Performing field verification on the data object and determining that the verification result is successful;
[0021] When the verification result is a verification failure, the process ends;
[0022] The field check includes at least one of a non-empty check and a range check. The non-empty check is to check whether the value of the field is an empty value, and the range check is to check whether the range of the value of the field is within a preset range.
[0023] Optionally, the gateway configuration information includes protocol information and subject information, and sending the data object to the client corresponding to the call request includes:
[0024] The client corresponding to the call request is determined according to the protocol information and the subject information, and the data object is sent to the client.
[0025] Optionally, the method further comprises:
[0026] Before obtaining the gateway configuration information corresponding to the caller and the request path information from the configuration center, determining that the gateway configuration information does not exist in the local cache, and after obtaining the gateway configuration information corresponding to the caller and the request path information from the configuration center, saving the gateway configuration information in the local cache;
[0027] When the gateway configuration information exists in the local cache, the gateway configuration information is obtained from the local cache.
[0028] According to another aspect of an embodiment of the present invention, a message processing device is provided, including:
[0029] The parsing module parses the request data and request path information from the call request sent by the caller;
[0030] A conversion module, which obtains gateway configuration information corresponding to the caller and the request path information from a configuration center, and converts the request data into a data object according to the gateway configuration information;
[0031] A sending module sends the data object to a client corresponding to the caller.
[0032] According to another aspect of an embodiment of the present invention, there is provided an electronic device, including:
[0033] one or more processors;
[0034] a storage device for storing one or more programs,
[0035] When the one or more programs are executed by the one or more processors, the one or more processors implement the message processing method provided by the present invention.
[0036] According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the message processing method provided by the present invention is implemented.
[0037] An embodiment of the above invention has the following advantages or beneficial effects: the message processing method of the embodiment of the present invention uniformly receives different call requests from different callers, parses the request data and request path information from the call request, and then obtains the gateway configuration information corresponding to the caller and the request path information from the configuration center, and then converts the request data into a data object according to the gateway configuration center, and sends the data object to the client corresponding to the caller. This message processing method can avoid repeated business development during business expansion, reduce the workload of code development, has high reusability, complies with the SOLID principle of code design, improves the robustness of the system, can be flexibly configured, and improves development efficiency.
[0038] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0040] Figure 1 is a schematic diagram of the main process of a message processing method according to an embodiment of the present invention;
[0041] Figure 2 is a schematic diagram of the main flow of another message processing method according to an embodiment of the present invention;
[0042] Figure 3 is a schematic diagram of main modules of a message processing device according to an embodiment of the present invention;
[0043] Figure 4 It is a schematic diagram of the process of a message processing method in the prior art;
[0044] Figure 5 It is a schematic diagram of a process of a message processing method according to an embodiment of the present invention;
[0045] Figure 6 is a schematic diagram of the interaction relationship between the integrated gateway system and the configuration center according to an embodiment of the present invention;
[0046] Figure 7 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0047] Figure 8 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0048] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0049] In the process of business expansion, such as the business expansion of new retail e-commerce, financial institutions connecting with third-party payment institutions, etc., the gateway system needs to connect with external business systems such as external ERP systems (Enterprise Resource Planning, integrated management information system) to receive messages from external business systems and perform related processing operations. In the prior art, the external business party will call the Controller corresponding to the gateway layer, and write the corresponding message content in the HTTP request Body. The Controllers of different processing parse different businesses and convert the relevant parameters of the request into the corresponding message body and send it. In this way, for each new business party or business scenario, the gateway module needs to encode a new Controller to accept new requests. Once the business party increases, the workload of the development business increases accordingly. In addition, when the number of Controllers in the code increases, it is not conducive to the maintenance of the gateway system, which violates the SOLID principle of code design. The scattered gateways will also cause different access standards, which is not conducive to subsequent unified management. In view of the above problems, the embodiment of the present invention provides a message processing method, which avoids repeated development of business, improves the reusability of the gateway system, and reduces the workload of code development.
[0050] Figure 1 is a schematic diagram of the main flow of a message processing method according to an embodiment of the present invention, such as Figure 1 As shown, the method includes:
[0051] Step S101: parsing request data and request path information from the call request sent by the caller;
[0052] Step S102: Obtaining gateway configuration information corresponding to the caller and request path information from the configuration center, and converting the request data into a data object according to the gateway configuration information;
[0053] Step S103: Send the data object to the client corresponding to the caller.
[0054] In an embodiment of the present invention, the caller is an external business system, such as an external ERP system. For example, in the field of e-commerce, it can be an order system, a commodity system, a price system, etc. of a certain e-commerce platform. The call request can be an HTTP request, from which the request data and request path information can be parsed, and the caller information can also be parsed. The caller information includes a caller identifier, and the request path information is the URL path information of the caller. The request data can be compressed data, for example, the request data is data compressed by snappy (an open source compression / decompression library), or it can be data compressed by compression libraries such as zlib, LZO, LZF, FastLZ, and QuickLZ. The request data includes business data information, such as commodity price reduction information, order information, etc. The request path information is the URL path information of the caller.
[0055] In an embodiment of the present invention, there may be one or more callers, each of which may correspond to one or more services or business scenarios, and each of which may send one or more call requests. The message processing device of the embodiment of the present invention may uniformly receive multiple call requests from multiple callers and verify the call requests. After successful verification, the request data may be converted into a data object and sent to the client corresponding to the caller.
[0056] Receive the call request sent by the caller and enter a series of gateway call chains. The gateway call chain is implemented using the responsibility chain design pattern, that is, if a behavior or process in the call chain fails, a failure result is returned. The gateway call chain is used to verify the call request and process the request data.
[0057] In the embodiment of the present invention, the gateway configuration information includes authentication configuration information. Before converting the request data into a data object according to the gateway configuration information, the process further includes: verifying the call request according to the authentication configuration information and confirming that the verification is successful.
[0058] In the embodiment of the present invention, after receiving the call request sent by the caller, the call request is verified according to the authentication configuration information of the configuration center. When the verification is successful, it can be determined that the caller and the call request have the call authority.
[0059] Optionally, a token, such as a token, can be parsed from the call request, and the authentication configuration information includes the configured token. The call request is verified according to the authentication configuration information, which also includes: matching the token parsed from the call request with the configured token. If the token parsed from the call request matches the configured token successfully, the verification is successful, otherwise, the verification fails and an unauthorized result is returned.
[0060] In an embodiment of the present invention, the authentication configuration information includes the configured caller information and the configured request path information. The call request is verified according to the authentication configuration information, and it also includes: verifying the caller information and the request path information in the call request to determine whether they match the configured caller information and the request path information. If the match is successful, the verification is successful, otherwise, the verification fails and an unauthorized result is returned.
[0061] Optionally, the call request also includes a key, and the authentication configuration information also includes a configured key. The call request is verified according to the authentication configuration information, including: matching the key in the call request with the configured key. If the match is successful, the verification is successful, otherwise, the verification fails and an unauthorized result is returned. If the request data is compressed data encrypted by a key, when the key in the call request successfully matches the configured key, the request data can be decompressed using the configured key to obtain the decompressed request data.
[0062] In an embodiment of the present invention, the gateway configuration information includes message body information. When the call request of the caller is successfully verified according to the authentication configuration information, the request data is converted into a data object according to the gateway configuration information, including: step S201: obtaining the parent node of the field name, field type and field attribute from the message body information; step S202: deserializing the request data according to the parent node of the field name, field type and field attribute to obtain the data object.
[0063] Optionally, when the call request is successfully verified, the message body information corresponding to the call request can be obtained from the configuration center according to the request path information and the caller information. The field name, field type, and parent node of the field attribute can be obtained from the message body information, and then the request data is deserialized to obtain the data object.
[0064] In an embodiment of the present invention, the request data may be data encrypted and compressed with a key, where the key is the same as the configured key. Before deserializing the request data according to the field name, field attributes, and the parent node of the field attributes, it also includes: decompressing the request data using the configured key to obtain the decompressed request data.
[0065] In an embodiment of the present invention, the request data is deserialized according to the parent node of the field name, field type and field attribute, including: according to the parent node of the field name, field type and field attribute, the decompressed request data is deserialized to obtain a data object.
[0066] In an embodiment of the present invention, the field name is the name of the field, such as the order number field, the product name field, the field type includes a string type, a numeric type and a date type, etc. The parent node of the field attribute, that is, the parent node of the field, is the parent node of the field that has a parent-child relationship with the field. If the field is the product price, the parent node of the field attribute is the product information. The request data is data in the Json string text format, the request data is deserialized, and the request data is converted into a data object according to the message body format, such as a Java object. For example, the product name is placed in the name field of the Java object, and the product price is placed in the price field of the Java object. The parent node of the corresponding field attribute is the product information. The request data is converted into a data object according to the format of the message body information, which is convenient for subsequent field verification of the data object.
[0067] In an embodiment of the present invention, before serializing the request data, it also includes: determining whether a field in the request data is an unconfigured field; if so, filtering the field; if not, determining whether the field type of the field matches the configured field type; if so, retaining the field, if not, filtering the field.
[0068] Before converting the caller's request data into a data object, filter the unrecognizable fields in the decompressed request data. For fields that are not configured in the configuration, that is, unconfigured fields, filter the field, such as deleting the field; for example, if the request data includes a field for the product category, if the field is not configured, filter the field. If the field is configured in the configuration, but the field type does not match the configured field type, filter the field, such as deleting the field; for example, if the order number field is configured, if the type of the order number field in the request data is a numeric type, which does not match the configured field type of a string type, filter the field.
[0069] In an embodiment of the present invention, after serializing the request data, it also includes: performing field verification on the data object to determine that the verification result is a successful verification; when the verification result is a verification failure, ending the process; wherein the field verification includes at least one of a non-empty check and a range check, the non-empty check is to check whether the value of the field is an empty value, and the range check is to check whether the range of the value of the field is within a preset range.
[0070] After converting the request data into a data object according to the message body information, the data object is subjected to field verification, including at least one of a non-empty verification and a range verification. The non-empty verification is as follows: when empty values are not allowed in the field, if the value of the field in the data object is verified to be an empty value, the verification fails, the gateway call chain fails to execute, the call failure result is returned, and the process ends; for example, if the field is an order number, empty values are not allowed, if an empty value is verified, the verification fails; the range verification is as follows: when the value of the set field is within a preset range, if the value of the field in the data object is verified to be not within the preset range, the verification fails, the gateway call chain fails to execute, the call failure result is returned, and the process ends; for example, if the field is an order status, the value range of the order status is 1-9, if the value of the order status in the data object is verified to be 10, the verification fails.
[0071] In an embodiment of the present invention, the gateway configuration information includes protocol information and subject information, and sending the data object to the client corresponding to the caller includes: determining the client corresponding to the caller according to the protocol information and subject information, and sending the data object to the client.
[0072] According to the caller information and request path information, the protocol information and topic information corresponding to the request data, that is, the configured message information, can be determined. According to the topic information, the topic name can be determined, that is, the topic name corresponding to the data object can be determined. The protocol information corresponds to the client, and the protocol information can include multiple protocols such as Kafka, rabbitMq, activeMq and pulsar. According to the protocol information and message topic information, the client and topic name can be determined, so that the message corresponding to the data object can be sent to the topic of the corresponding client. By converting the call request into an asynchronous message containing the data object, the protocol conversion is realized, so that the message corresponding to the data object supports multiple protocols. According to business needs, the types of protocols can be increased, which is easy to expand horizontally.
[0073] For example, call requests 1 and call requests 2 corresponding to services 1 and 2 respectively sent by the caller are received, and the authentication information of call requests 1 and 2 are respectively verified according to the authentication information of the configured call requests. When the verification is successful, the request data in call requests 1 and 2 are converted into data objects 1 and data object 2, and the message containing data object 1 is sent to topic 1 of the client corresponding to the caller, and the message containing data object 2 is sent to topic 2 of the client corresponding to the caller, so that the back-end business systems perform their respective business logic processing.
[0074] In an embodiment of the present invention, the method further includes: before obtaining the gateway configuration information corresponding to the caller and the request path information from the configuration center, determining that the gateway configuration information does not exist in the local cache; after obtaining the gateway configuration information corresponding to the caller and the request path information from the configuration center, saving the gateway configuration information in the local cache;
[0075] When the gateway configuration information exists in the local cache, the gateway configuration information is obtained from the local cache.
[0076] In an embodiment of the present invention, in order to improve the query and acquisition efficiency of gateway configuration information, the configuration snapshot obtained from the configuration center, that is, the gateway configuration information, is saved in the local cache. When the gateway configuration information exists in the local cache, the gateway configuration information is obtained from the local cache first. When the gateway configuration information does not exist in the local cache, it is obtained from the configuration center, and after obtaining the gateway configuration information corresponding to the caller and the request path information from the configuration center, the gateway configuration information is saved in the local cache. When the gateway configuration information of the configuration center changes, the configuration center pushes a notification of updating the gateway configuration information to the integrated gateway system, so that the integrated gateway system obtains the updated gateway configuration information and saves it in the local cache, thereby improving the query efficiency of the gateway configuration information.
[0077] The message processing method provided by the embodiment of the present invention uniformly receives the call request of the caller, parses the request data and request path information from the call request, converts the request data into a data object according to the gateway configuration information corresponding to the caller and the request path information obtained from the configuration center, and enables the data object to support multiple protocols such as Kafka, rabbitMq, activeMq and pulsar through the gateway configuration information of the configuration center, and sends the data object to the client corresponding to the protocol information and the subject information, so that the client serializes the data object and sends it to the message middleware, thereby realizing the protocol conversion of the call request to the asynchronous message, and is easy to expand horizontally; by deploying the configuration center gateway configuration information, the decoupling of business and technology is realized, the reusability is high, and the business expansion can be realized by changing the gateway configuration information of the configuration center, avoiding repeated business development, greatly reducing the workload of code development, and improving development efficiency, and can be applied to the external expansion of new retail e-commerce business.
[0078] like Figure 3 As shown, the embodiment of the present invention further provides a message processing device 300, including:
[0079] The parsing module 301 parses the call request sent by the caller to obtain the request data and the request path information;
[0080] The conversion module 302 obtains the gateway configuration information corresponding to the caller and the request path information from the configuration center, and converts the request data into a data object according to the gateway configuration information;
[0081] The sending module 303 sends the data object to the client corresponding to the caller.
[0082] In an embodiment of the present invention, the gateway configuration information includes authentication configuration information, and the device also includes an authentication module for verifying the call request according to the authentication configuration information before converting the request data into a data object according to the gateway configuration information, and confirming that the verification is successful.
[0083] In an embodiment of the present invention, the gateway configuration information includes message body information; the conversion module 302 is further used to: obtain the field name, field type and parent node of the field attribute from the message body information; deserialize the request data according to the parent node of the field name, field type and field attribute to obtain the data object.
[0084] In an embodiment of the present invention, the conversion module 302 is also used to: before deserializing the request data, determine whether a field in the request data is an unconfigured field; if so, filter the field; if not, determine whether the field type of the field matches the configured field type; if so, retain the field, if not, filter the field.
[0085] In the embodiment of the present invention, the conversion module 302 is further used to: after deserializing the request data, perform field verification on the data object to determine that the verification result is successful; when the verification result is a verification failure, end the process;
[0086] The field check includes at least one of a non-empty check and a range check. The non-empty check is to check whether the value of the field is an empty value, and the range check is to check whether the range of the value of the field is within a preset range.
[0087] According to an embodiment of the present invention, the gateway configuration information includes protocol information and subject information, and the sending module 303 is also used to: send the data object to the client corresponding to the caller, including: determining the client corresponding to the caller according to the protocol information and subject information, and sending the data object to the client.
[0088] In the embodiment of the present invention, the conversion module 302 is further used to: before obtaining the gateway configuration information corresponding to the caller and the request path information from the configuration center, determine that the gateway configuration information does not exist in the local cache, and after obtaining the gateway configuration information corresponding to the caller and the request path information from the configuration center, save the gateway configuration information in the local cache;
[0089] When the gateway configuration information exists in the local cache, the gateway configuration information is obtained from the local cache.
[0090] The message processing device of the embodiment of the present invention may be an integrated gateway system, such as Figure 4 The figure shows a flow chart of a method for message processing by a gateway system in the prior art. An external business system sends HTTP requests for business 1 and business 2 to the gateway system. Controller 1 and Controller 2 of the gateway system parse business 1 and business 2 respectively, and then convert the business request data of business 1 and business 2 into data objects respectively, and send the messages containing the data objects to the corresponding client topics 1 and 2 respectively. The client serializes the data objects and converts them into messages and sends them to the message queue. The backend business system listens for the messages, obtains the messages from the message queue, and processes business 1 and business 2 respectively. Figure 4 It can be seen that when adding new business parties or business scenarios, new Controllers need to be added for parsing and processing, which increases the workload of code development. The increase in the number of Controllers in the code is not conducive to system maintenance and violates the SOLID principle of code equipment. Dispersed Controllers will also cause various access standards to be inconsistent, which is not conducive to subsequent unified management.
[0091] like Figure 5 The figure shows a flow chart of a method for message processing using an integrated gateway system according to an embodiment of the present invention. An external business system sends HTTP requests of business 1 and business 2 to the integrated gateway system. The Controller of the integrated gateway system uniformly receives HTTP requests of business 1 and business 2. After receiving the HTTP request, the token, caller information and request path information are parsed from the HTTP request, the gateway configuration information is obtained, the token, caller information and request path information in the HTTP request are verified according to the authentication configuration information, the message body information is obtained after the verification is successful, the request data in the HTTP request is deserialized according to the format of the message body information, the data object is obtained, and then the field of the data object is verified, including non-empty verification and range verification. After the field verification is successful, according to the obtained message Configuration information is used to determine the client and topic names corresponding to each HTTP request of business 1 and business 2, and then the message containing the data object of business 1 is sent to topic 1 of the client corresponding to the HTTP request of business 1, and the message containing the data object of business 2 is sent to topic 2 of the client corresponding to the HTTP request of business 2; the client serializes the data object of business 1 and sends it to message queue 1, the back-end business system listens for the message, and obtains the message containing the data object from message queue 1 to process business 1; the client serializes the data object of business 2 and sends it to message queue 2, the back-end business system listens for the message, and obtains the message containing the data object from message queue 2 to process business 2.
[0092] like Figure 6 The diagram shows the interactive relationship between the integrated gateway system and the configuration center of the embodiment of the present invention. The integrated gateway system includes a parsing module, a conversion module and a sending module; the configuration center can be a configuration management system implemented based on middleware such as Zookeeper, and the configuration center stores gateway configuration information, including authentication configuration information, message body information and message configuration information. The authentication configuration information includes one or more of a token, a key, a caller information and a request path information. The message body information includes a field name, a field type and a field attribute parent node, and the message configuration information includes protocol information (message client type) and message subject information. When the integrated gateway system starts, it sends a registration request to the configuration center, and sends the gateway information of the integrated gateway system (including information such as a gateway identifier) to the configuration center. When the integrated gateway system is initialized, it obtains a configuration snapshot from the configuration center. The configuration snapshot includes all configuration information of the configuration center, including the gateway configuration information, and stores the configuration snapshot in the local cache, that is, the local cache. If the configuration information of the configuration center changes, the configuration center will send a change notification to the integrated gateway system in real time, and push the changed configuration snapshot to the integrated gateway system, so that the integrated gateway system stores the changed configuration snapshot in the local cache. When the configuration information in the configuration center has not changed, the integrated gateway system will query the configuration information from the local cache. If the integrated gateway system does not find the configuration information in the local cache, the query request will penetrate to the configuration center. If the configuration center does not have this configuration information, the integrated gateway system will store a null value in the local cache to prevent the query request from penetrating.
[0093] The message processing device or integrated gateway system provided in the embodiment of the present invention can uniformly receive the call request of the caller and use a unified Controller to process the call request. When the business is subsequently expanded, it is sufficient to change the gateway configuration information of the configuration center, thereby avoiding repeated business development. The configuration center will also push the change notification of the gateway configuration information to the integrated gateway system in real time. Through the combination of the integrated gateway system and the configuration center, the functions passed are clustered, and the differentiated functions are abstracted into different interfaces. For example, different message sending operations are performed with different protocol information, thereby realizing kernel abstraction, decoupling of business and technology, high reusability, complying with the SOLID principle of code design, and improving the robustness of the system. If the protocol information needs to be expanded later, it can be modified directly in the outer layer, that is, the client type in the gateway configuration information of the configuration center is changed.
[0094] An embodiment of the present invention also provides an electronic device, including one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by one or more processors, the one or more processors implement the message processing method of the embodiment of the present invention.
[0095] The embodiment of the present invention further provides a computer-readable medium on which a computer program is stored. When the program is executed by a processor, the message processing method of the embodiment of the present invention is implemented.
[0096] Figure 7 An exemplary system architecture 700 is shown to which the message processing method or message processing apparatus according to the embodiment of the present invention can be applied.
[0097] like Figure 7 As shown, system architecture 700 may include multiple servers 701, 702, 703, 704 and a network 705. Network 705 is used to provide a medium for communication links between servers 701, 702, 703, 704. Network 705 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0098] Servers 701, 702, 703 and 704 may be servers that provide various services, such as a backend management server that provides support for shopping websites browsed by users using terminal devices (only for example). The backend management server may analyze and process the received information query request and other data, and feed back the processing results (such as product information - only for example) to the terminal device.
[0099] It should be noted that the message processing method provided in the embodiment of the present invention is generally executed by servers 701 , 702 , 703 and 704 , and accordingly, the message processing device is generally arranged in servers 701 , 702 , 703 and 704 .
[0100] It should be understood that Figure 7 The number of networks and servers in the embodiment is only for illustration. Any number of networks and servers may be provided as required.
[0101] Reference below Figure 8 , which shows a schematic diagram of the structure of a computer system 800 of a terminal device suitable for implementing an embodiment of the present invention. Figure 8 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0102] like Figure 8As shown, the computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage part 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the system 800 are also stored. The CPU 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0103] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed, so that a computer program read therefrom is installed into the storage section 808 as needed.
[0104] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 809, and / or installed from the removable medium 811. When the computer program is executed by the central processing unit (CPU) 801, the above-mentioned functions defined in the system of the present invention are executed.
[0105] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, 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 above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0106] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0107] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be set in a processor. For example, they may be described as: a processor includes a parsing module, a conversion module, and a sending module. The names of these modules do not, in some cases, constitute a limitation on the modules themselves. For example, the parsing module may also be described as "a module for parsing request data and request path information from a call request sent by a caller".
[0108] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: parsing request data and request path information from the call request sent by the caller; obtaining gateway configuration information corresponding to the caller and the request path information from the configuration center, converting the request data into a data object according to the gateway configuration information; and sending the data object to the client corresponding to the caller.
[0109] According to the technical solution of the embodiment of the present invention, by uniformly receiving the call request of the caller, parsing the request data and request path information from the call request, converting the request data into a data object according to the gateway configuration information corresponding to the caller and the request path information obtained from the configuration center, so that the data object supports multiple protocols such as Kafka, rabbitMq, activeMq and pulsar, and sending the data object to the client corresponding to the protocol information and the subject information, so that the client serializes the data object and sends it to the message middleware, thereby realizing the protocol conversion of the call request to the asynchronous message, and facilitating horizontal expansion; by deploying the configuration center gateway configuration information, the decoupling of business and technology is realized, and the reusability is high. The business expansion can be realized by changing the gateway configuration information of the configuration center, avoiding repeated business development, greatly reducing the workload of code development, and improving development efficiency. It can be applied to the external expansion of new retail e-commerce business.
[0110] 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 may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A message processing method, characterized in that: include: Parse the request data and request path information from the call request sent by the caller; Acquire gateway configuration information corresponding to the caller and the request path information from a configuration center, and convert the request data into a data object according to the gateway configuration information; Sending the data object to a client corresponding to the caller; Wherein, the gateway configuration information includes authentication configuration information, and before converting the request data into a data object according to the gateway configuration information, it also includes: verifying the caller and the request path information according to the authentication configuration information, and confirming that the verification is successful; The gateway configuration information includes message body information; converting the request data into a data object according to the gateway configuration information, including: obtaining the field name, field type and parent node of the field attribute from the message body information; deserializing the request data according to the field name, the field type and the parent node of the field attribute to obtain the data object.
2. The method according to claim 1, characterized in that Before deserializing the request data, it includes: Determine whether a field in the request data is an unconfigured field; If so, filter the field; If not, determining whether the field type of the field matches the configured field type; If yes, keep the field; if no, filter the field.
3. The method according to claim 1, characterized in that: After deserializing the request data, it also includes: Performing field verification on the data object and determining that the verification result is successful; When the verification result is a verification failure, the process ends; The field check includes at least one of a non-empty check and a range check. The non-empty check is to check whether the value of the field is an empty value, and the range check is to check whether the range of the value of the field is within a preset range.
4. The method according to claim 1, characterized in that: The gateway configuration information includes protocol information and subject information, and sending the data object to the client corresponding to the call request includes: The client corresponding to the call request is determined according to the protocol information and the subject information, and the data object is sent to the client.
5. The method according to claim 1, characterized in that The method further comprises: Before obtaining the gateway configuration information corresponding to the caller and the request path information from the configuration center, determining that the gateway configuration information does not exist in the local cache, and after obtaining the gateway configuration information corresponding to the caller and the request path information from the configuration center, saving the gateway configuration information in the local cache; When the gateway configuration information exists in the local cache, the gateway configuration information is obtained from the local cache.
6. A message processing device, characterized in that: include: The parsing module parses the request data and request path information from the call request sent by the caller; A conversion module, which obtains gateway configuration information corresponding to the caller and the request path information from a configuration center, and converts the request data into a data object according to the gateway configuration information; A sending module, sending the data object to a client corresponding to the caller; Wherein, the gateway configuration information includes authentication configuration information, and before converting the request data into a data object according to the gateway configuration information, it also includes: verifying the caller and the request path information according to the authentication configuration information, and confirming that the verification is successful; The gateway configuration information includes message body information; the conversion module is further used to: obtain the field name, field type and parent node of the field attribute from the message body information; deserialize the request data according to the field name, the field type and the parent node of the field attribute to obtain the data object.
7. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.
8. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
