Data processing method based on API gateway and API gateway
By introducing the configuration of conversion rules and signing methods in the API gateway, the problem of interface changes and signature rule differences in the microservice architecture is solved, interface adaptation and data sharing are realized, system interaction and bandwidth usage are simplified, and the system is improved. flexibility and security.
Patent Information
- Application Number
- CN202210033242.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-12
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2042-01-12
AI Technical Summary
In the microservice architecture, the API gateway only transparently forwards messages, which causes the client to generate different request messages according to the interface requirements of each microservice node. As a result, the client needs to make a large number of adaptations when the interface changes, and the requirements of different service nodes are The signature rules are different, and the requesting party needs to adapt to their own signature verification requirements, which increases the complexity and bandwidth consumption of the system.
By introducing conversion rules and signing method configuration into the API gateway, message conversion and signing are realized, interface adaptation and signature verification requirements are unified, multicast/broadcast message processing is supported, and a mirror database is built on the API gateway to achieve Data sharing and backup.
It reduces the client's adaptation requirements for microservice interface changes, simplifies the requesting party's signing process, saves bandwidth resources between systems, realizes safe sharing and backup of data, and promotes loosely coupled interactions between systems.
Smart Images

Figure CN114374603B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a data processing method based on an API gateway and an API gateway. Background Art
[0002] In a microservice architecture, a large application is split into multiple microservices. Each microservice can be self-contained, that is, these microservices can have their own databases, frameworks, and even languages, and are usually called by upper-level applications or third-party applications through interfaces in the Representational State Transfer (REST) mode.
[0003] The Application Programming Interface (API) gateway is the only external entrance for internal microservices and an important part of the microservice architecture. The API gateway is a software component located above the application layer in the OSI seven-layer model and is mostly based on the HTTP protocol.
[0004] All requests / messages from external systems will first be sent to the API gateway, which will route them to different microservice nodes based on different requests / messages.
[0005] Usually, different microservice nodes have different interfaces. Currently, since the API gateway only forwards messages transparently, the client needs to generate corresponding request messages according to the interface requirements of the target microservice node. Different interfaces correspond to different request messages. In other words, the client needs to see the interface requirements of each internal microservice. If the interface of a microservice changes, the client needs to make corresponding adaptations. Summary of the invention
[0006] One of the purposes of the present invention is to overcome at least some of the deficiencies in the prior art, and to provide a data processing method and an API gateway based on an API gateway, thereby reducing the impact of changes in the microservice interfaces within the business system on the client by enhancing the functionality of the API gateway.
[0007] The technical solution provided by the present invention is as follows:
[0008] The present invention provides a data processing method based on an API gateway, comprising:
[0009] When receiving the first message, the API gateway queries the configuration information and obtains the conversion rules for converting the first message into the second message from the configuration information; the API gateway converts the first message into the second message according to the conversion rules; the API gateway sends the second message to the recipient of the first message.
[0010] In some embodiments, the API gateway converts the first message into the second message according to the conversion rule, including: the API gateway converts the first message into the second message by calling a conversion function that implements the conversion rule; the conversion function is implemented in a plug-in manner.
[0011] In some embodiments, the method further includes: when receiving the first message, the API gateway also obtains the signing method of the recipient of the first message from the configuration information;
[0012] After generating the second message and before sending the second message, the method further includes: the API gateway signing the second message according to the signing method of the recipient;
[0013] The API gateway sends the second message to the recipient of the first message, including: the API gateway sends the signed second message to the recipient of the first message.
[0014] In some embodiments, the step of obtaining a conversion rule for converting the first message into the second message from the configuration information includes: when the first message is a multicast message, obtaining all receiver information of the first message and a conversion rule corresponding to each receiver from the configuration information;
[0015] The API gateway converts the first message into the second message according to the conversion rule, including: for each recipient, the API gateway converts the first message into a corresponding second message according to the corresponding conversion rule;
[0016] The API gateway sends the second message to the recipient of the first message, including: the API gateway sends the corresponding second message to each recipient respectively.
[0017] In some embodiments, the step of obtaining a conversion rule for converting the first message into the second message from the configuration information further includes: when the first message is a broadcast message, obtaining a broadcast object corresponding to the first message from the configuration information;
[0018] The API gateway sends the second message to the recipient of the first message, including: the API gateway sends the second message to each broadcast object respectively.
[0019] In some embodiments, it also includes: building a mirror database on the API gateway, the mirror database includes a first data part, and the first data part is the original data generated by the data maintainer; when the data maintainer initiates data synchronization to the API gateway, the API gateway updates the first data part according to the synchronized data; the API gateway assigns an account and address for accessing the first data part of the mirror database to relevant data consumers.
[0020] In some embodiments, the mirror database further includes a second data portion, wherein the second data portion is data generated by the API gateway according to the first data portion;
[0021] After the API gateway updates the first data part according to the synchronized data, the method further includes: the API gateway queries configuration information and obtains data processing rules from the configuration information; the API gateway processes the updated first data part according to the data processing rules to obtain an updated second data part;
[0022] The API gateway allocates an account number and an address for accessing the second data portion of the mirror database to relevant data consumers.
[0023] The present invention also provides an API gateway, including:
[0024] an acquisition module, configured to query configuration information when a first message is received, and acquire from the configuration information a conversion rule for converting the first message into a second message;
[0025] A message generating module, configured to convert the first message into the second message according to the conversion rule;
[0026] A sending module is used to send the second message to a recipient of the first message.
[0027] In some embodiments, the message generation module is further used to convert the first message into the second message by calling a conversion function that implements the conversion rule; the conversion function is implemented in a plug-in manner.
[0028] In some embodiments, the acquisition module is further used to acquire the signing method of the recipient of the first message from the configuration information when the first message is received;
[0029] The message generating module is further configured to sign the second message according to the signing method of the receiving party;
[0030] The sending module is further used to send the signed second message to a recipient of the first message.
[0031] Compared with the prior art, the data processing method based on API gateway and API gateway provided by the present invention have at least one of the following beneficial effects:
[0032] 1. The present invention enhances the function of the API gateway, and the API gateway completes the interface adaptation of multiple service nodes within the microservice system. When the interface of a service node changes, there is no need to make major modifications to the peripheral system. It is only necessary to modify the configuration information of the API gateway according to the new interface, thereby further promoting the interaction between systems through the API gateway to achieve the effect of loose coupling.
[0033] 2. The present invention encapsulates the signature rules of different service nodes through the API gateway, and the requester no longer needs to adapt to the signature verification requirements of the recipient, which simplifies the signature processing of the requester; the requester can unify the signature method and only needs to see the signature verification requirements of the API gateway.
[0034] 3. The present invention supports the processing of multicast / broadcast messages through the API gateway, so that the requester only needs to send one multicast / broadcast message to the API gateway, and does not need to generate a message for each recipient, which can save bandwidth resources between the peripheral system and the API gateway.
[0035] 4. The present invention not only plays a role in data backup but also plays a role in data sharing through the mirroring function of the API gateway, thereby improving the security of data access. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] The preferred implementation modes will be described below in a clear and understandable manner with reference to the accompanying drawings to further illustrate the above-mentioned characteristics, technical features, advantages and implementation methods of the present invention.
[0037] Figure 1 is a flow chart of an embodiment of the data processing method based on API gateway of the present invention;
[0038] Figure 2 is a flow chart of another embodiment of the data processing method based on API gateway of the present invention;
[0039] Figure 3 This is an example of multiple signing methods within a microservice system;
[0040] Figure 4 is a flow chart of another embodiment of the data processing method based on API gateway of the present invention;
[0041] Figure 5 is an example of a multicast message;
[0042] Figure 6is a flow chart of another embodiment of the data processing method based on API gateway of the present invention;
[0043] Figure 7 is a flow chart of another embodiment of the data processing method based on API gateway of the present invention;
[0044] Figure 8 is a flow chart of another embodiment of the data processing method based on API gateway of the present invention;
[0045] Fig. 9 It is a structural diagram of an embodiment of the API gateway of the present invention;
[0046] Fig.10 It is a structural diagram of another embodiment of the API gateway of the present invention;
[0047] Fig.11 It is a network schematic diagram of the data processing method based on API gateway of the present invention. DETAILED DESCRIPTION
[0048] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the specific implementation methods of the present invention will be described below with reference to the accompanying drawings. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings and other implementation methods can be obtained based on these drawings without creative work.
[0049] In order to simplify the drawings, only the parts related to the invention are schematically shown in each figure, and they do not represent the actual structure of the product. In addition, in order to simplify the drawings and facilitate understanding, in some figures, only one of the parts with the same structure or function is schematically drawn or marked. In this article, "one" not only means "only one", but also means "more than one".
[0050] Fig.11 A network diagram of an API gateway provided in an embodiment of the present invention. An API gateway 1 is deployed between a client 3 and a microservice system 2, and the microservice system 2 includes a plurality of service nodes 4. All accesses to the microservice system 2 are accessed through the API gateway 1.
[0051] In one embodiment, Figure 1 As shown, a data processing method based on API gateway includes:
[0052] Step S100: When receiving the first message, the API gateway queries the configuration information and obtains the conversion rule for converting the first message into the second message from the configuration information;
[0053] Step S200: The API gateway converts the first message into a second message according to the conversion rule;
[0054] Step S400: The API gateway sends a second message to the recipient of the first message.
[0055] Specifically, the first message is a message sent by the client; the second message is a message received by the receiver of the first message. The receiver of the first message is at least one service node of the microservice system 2.
[0056] When the API gateway receives the first message, it queries the configuration information and obtains the conversion rule of the first message from the configuration information. The API gateway processes the first message according to the conversion rule to obtain the second message. The configuration information can be pre-stored in the API gateway, or the user or the management device of the API gateway can dynamically configure or modify the information for the API gateway.
[0057] In some scenarios, there may be no conversion rules, which means that the API gateway only needs to perform traditional forwarding, that is, transparent transmission. Scenarios where conversion rules exist require special processing by the API gateway. Conversion rules include conversion rules for data exchange formats, parameter name conversion rules, and parameter value conversion rules.
[0058] Generally, the two communicating parties exchange information according to the agreed data exchange format, and the data exchange formats used by different communicating parties may be different.
[0059] Commonly used data exchange formats include XML (Extensible Markup Language), JSON (JavaScript Object Notation), FormData (organizing object data in key / value pairs), etc.
[0060] For example, the XML data exchange format is used between the client and the API gateway, and the JSON format is used between the API gateway and the A service node. If the first message is sent to the A service node via the API gateway, the conversion rule is XML format = > JSON format. The API gateway needs to parse the first message in XML format, organize the original message content obtained after parsing in JSON format, obtain the second message, and then send the second message to the A service node.
[0061] In addition to the data exchange format, there may also be conversion of parameter names and / or parameter values between the first message and the second message. For example, the parameter "page_num" of the first message corresponds to the parameter "page_num_convert" of the second message; due to different units used, the value "10" of the parameter "amount" of the first message corresponds to the value "100" of the parameter "amount" of the second message, etc.
[0062] The above conversion rules can be combined. In addition to the above listed conversion rules, there may be other conversion rules, which are not limited.
[0063] When the first message is a unicast message (i.e., point-to-point transmission), the API gateway can determine the recipient information, such as the recipient address, based on the first message. If the first message is a multicast message / broadcast message, the API gateway can obtain all recipient addresses / broadcast object addresses of the first message from the configuration information. Based on the recipient address / broadcast object address, the API gateway sends the second message to the corresponding recipient.
[0064] In one embodiment, step S200 includes:
[0065] Step S201: The API gateway converts the first message into the second message by calling a conversion function that implements the conversion rule; the conversion function is implemented in a plug-in manner.
[0066] For example, a Lua parser is set inside the API gateway, corresponding Lua functions are developed for different conversion rules, and the developed Lua functions are configured in the API gateway through plug-ins, which can realize data processing in specific scenarios. Other plug-in development software can also be used, and the present invention does not limit this.
[0067] The aforementioned conversion rules can be implemented through plug-ins, and more complex data conversion functions can also be implemented. Through plug-ins, customized functions can be flexibly added to meet the needs of specific scenarios, which is conducive to dynamically expanding the functions of the API gateway.
[0068] In this embodiment, by enhancing the function of the API gateway, the API gateway completes the interface adaptation of multiple service nodes within the microservice system. When the interface of a service node changes, there is no need to make major modifications to the peripheral system. It is only necessary to modify the configuration information of the API gateway according to the new interface, thereby further promoting the interaction between systems through the API gateway to achieve a loose coupling effect.
[0069] In another embodiment, Figure 2 As shown, a data processing method based on API gateway includes:
[0070] Step S110: When receiving the first message, the API gateway queries the configuration information, and obtains the conversion rule for converting the first message into the second message and the signing method of the recipient of the first message from the configuration information;
[0071] Step S210: The API gateway converts the first message into a second message according to the conversion rule;
[0072] Step S310: The API gateway signs the second message according to the signing method of the recipient;
[0073] Step S410: The API gateway sends the signed second message to the recipient of the first message.
[0074] Specifically, the configuration information of the API gateway also includes the signing method of each service node in the microservice system; when receiving the first message, the API gateway obtains the signing method of the recipient of the first message from the configuration information; after generating the second message, the second message is signed to meet the signature verification requirements of the recipient. Signing is encryption, and signature verification is decryption.
[0075] like Figure 3 For example, assuming that the API gateway and each service have their own signature verification requirements, requester 1 sends message 1 to service A via the API gateway, and requester 2 sends message 2 to service B via the API gateway. When generating message 1, requester 1 only needs to meet the signature verification requirements of the API gateway, that is, message 1 (i.e., the first message) only needs to encapsulate the signature method of the API gateway; the API gateway converts message 1 to obtain message A (i.e., the second message), and then encapsulates message A with the signature method of service A according to the signature verification requirements of service A, and sends the signed message A to service A. Similarly, message 2 needs to encapsulate the signature method of the API gateway. The second message corresponding to message 2 is message B. Message B needs to encapsulate the signature method of service B, and the signed message B is sent to service B.
[0076] If the existing method is used, message 1 needs to first encapsulate the signing method of service A, and then encapsulate the signing method of the API gateway. Message 2 needs to first encapsulate the signing method of service B, and then encapsulate the signing method of the API gateway.
[0077] It can be seen that this embodiment encapsulates the signature rules of different service nodes through the API gateway, and the requester no longer needs to adapt to the signature verification requirements of the recipient, which simplifies the signature processing of the requester; the requester can unify the signature method and only needs to see the signature verification requirements of the API gateway.
[0078] In another embodiment, Figure 4 As shown, a data processing method based on API gateway includes:
[0079] Step S120: When the first message is received and the first message is a multicast message, the API gateway queries the configuration information and obtains all the recipient information of the first message and the conversion rules corresponding to each recipient from the configuration information;
[0080] Step S220: For each recipient, the API gateway converts the first message into a corresponding second message according to a corresponding conversion rule;
[0081] Step S420: The API gateway sends a corresponding second message to each recipient respectively.
[0082] Specifically, the configuration information of the API gateway includes the address information of all recipients in the multicast message and the conversion rules corresponding to each recipient. The conversion rules corresponding to each recipient may be different.
[0083] When receiving a multicast message (i.e. point-to-multipoint transmission), the API gateway obtains the address information of all recipients and the conversion rules corresponding to each recipient from the configuration information. According to the conversion rules of each recipient, the API gateway generates a corresponding second message based on the first message and then sends the second message to the corresponding recipient.
[0084] like Figure 5 For example, suppose a multicast message needs to be sent to service AC. The multicast message content has n fields, of which n1 fields are for service A, n2 fields are for service B, and n3 fields are for service C. According to this requirement, the respective conversion rules are formed and configured for the API gateway. The API gateway receives this multicast message, processes it according to the conversion rule requirements of each recipient to obtain message AC (i.e., the second message), and then sends message AC to the corresponding recipients.
[0085] Through this embodiment, the requester only needs to send a multicast message to the API gateway, and does not need to generate a first message for each recipient, which can save bandwidth resources between the peripheral system and the API gateway.
[0086] In one embodiment, step S220 may convert the first message into a second message that meets the requirements of the corresponding recipient by calling a conversion function that implements the conversion rule of each recipient; the conversion function is implemented in a plug-in manner.
[0087] In one embodiment:
[0088] Step S120 is replaced by: Step S121: When the first message is received and the first message is a multicast message, the API gateway queries the configuration information, obtains all recipient information of the first message, the signing method of all recipients, and the conversion rules corresponding to each recipient from the configuration information.
[0089] Add step S321 after step S220: For each recipient, the API gateway signs the corresponding second message according to the recipient's signing method.
[0090] Step S420 is replaced by step S421: the API gateway sends the corresponding signed second message to each recipient respectively.
[0091] In another embodiment, Figure 6 As shown, a data processing method based on API gateway includes:
[0092] Step S130: When a first message is received and the first message is a broadcast message, the API gateway queries the configuration information, obtains the broadcast object corresponding to the first message and the conversion rule for converting the first message into the second message from the configuration information;
[0093] Step S230 The API gateway converts the first message into a second message according to the conversion rule;
[0094] Step S430: The API gateway sends a second message to each broadcast object respectively.
[0095] In some scenarios, when a business message needs to be synchronized to multiple other business systems, the traditional method requires the initiator to send it to multiple business systems separately, and the transmitted message is consistent.
[0096] The broadcast function of the API gateway in this embodiment can simplify the sending workload of the initiator. The initiator only needs to send a message to the API gateway once, and the API gateway will distribute the message. When the message fails to be distributed to a service node, the API gateway can use the retry mechanism to retry.
[0097] In this embodiment, the broadcast function of the API gateway can save bandwidth resources between the peripheral system and the API gateway.
[0098] In one embodiment:
[0099] Step S130 is replaced by: Step S131: When the first message is received and the first message is a broadcast message, the API gateway queries the configuration information, obtains the broadcast object corresponding to the first message, the signing method of all broadcast objects, and the conversion rules for converting the first message into the second message from the configuration information.
[0100] Add step S331 after step S230: The API gateway signs the corresponding second message according to the signing method of each broadcast object.
[0101] Step S430 is replaced by step S431: the API gateway sends the corresponding signed second message to each broadcast object respectively.
[0102] In another embodiment, Figure 7 As shown, a data processing method based on API gateway includes:
[0103] Step S140 builds a mirror database on the API gateway, the mirror database includes a first data portion, and the first data portion is the original data generated by the data maintainer;
[0104] Step S240: When the data maintainer initiates data synchronization to the API gateway, the API gateway updates the first data part according to the synchronized data;
[0105] Step S340: The API gateway allocates an account and address for accessing the first data portion of the mirror database to the relevant data consumer.
[0106] There is often a large amount of data that needs to be shared between systems. In order to simplify the complexity of docking, systems usually use views or intermediate tables to share data. When the data of a system (i.e., data maintainer or data generator) needs to be shared with multiple other systems (i.e., related data consumers), multiple other systems need to query the tables or views in the database of the system, but the queries of multiple other systems may affect the database performance of the system.
[0107] In view of the above problems, and the fact that each service node in the microservice system is naturally connected to the API gateway, a mirror database can be built on the API gateway to uniformly mirror the shared data to the mirror database of the API gateway. Based on the actual situation, other systems that need to share data are assigned independent accounts and addresses for their connection. Data consumers consult the mirror database on the API gateway based on the access account and access address obtained to obtain the data they need. This can prevent data consumers from directly accessing the database of the data maintainer, thereby affecting the database performance of the data maintainer.
[0108] The mirror database includes a first data part, which is the original data generated by the data maintainer. The data consumer can generate the data he needs based on the first data part.
[0109] In another embodiment, Figure 8 As shown, a data processing method based on API gateway includes:
[0110] Step S150 builds a mirror database on the API gateway, the mirror database includes a first data part and a second data part, the first data part is the original data generated by the data maintainer, and the second data part is the data generated by the API gateway according to the first data part;
[0111] Step S250: When the data maintainer initiates data synchronization to the API gateway, the API gateway updates the first data part according to the synchronized data;
[0112] Step S350: The API gateway queries the configuration information and obtains the data processing rules from the configuration information;
[0113] Step S450: The API gateway processes the updated first data portion according to the acquired data processing rule to obtain an updated second data portion;
[0114] Step S550: The API gateway allocates an account and address for accessing the second data portion of the mirror database to the relevant data consumer.
[0115] Specifically, the data maintainer generates the original data, and the data consumers use the data. Some consumers use the original data, but some consumers need to use the data obtained after processing the original data. For this reason, a second data part is added to the mirror database.
[0116] The API gateway obtains the data processing rules from the configuration message, organizes the relevant first data part into the data required by the data consumer according to the data processing rules, and stores it in the second data part. Furthermore, the corresponding second data part can be constructed for different data consumers. In this way, the data consumer only needs to access the second data part, which not only facilitates the access of the data consumer, but also increases the security of the access. The data consumer only needs to access the data related to it and avoids seeing the data irrelevant to it.
[0117] The permissions for different consumers to access the mirror database can be flexibly set. For example, for consumers who only need to access the second data part / first data part, only the account and address for accessing the second data part / first data part can be allocated; for consumers who need to see both the first data part and the second data part, the account and address for accessing both the first data part and the second data part can be allocated.
[0118] In this embodiment, the mirroring function of the API gateway not only plays a role in data backup, but also plays a role in data sharing, thereby improving the security of data access.
[0119] In one embodiment, Fig. 9 As shown, an API gateway includes:
[0120] The acquisition module 100 is used to query the configuration information when receiving the first message, and obtain the conversion rule for converting the first message into the second message from the configuration information;
[0121] The message generating module 200 is used to convert the first message into the second message according to the conversion rule;
[0122] The sending module 300 is used to send a second message to a recipient of the first message.
[0123] In one embodiment, the message generation module 200 is further used to convert the first message into the second message by calling a conversion function that implements the conversion rule; the conversion function is implemented in a plug-in manner.
[0124] In this embodiment, by enhancing the function of the API gateway, the API gateway completes the interface adaptation of multiple service nodes within the microservice system. When the interface of a service node changes, there is no need to make major modifications to the peripheral system. It is only necessary to modify the configuration information of the API gateway according to the new interface, thereby further promoting the interaction between systems through the API gateway to achieve a loose coupling effect.
[0125] In another embodiment, Fig. 9 As shown, an API gateway includes:
[0126] The acquisition module 100 is used to query the configuration information when receiving the first message, and obtain the conversion rule for converting the first message into the second message and the signing method of the recipient of the first message from the configuration information;
[0127] The message generation module 200 is used to convert the first message into a second message according to the conversion rule; and to sign the second message according to the signing method of the recipient;
[0128] The sending module 300 is used to send the signed second message to the recipient of the first message.
[0129] In another embodiment, Fig. 9 As shown, an API gateway includes:
[0130] The acquisition module 100 is used to query the configuration information when receiving the first message, and when the first message is a multicast message, and obtain all the receiver information of the first message and the conversion rule corresponding to each receiver from the configuration information;
[0131] The message generating module 200 is used to convert the first message into a corresponding second message according to a corresponding conversion rule for each recipient;
[0132] The sending module 300 is used to send a corresponding second message to each recipient respectively.
[0133] In one embodiment, the message generation module 200 may convert the first message into a second message that meets the requirements of the corresponding recipient by calling a conversion function that implements the conversion rule of each recipient; the conversion function is implemented in a plug-in manner.
[0134] In one embodiment, the acquisition module 100 is also used to query the configuration information when a first message is received and the first message is a multicast message, and obtain the information of all recipients of the first message, the signing method of all recipients, and the conversion rules corresponding to each recipient from the configuration information; the message generation module 200 is also used to sign the corresponding second message for each recipient according to the signing method of the recipient; the sending module 300 is also used to send the corresponding signed second message to each recipient respectively.
[0135] In another embodiment, Fig. 9 As shown, an API gateway includes:
[0136] The acquisition module 100 is used to query the configuration information when a first message is received and the first message is a broadcast message, and obtain the broadcast object corresponding to the first message and the conversion rule for converting the first message into a second message from the configuration information;
[0137] The message generating module 200 is used to convert the first message into the second message according to the conversion rule;
[0138] The sending module 300 is used to send a second message to each broadcast object respectively.
[0139] In one embodiment, the acquisition module 100 is also used to query the configuration information when a first message is received and the first message is a broadcast message, and obtain the broadcast object corresponding to the first message, the signing method of all broadcast objects, and the conversion rules for converting the first message into the second message from the configuration information; the message generation module 200 is also used to sign the corresponding second message according to the signing method of each broadcast object; the sending module 300 is also used to send the corresponding signed second message to each broadcast object respectively.
[0140] In another embodiment, Fig.10 As shown, an API gateway includes:
[0141] A construction module 110 is used to construct a mirror database on the API gateway, where the mirror database includes a first data portion, where the first data portion is original data generated by a data maintainer;
[0142] The data synchronization module 210 is used to update the first data part according to the synchronized data when the data maintainer initiates data synchronization to the API gateway;
[0143] The allocation module 310 is used to allocate an account number and address for accessing the first data portion of the mirror database to relevant data consumers.
[0144] In another embodiment, Fig.10As shown, an API gateway includes:
[0145] A construction module 110 is used to construct a mirror database on the API gateway, the mirror database includes a first data part and a second data part, the first data part is the original data generated by the data maintainer, and the second data part is the data generated by the API gateway according to the first data part;
[0146] The data synchronization module 210 is used to update the first data part according to the synchronized data when the data maintainer initiates data synchronization to the API gateway; query the configuration information and obtain the data processing rules from the configuration information; process the updated first data part according to the obtained data processing rules to obtain the updated second data part;
[0147] The allocation module 310 is used to allocate an account number and address for accessing the second data portion of the mirror database to the relevant data consumer.
[0148] In this embodiment, the mirroring function of the API gateway not only plays a role in data backup, but also plays a role in data sharing, thereby improving the security of data access.
[0149] It should be noted that the embodiment of the API gateway provided by the present invention and the embodiment of the data processing method based on the API gateway provided above are based on the same inventive concept and can achieve the same technical effect. Therefore, other specific contents of the embodiment of the API gateway can refer to the contents of the embodiment of the data processing method based on the API gateway.
[0150] It should be noted that the above embodiments can be freely combined as needed. The above are only preferred embodiments of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be regarded as the protection scope of the present invention.
Claims
1. A data processing method based on API gateway, characterized in that: include: When receiving the first message, the API gateway queries the configuration information and obtains a conversion rule for converting the first message into the second message from the configuration information; The API gateway converts the first message into the second message according to the conversion rule; The API gateway sends the second message to a recipient of the first message; In order to realize data sharing between the data maintainer and multiple data consumers, a mirror database is built on the API gateway, and the mirror database includes a first data part and a second data part. The first data part is the original data generated by the data maintainer, and the second data part is the data generated by the API gateway according to the first data part; When the data maintainer initiates data synchronization to the API gateway, the API gateway updates the first data portion according to the synchronized data; The API gateway queries configuration information and obtains data processing rules from the configuration information; The API gateway processes the updated first data portion according to the data processing rule to obtain an updated second data portion; The API gateway allocates an account and address for accessing the first data part and / or the second data part of the mirror database to relevant data consumers, including: for consumers who only need to access the second data part / the first data part, only allocating an account and address for accessing the second data part / the first data part.
2. The data processing method based on API gateway according to claim 1 is characterized in that: The API gateway converts the first message into the second message according to the conversion rule, including: The API gateway converts the first message into the second message by calling a conversion function that implements the conversion rule; the conversion function is implemented in a plug-in manner.
3. The data processing method based on API gateway according to claim 1 is characterized in that: Also includes: When receiving the first message, the API gateway also obtains the signing method of the recipient of the first message from the configuration information; After generating the second message and before sending the second message, the method further includes: the API gateway signing the second message according to the signing method of the recipient; The API gateway sends the second message to the recipient of the first message, including: the API gateway sends the signed second message to the recipient of the first message.
4. The data processing method based on API gateway according to claim 1 is characterized in that: The obtaining of the conversion rule for converting the first message into the second message from the configuration information includes: when the first message is a multicast message, obtaining all receiver information of the first message and the conversion rule corresponding to each receiver from the configuration information; The API gateway converts the first message into the second message according to the conversion rule, including: for each recipient, the API gateway converts the first message into a corresponding second message according to the corresponding conversion rule; The API gateway sends the second message to the recipient of the first message, including: the API gateway sends the corresponding second message to each recipient respectively.
5. The data processing method based on API gateway according to claim 1 is characterized in that: The step of obtaining a conversion rule for converting the first message into a second message from the configuration information further includes: when the first message is a broadcast message, obtaining a broadcast object corresponding to the first message from the configuration information; The API gateway sends the second message to the recipient of the first message, including: the API gateway sends the second message to each broadcast object respectively.
6. An API gateway, characterized in that: include: an acquisition module, configured to query configuration information when a first message is received, and acquire a conversion rule for converting the first message into a second message from the configuration information; A message generating module, configured to convert the first message into the second message according to the conversion rule; A sending module, used for sending the second message to a recipient of the first message; A construction module, configured to construct a mirror database on the API gateway in order to realize data sharing between a data maintainer and a plurality of data consumers, wherein the mirror database includes a first data portion and a second data portion, wherein the first data portion is original data generated by the data maintainer, and the second data portion is data generated by the API gateway according to the first data portion; A data synchronization module, used for updating the first data part according to the synchronized data when the data maintainer initiates data synchronization to the API gateway; querying configuration information, and obtaining data processing rules from the configuration information; processing the updated first data portion according to the data processing rules to obtain an updated second data portion; An allocation module is used to allocate accounts and addresses for accessing the first data part and / or the second data part of the mirror database to relevant data consumers, including: for consumers who only need to access the second data part / the first data part, only the account number and address for accessing the second data part / the first data part is allocated.
7. The API gateway according to claim 6, characterized in that: The message generation module is further used to convert the first message into the second message by calling a conversion function that implements the conversion rule; the conversion function is implemented in a plug-in manner.
8. The API gateway according to claim 6, characterized in that: The acquisition module is further configured to acquire, when receiving the first message, a signature method of a recipient of the first message from the configuration information; The message generating module is further configured to sign the second message according to the signing method of the recipient; The sending module is further used to send the signed second message to a recipient of the first message.
