Data interaction method, system, device, equipment and medium
By introducing preset routing rules between the front-end device and the gateway, and deploying only updated back-end services separately, the high-cost full-scale replication deployment problem in existing technologies is solved, enabling low-cost adjustments to business requirements and testing of stability.
Patent Information
- Application Number
- CN202411062861.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-05
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2044-08-05
AI Technical Summary
During the adjustment of new business requirements, the existing technology requires full replication and deployment of components such as front-end applications, back-end services and databases, resulting in high manpower, time and machine operating costs, as well as unstable joint debugging and testing issues.
By introducing preset routing rules between the front-end device and the gateway, the back-end service identifier is determined by matching parameters and service parameters. Only updated back-end services are deployed separately, and the original service and the new service run simultaneously. The gateway sends requests to the corresponding service according to the routing rules.
This reduced the manpower, time, and machine operation costs of service deployment, while ensuring the normal use of the original services and the joint debugging and testing of new requirements, avoiding resource waste and increased communication costs.
Smart Images

Figure CN118972462B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a data interaction method, system, apparatus, device, and medium. Background Technology
[0002] Current mainstream software architecture can be abstracted as the interaction between components such as front-end applications, back-end services, and databases. As business requirements change, one or more of these components may also change. Developers need to adjust the code logic of any one or more of these components to respond to these changes. Furthermore, integration testing during development and testing after development both require the support of the deployment environment. In adjusting to new business requirements, it is essential to ensure the normal operation of the original services while simultaneously supporting integration testing and validation of the new requirements.
[0003] In order to ensure the normal use of the original services while supporting the joint debugging and testing of new requirements during the adjustment of new business needs, a significant investment is required in the manpower, time, and machine operation costs of service deployment. Summary of the Invention
[0004] The purpose of this application is to provide a data interaction method, system, device, equipment, and medium to reduce the investment in manpower, time, and machine operation costs for service deployment while ensuring the normal use of the original services and supporting the joint debugging and testing of new requirements during the adjustment of new business needs. The specific technical solution is as follows:
[0005] In a first aspect of this application, a data interaction method is provided, applied to a front-end device, the method comprising:
[0006] Send an interaction request to the gateway, the interaction request carrying a first matching parameter, the first matching parameter being used to identify the original first backend service;
[0007] If the interaction request also carries a first service parameter, the gateway determines the backend service identifier based on the first matching parameter and the first service parameter, determines the second address of the second backend service based on the preset routing rule and the backend service identifier, and sends the interaction request to the second backend service based on the second address; wherein, the first service parameter is used to identify the second backend service updated based on the first backend service, and the preset routing rule represents the correspondence between the backend service identifier and the address of the backend service;
[0008] If the interaction request does not carry the first service parameter, the gateway determines the address of the first backend service based on the first matching parameter and the preset routing rules, and sends the interaction request to the first backend service.
[0009] Receive response data sent by the gateway, wherein the response data is obtained by the first backend service or the second backend service in response to the interaction request.
[0010] In one embodiment of this application, the second backend service is used to redirect from the current page of the frontend application running on the frontend device to the target page. The interaction request is a route-based redirection request, and a first service parameter is added to the redirection request through the following steps:
[0011] Obtain the first service parameter from the routing parameters in the current page;
[0012] If the routing parameters of the target page do not include the first service parameter, then the first service parameter is added to the routing parameters of the target page, and the routing parameters of the target page after adding the first service parameter are added to the redirect request.
[0013] In one embodiment of this application, the second backend service is used to redirect from the current page of the frontend application running on the frontend device to the target page. The interaction request is a redirection request based on the tag. The first service parameter is added to the redirection request through the following steps:
[0014] Obtain the first service parameter;
[0015] Listen for changes in elements within the Document Object Model (DOM) tree of the current page;
[0016] If changes occur, add the first service parameter to the redirect request.
[0017] In one embodiment of this application, the second backend service is used to process data by adding a first service parameter to the interaction request through the following steps:
[0018] Obtain the first service parameter;
[0019] Before sending the interaction request to the gateway, the first service parameter is added to the interaction request.
[0020] In a second aspect of this application, a data interaction method is also provided, applied to a gateway, the method comprising:
[0021] Receive an interaction request sent by a front-end device, the interaction request carrying a first matching parameter, the first matching parameter being used to identify the original first back-end service;
[0022] If the interaction request also carries a first service parameter, a backend service identifier is determined based on the first matching parameter and the first service parameter. A second address of the second backend service is determined based on the preset routing rule and the backend service identifier. The interaction request is then sent to the second backend service based on the second address. The first service parameter is used to identify the second backend service updated from the first backend service. The preset routing rule represents the correspondence between the backend service identifier and the address of the backend service.
[0023] If the interaction request does not carry the first service parameter, the address of the first backend service is determined according to the first matching parameter and the preset routing rule, and the interaction request is sent to the first backend service.
[0024] Send response data to the front-end device, wherein the response data is obtained by the first back-end service or the second back-end service in response to the interaction request.
[0025] In one embodiment of this application, the preset routing rule is obtained based on dynamic registration.
[0026] In one embodiment of this application, the response data includes a backend service identifier of a first backend service or a second backend service.
[0027] In a third aspect of this application, a data exchange system is also provided, the system comprising: a front-end device, a gateway, and a back-end device;
[0028] The front-end device is used to send an interaction request to the gateway. The interaction request carries a first matching parameter, which is used to identify the original first back-end service.
[0029] The gateway is configured to, when the interaction request also carries a first service parameter, determine a backend service identifier based on a first matching parameter and the first service parameter, determine a second address of a second backend service based on a preset routing rule and the backend service identifier, and send the interaction request to the second backend service based on the second address; wherein, the first service parameter is used to identify the second backend service updated from the first backend service, and the preset routing rule represents the correspondence between the backend service identifier and the address of the backend service; when the interaction request does not carry the first service parameter, determine the address of the first backend service based on the first matching parameter and the preset routing rule, and send the interaction request to the first backend service;
[0030] The backend device is configured to, upon receiving an interaction request sent by the gateway, invoke the second backend service to process the interaction request, obtain response data, and send the response data back to the gateway; or
[0031] The backend device is used to, after receiving the interaction request sent by the gateway, call the first backend service to process the interaction request, obtain response data, and send the response data to the gateway.
[0032] The gateway is also used to receive response data sent by the backend device and send the response data to the frontend device.
[0033] In a fourth aspect of this application, a data interaction device is also provided, applied to a front-end device, the device comprising:
[0034] The first sending module is used to send an interaction request to the gateway. The interaction request carries a first matching parameter, which is used to identify the original first backend service.
[0035] The second sending module is configured to, when the interaction request also carries a first service parameter, enable the gateway to determine a backend service identifier based on the first matching parameter and the first service parameter, determine a second address of a second backend service based on a preset routing rule and the backend service identifier, and send the interaction request to the second backend service based on the second address; wherein, the first service parameter is used to identify the second backend service updated from the first backend service, and the preset routing rule represents the correspondence between the backend service identifier and the address of the backend service;
[0036] The third sending module is used to, when the interaction request does not carry the first service parameter, enable the gateway to determine the address of the first backend service based on the first matching parameter and the preset routing rules, and send the interaction request to the first backend service.
[0037] The first receiving module is used to receive response data sent by the gateway, wherein the response data is obtained by the first backend service or the second backend service in response to the interaction request.
[0038] In a fifth aspect of this application, a data interaction device is also provided, applied to a gateway, the device comprising:
[0039] The second receiving module is used to receive an interaction request sent by the front-end device. The interaction request carries a first matching parameter, which is used to identify the original first back-end service.
[0040] The fourth sending module is configured to, when the interaction request also carries a first service parameter, determine a backend service identifier based on a first matching parameter and the first service parameter, determine a second address of a second backend service based on a preset routing rule and the backend service identifier, and send the interaction request to the second backend service based on the second address; wherein, the first service parameter is used to identify the second backend service updated from the first backend service, and the preset routing rule represents the correspondence between the backend service identifier and the address of the backend service;
[0041] The fifth sending module is used to determine the address of the first backend service based on the first matching parameter and the preset routing rules, and send the interaction request to the first backend service when the interaction request does not carry the first service parameter.
[0042] The sixth sending module is used to send response data to the front-end device, wherein the response data is obtained by the first back-end service or the second back-end service in response to the interaction request.
[0043] In another aspect of this application, an electronic device is also provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus.
[0044] Memory, used to store computer programs:
[0045] The processor, when executing a program stored in memory, implements any of the data interaction methods described above.
[0046] In another aspect of this application, a computer-readable storage medium is provided, wherein a computer program is stored therein, and the computer program, when executed by a processor, implements any of the data interaction methods described above.
[0047] In another aspect of this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to perform any of the data interaction methods described above.
[0048] In the technical solution provided in this application embodiment, the front-end device sends an interaction request to the gateway. The interaction request carries a first matching parameter identifying the original first back-end service. If the interaction request also carries a first service parameter identifying a newly added second back-end service, the gateway determines the back-end service identifier based on the first matching parameter and the first service parameter. Then, based on preset routing rules and the back-end service identifier, it determines the address of the second back-end service and sends the interaction request to the second back-end service. If the interaction request does not carry the first service parameter, the gateway determines the address of the first back-end service based on the first matching parameter and preset routing rules and sends the interaction request to the first back-end service. The first or second back-end service processes the interaction request, obtains response data, and sends the response data back to the front-end device through the gateway, completing the front-end and back-end data interaction process.
[0049] Since the first backend service is the original backend service, and the second backend service is a new backend service updated based on the original first backend service, in this embodiment, only the backend service with update requirements (the second backend service) is deployed separately. Backend services that have not changed are not deployed (backed up). Compared to deploying all backend services, this reduces the investment in manpower, time, and machine operation costs for service deployment. Furthermore, the original first backend service and the newly added second backend service run simultaneously. The original first backend service can provide normal original services to the frontend applications running on the frontend devices, while the newly added second backend service can support the integration and testing of new requirements. Therefore, the technical solution provided by this embodiment can reduce the investment in manpower, time, and machine operation costs for service deployment while ensuring the normal use of the original service and supporting the integration and testing of new requirements.
[0050] Furthermore, in the technical solution provided in this application embodiment, by carrying a first service parameter in the interaction request, the first service parameter is used to identify the second backend service updated from the original first backend service, so that the gateway can determine the sending object corresponding to the interaction request, i.e. the second backend service, based on the first matching parameter, ensuring that the frontend application running on the frontend device can successfully call the newly deployed backend service and realize the data interaction between the frontend and the backend. Attached Figure Description
[0051] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below.
[0052] Figure 1 A schematic diagram of a software architecture provided for an embodiment of this application;
[0053] Figure 2 Another software architecture diagram provided for an embodiment of this application;
[0054] Figure 3 This is a schematic diagram of an application scenario provided by an embodiment of this application;
[0055] Figure 4 A flowchart illustrating the first data interaction method provided in this application embodiment;
[0056] Figure 5a This is a schematic diagram of the software architecture in related technologies;
[0057] Figure 5b Another software architecture diagram provided for an embodiment of this application;
[0058] Figure 6 A schematic diagram of a front-end page provided for an embodiment of this application;
[0059] Figure 7 A flowchart illustrating the second data interaction method provided in this application embodiment;
[0060] Figure 8 This is a schematic diagram of the structure of a data interaction system provided in an embodiment of this application;
[0061] Figure 9 This is a schematic diagram of the structure of the first data interaction device provided in the embodiments of this application;
[0062] Figure 10 This is a schematic diagram of the structure of a second data interaction device provided in an embodiment of this application;
[0063] Figure 11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0064] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.
[0065] like Figure 1 As shown, Figure 1 This is a schematic diagram of a software architecture provided for an embodiment of this application. The software architecture can be abstracted as the interaction between members such as a front-end application, a back-end service, and a database. The front-end application is mainly responsible for interacting with the user and can include web pages (WEB), applications (APP), mini-programs, etc. The back-end service is responsible for processing business logic and making different responses based on different interaction requests sent by the front-end application. The database is mainly responsible for storing data.
[0066] In practical applications, a front-end application needs to call multiple back-end services to complete the interaction process. Each back-end service has its own calling address and calling method, and these addresses and methods may change, leading to increased complexity in front-end application calls to back-end services. To reduce this complexity, in... Figure 1 Based on the software architecture shown, a gateway was added between the front-end application and the back-end service. For example... Figure 2 As shown, Figure 2 This is a schematic diagram of another software architecture provided in an embodiment of this application. In this software architecture, a gateway is used as a proxy to receive all interaction requests issued by the front-end application and send the interaction requests to the corresponding back-end service, thereby reducing the complexity of the front-end application calling the back-end service.
[0067] As business requirements change, one or more of the front-end application, back-end service, and database may also change. Developers need to adjust the code logic of any one or more of these components to respond to the changes in business requirements. Meanwhile, integration testing during development and testing after development both require the support of the deployment environment. In adjusting to new business requirements, it is necessary to ensure the normal operation of the original services while also supporting integration testing and testing of the new requirements.
[0068] To ensure the continued normal operation of existing services while supporting the integration and testing of new requirements during adjustments to business needs, the relevant technologies will include... Figure 2 In this approach, all members of the software architecture are copied to the deployment environment. While this ensures the normal operation of the original service and supports the integration and testing of new requirements during the adjustment of new business needs, it requires a significant investment in manpower, time, and machine operation costs for service deployment, regardless of the amount of modification.
[0069] Will Figure 2 Copying all components of the software architecture to the deployment environment is the simplest and most direct way to solve the problem of ensuring the normal use of the original service while supporting the integration and testing of new requirements during the adjustment of new business needs. However, its disadvantages are also obvious: high cost and long time consumption. In practice, this solution also has the following problems:
[0070] (1) Scenario 1: Engineer A thinks a certain environment is idle and deploys it directly, but in fact the environment is being used by Engineer B. This will cause problems such as call exceptions and invalid tests, affecting the development work of both engineers.
[0071] (2) Scenario 2: Engineer A and Engineer B know the usage of a certain environment and take turns using it. This can reduce deployment costs, but increases communication costs.
[0072] (3) Scenario 3: Engineer A and Engineer B know the usage of a certain environment and use it together. This requires merging their development work together, which increases the risk of code merging. At the same time, the testing work will be based on the merged code, which may not be able to truly reflect the independent operation of each member in the software system architecture.
[0073] In order to ensure the normal use of the original services while supporting the joint debugging and testing of new requirements during the adjustment of new business needs, and at the same time reduce the investment in manpower, time and machine operation costs of service deployment, this application provides a data interaction method, system, device, equipment and storage medium.
[0074] First, refer to Figure 3 The application scenarios of the embodiments of this application are illustrated by way of example. Figure 3 This is a schematic diagram of an application scenario provided by an embodiment of this application.
[0075] like Figure 3 As shown, in this application scenario, when business requirements change, a new backend service needs to be updated based on backend service A, and a backend service identifier 'a' (i.e., the first service parameter) is agreed upon for the new backend service. User (or developer) 301 adjusts the code logic of backend service A using the code management tool GitLab, and deploys the new backend service Aa to the deployment environment through building and packaging, thus completing the new service deployment process. Simultaneously, the mapping between the backend service identifier of the new backend service Aa and the address of backend service Aa is dynamically registered in the preset routing rules stored on the gateway.
[0076] When user (or developer) 301 opens front-end application 302 through a front-end device, front-end application 302 obtains the corresponding static resources from the front-end server and renders the corresponding front-end application page. In response to user 301's operation on the front-end application page, front-end application 302 sends an interaction request to gateway 303. Gateway 303 determines a first back-end service (back-end service A) 304 based on the first matching parameter carried in the interaction request and sends the interaction request to the first back-end service 304. Alternatively, gateway 303 determines a second back-end service (back-end service Aa) 305 based on the first matching parameter and the first service parameter carried in the interaction request, sends the interaction request to the second back-end service 305, and sends the received response data from the first back-end service 304 or the second back-end service 305 to the front-end application 302 running on the front-end device, so that front-end application 302 responds to the user's operation.
[0077] It should be noted that, Figure 3This is merely a schematic diagram illustrating one application scenario provided by an embodiment of this application. This embodiment does not necessarily represent... Figure 3 The included equipment is not limited, nor is it restricted. Figure 3 The positional relationships and number of devices in the middle are limited.
[0078] The following combination Figure 3 Application scenarios, and Figure 4 A flowchart illustrating a data interaction method is provided, which details the data interaction method provided in this application embodiment. This data interaction method is applied to a front-end device, and the front-end application can run on the front-end device. The data interaction method includes steps S41-S44.
[0079] S41 sends an interaction request to the gateway.
[0080] The interaction request carries a first matching parameter, which identifies the original first backend service.
[0081] S42, if the interaction request also carries the first service parameter, the gateway determines the backend service identifier based on the first matching parameter and the first service parameter, determines the second address of the second backend service based on the preset routing rules and the backend service identifier, and sends the interaction request to the second backend service based on the second address.
[0082] The first service parameter is used to identify the second backend service updated from the first backend service. The preset routing rule represents the correspondence between the backend service identifier and the address of the backend service. Only when the original backend service is updated to obtain the new backend service can the original backend service and the new backend service run simultaneously. For the original backend service that has not been updated, there is no backup of the backend service.
[0083] S43, if the interaction request does not carry the first service parameter, the gateway determines the address of the first backend service based on the first matching parameter and the preset routing rules, and sends the interaction request to the first backend service.
[0084] S44 receives response data sent by the gateway.
[0085] The response data is obtained by the first or second backend service in processing the interactive request.
[0086] In the technical solution provided in this application embodiment, the front-end device sends an interaction request to the gateway. The interaction request carries a first matching parameter identifying the original first back-end service. If the interaction request also carries a first service parameter identifying a newly added second back-end service, the gateway determines the back-end service identifier based on the first matching parameter and the first service parameter. Then, based on preset routing rules and the back-end service identifier, it determines the address of the second back-end service and sends the interaction request to the second back-end service. If the interaction request does not carry the first service parameter, the gateway determines the address of the first back-end service based on the first matching parameter and preset routing rules and sends the interaction request to the first back-end service. The first or second back-end service processes the interaction request, obtains response data, and sends the response data back to the front-end device through the gateway, completing the front-end and back-end data interaction process.
[0087] Since the first backend service is the original backend service, and the second backend service is a new backend service updated based on the original first backend service, and only when the original backend service is updated to obtain the new backend service, both the original backend service and the new backend service run simultaneously. For the original backend service that has not been updated, there is no backup of that backend service. That is, in this embodiment, only the backend service with update requirements (the second backend service) is deployed separately. Backend services that have not changed are not deployed (backed up). Compared to deploying all backend services, this reduces the investment in manpower, time, and machine operation costs for service deployment. Moreover, the original first backend service and the newly added second backend service run simultaneously. The original first backend service can provide normal original services to the frontend application, while the newly added second backend service can support the integration and testing of new requirements. Therefore, the technical solution provided by this embodiment can reduce the investment in manpower, time, and machine operation costs for service deployment while ensuring the normal use of the original service and supporting the integration and testing of new requirements.
[0088] Furthermore, in the technical solution provided in this application embodiment, by carrying a first service parameter in the interaction request, the first service parameter is used to identify the second backend service updated from the original first backend service, so that the gateway can determine the sending object corresponding to the interaction request, i.e. the second backend service, based on the first matching parameter, ensuring that the frontend application can successfully call the newly deployed backend service and realize the data interaction between the frontend and the backend.
[0089] In step S41 above, the interaction request is received by the front-end device in response to the user's operation on the current page of the front-end application. The interaction request can be an operation request that processes data. For example, the interaction request can be a GET request in the Hypertext Transfer Protocol (HTTP) request, used to request the backend service to return specified page information. The interaction request can also be a jump request from the current page of the front-end application to a target page. This application embodiment does not specifically limit the type of interaction request.
[0090] In this embodiment, the interaction request carries a first matching parameter, which is used to identify the original first backend service. The concepts of original backend service and newly added backend service are relative. An original backend service refers to a backend service that exists in the software architecture and has not been updated. A newly added backend service refers to a new backend service obtained by updating the original backend service.
[0091] Matching parameters can be understood as the backend service identifier of the original backend service. For example, the matching parameter can be the service name of the backend service. The frontend device can pre-configure the mapping relationship between interaction requests and original backend services. When the frontend device responds to the user's operation on the current page of the frontend application and receives the interaction request, it determines the first backend service to be processed based on the mapping relationship between the interaction request and the original backend service, obtains the backend service identifier of the first backend service as the first matching parameter, and sends the first matching parameter in the interaction request to the gateway.
[0092] In this embodiment, the interaction request may carry other parameters besides the first matching parameter, such as a source identifier indicating the source of the interaction request. This embodiment does not specifically limit the parameters carried in the interaction request.
[0093] For ease of understanding, a specific form of an interaction request is given, but it is not intended to be limiting. For example, the interaction request could be: / api / A / get, where the Application Programming Interface (API) indicates that the interaction request is forwarded to the corresponding backend service interface, A is the service name of the first backend service, which is also the first matching parameter, and this interaction request is to call the interface of the first backend service to return the specified page information.
[0094] In step S42 above, the interaction request may also carry a first service parameter. The method by which the front-end device adds the first service parameter to the interaction request will be explained later.
[0095] As business requirements change, developers need to adjust the code logic of the original backend service to implement the new requirements. When business requirements change, the code logic of the original backend service is adjusted to create a new second backend service, which is then deployed to the environment. Simultaneously, developers pre-define the backend service identifier, or service parameter, for the newly deployed backend service. The specific format of the service parameter can be any string, as long as it avoids names frequently used in interactive requests.
[0096] In this embodiment of the application, the second backend service is a new backend service obtained by adjusting the code logic of the first backend service based on the original first backend service, and the first service parameter is used to identify the second backend service.
[0097] After the front-end device sends an interaction request to the gateway, the gateway determines whether the interaction request carries a first service parameter. Specifically, the gateway can determine whether the interaction request carries additional parameters compared to a regular interaction request. If it does, then the gateway can confirm that the interaction request carries a first service parameter. If the interaction request carries a first service parameter, the gateway determines the backend service identifier based on a first matching parameter and the first service parameter. Specifically, the gateway can concatenate the first matching parameter and the first service parameter to obtain the backend service identifier.
[0098] For example, the gateway receives the interaction request: / api / A / get? branch=a, where A is the service name of the first backend service, i.e., the first matching parameter, and a is the pre-agreed backend service identifier of the second backend service, i.e., the first service parameter. branch=a indicates that the value of the first service parameter is a. branch can also be replaced with other strings. The gateway finds that this interaction request carries the additional parameter branch=a compared to the regular interaction request: api / A / get. Therefore, it can determine that the first service parameter is a, and concatenates the first matching parameter A and the first service parameter a to obtain the backend service identifier, Aa.
[0099] Alternatively, the first service parameter can be carried in a specific field within the first service parameter.
[0100] In this embodiment, the preset routing rule represents the correspondence between backend service identifiers and backend service addresses. The gateway can be pre-configured with preset routing rules, and when a new backend service is deployed, the preset routing rule can be dynamically registered with the gateway, adding the correspondence between the newly added backend service identifier and its address to the preset routing rule. Specifically, a method interface for writing routing rules can be encapsulated and provided externally. Based on this interface, the dynamic registration of routing rules with the gateway can be achieved.
[0101] The specific form of the preset routing rules can be shown in Table 1. Referring to Table 1, it is a preset routing rule table provided in the embodiments of this application.
[0102] Table 1
[0103] Backend service identifier Backend service address A Address 1 Aa Address 2 B Address 3 … …
[0104] In addition to the above, the preset routing rules may also include other parameters, such as an identifier for each mapping relationship to identify its uniqueness, and a priority for each mapping relationship to adjust the order in which they are used. When an interaction request matches multiple mapping relationships, the mapping relationship with the highest priority is selected, and this mapping relationship is used to determine the address of the backend service. This application embodiment does not specifically limit the form of the preset routing rules.
[0105] In this embodiment, after determining the backend service identifier based on the first matching parameter and the first service parameter, the gateway matches the backend service identifier with preset routing rules to determine the second address of the second backend service. Based on the second address, the gateway sends the interaction request to the second backend service. Here, the address of the second backend service can be its interface address, path address, etc. The second backend service is a new service modified based on the first backend service in response to changes in requirements. Therefore, the second backend service can both provide the modified service to the frontend application and enable joint debugging and testing of the modified service.
[0106] In this embodiment, when a new backend service is obtained by updating the original backend service, both the original and new backend services run concurrently. There is no backup for the original backend service that has not been updated; that is, only the changed backend service is deployed separately, and the unchanged backend service is not redeployed. This reduces deployment costs. Furthermore, the original and new backend services run simultaneously. The original backend service can provide normal original services to the frontend application, while the newly added second backend service can support integration testing and debugging of new requirements.
[0107] In step S44 above, since the first matching parameter is used to identify the original first backend service (i.e., the first matching parameter is the backend service identifier of the first backend service), after the frontend device sends an interaction request to the gateway, if the gateway determines that the interaction request does not carry the first service parameter, it directly matches the first matching parameter with the preset routing rules to determine the address of the first backend service. Based on the address of the first backend service, it sends an interaction request to the first backend service. Since the first backend service is the original backend service, it can provide the original service to the frontend application.
[0108] In one embodiment of this application, when an interaction request carries both a first matching parameter and a first service parameter, but a new second backend service has not yet been deployed, since the second backend service has not been deployed, there will be no correspondence between the backend service identifier and the second address of the second backend service in the preset routing rules. After the gateway determines the backend service identifier based on the first matching parameter and the first service parameter, it cannot determine the second address of the second backend service based on the backend service identifier in the preset routing rules. In this case, the gateway will not discard the interaction request, but will only match the first matching parameter with the preset routing rules to determine the first address of the first backend service, and then send the interaction request to the first backend service. This avoids the situation where the gateway directly discards the interaction request, causing the frontend application to be unable to receive response data.
[0109] Below, to facilitate understanding of the difference between deploying the modified backend service separately in this embodiment of the application and repeatedly deploying all members of the software architecture in related technologies, we will combine... Figure 2 , Figure 5a and Figure 5b To illustrate the differences between the embodiments of this application and related technologies, Figure 5a and Figure 5b The database portion of the software architecture is not shown.
[0110] from Figure 2 As can be seen, there are N backend services in the software architecture, namely backend service A, backend service B, ..., backend service N. When backend service A changes, for example, if backend service A originally provided the service of reading and writing MySQL tables, a read and write caching service needs to be added.
[0111] Solutions in related technologies, such as Figure 5aAs shown, based on backend service A, the code logic of backend service A is adjusted to obtain backend service Aa. Simultaneously, other members of the software architecture—namely, the frontend application, gateway, backend service B…backend service N—are copied and deployed to the newly built deployment environment 2. Here, / api / A / **, / api / Aa / **, / api / B / **, and / api / N / ** represent a form of interactive request. `api` indicates that the interactive request is forwarded to the corresponding backend service's interface address. A, Aa, B, and N are the service identifiers of the backend services, and `**` indicates the request type, which can be GET, POST, etc. The software architecture in deployment environment 1 provides the original services, while the software architecture in deployment environment 2 provides the new services and tests for the new services. Thus, regardless of the number of service changes, a significant investment is required in the manpower, time, and machine operation costs of service deployment.
[0112] The technical solutions provided in the embodiments of this application are as follows: Figure 5b As shown, based on backend service A, a new backend service Aa is obtained, and the newly built backend service Aa is deployed to the existing deployment environment. Here, / api / A / **, / api / B / **, and / api / N / ** represent the interaction request format carrying only the first matching parameter, while / api / A / **? branch=a represents the interaction request format carrying both the first matching parameter and the first service parameter. The original backend service can provide the original service to the frontend application, and the newly deployed backend service can provide the new service to the frontend application, as well as test the new service. In this way, a single point of deployment is achieved for the changed backend service, reducing the investment in manpower, time, and machine operation costs for service deployment.
[0113] In step S44 above, after the gateway sends the interaction request to the first backend service or the second backend service, the first backend service or the second backend service processes the interaction request according to its own processing logic, generates response data, sends the response data to the gateway, and the gateway then returns the response data to the frontend device.
[0114] For example, if the interaction request is to refresh the weather information, the first backend service receives the interaction request, obtains the weather information, carries the weather information in the response data, and sends it to the frontend device through the gateway. The frontend device then renders the current page of the frontend application based on the response data and displays the latest weather information on the current page.
[0115] For example, an interaction request might be a jump request from the current page of the front-end application to the news page. After receiving the interaction request, the first back-end service obtains the rendering data of the news page, carries the rendering data of the news page in the response data, and sends it to the front-end device through the gateway. The front-end device then renders the current page of the front-end application based on the response data, and jumps from the current page to the news page.
[0116] In one embodiment of this application, the response data obtained by the first backend service in processing the interaction request may further include a backend service identifier of the first backend service. Similarly, the response data obtained by the second backend service in processing the interaction request may further include a backend service identifier of the second backend service. In this way, after receiving the response data, the frontend device can perceive which backend service is currently responding and accurately determine whether the interaction request has reached the backend service as expected.
[0117] The following describes an embodiment in which the front-end device adds a first service parameter to the interaction request.
[0118] In one embodiment of this application, the second backend service is used to jump from the current page of the frontend application to the target page. The interaction request is a jump request based on route jump, and the first service parameter can be added to the jump request through the following steps one to two.
[0119] Step 1: Obtain the first service parameter from the routing parameters on the current page.
[0120] In this embodiment of the application, the front-end application running on the front-end device can use the functions provided by the front-end framework to implement route jump, that is, jump from the current page of the front-end application to the target page that the user expects to jump to.
[0121] The routing parameter for the current page is its path address. The path address of the current page in the front-end application typically comes from the system menu configuration or is entered by the user in the browser. Since the first service parameter is pre-defined after the new back-end service is deployed, the front-end device can modify the system menu configuration of the front-end application to add the first service parameter to the address in the system menu configuration, or the first service parameter can be added when the user enters the path address in the browser's search bar. It should be noted that whether the current page's path address carries the first service parameter does not affect the rendering of the current page in the front-end application.
[0122] For example, if the current page path of the front-end application is http: / / host / page, then the front-end application can modify the system menu configuration to: http: / / host / page?branch=xxx, where xxx is a pre-defined first service parameter. Alternatively, the user can manually enter the pre-defined first service parameter after the current page path in the browser's search bar.
[0123] At this point, the routing parameters of the current page of the front-end application will carry the first service parameter, and the front-end device can extract the first service parameter from the routing parameters of the current page of the front-end application.
[0124] Step 2: If the target page's routing parameters do not include the first service parameter, then add the first service parameter to the target page's routing parameters and add the target page's routing parameters after adding the first service parameter to the redirect request.
[0125] In this embodiment, before the front-end application navigates from the current page to the target page, the front-end device can monitor the routing parameters of the current page and the target page. If a first service parameter exists in the routing parameters before the navigation and does not exist in the target page, the first service parameter is added to the routing parameters of the target page, and the routing parameters of the target page with the added first service parameter are added to the navigation request. Specifically, the first service parameter can be added to the routing parameters of the target page using route parameter passing.
[0126] For example, taking vue-router as an example, vue-router is a front-end framework that provides functionality for route navigation. For declarative routing, the front-end application listens to the route parameters of the current page and the target page before navigation. If the current page's route parameters contain a first service parameter but the target page's route parameters do not, the first service parameter will be added to the target page's route parameters. Specifically, the following command can be used to add the first service parameter xxx to the target page's route parameters:<router-link:to="{path:'home',params:{branch:xxx}}"> .
[0127] For programmatic routing, there are three main APIs: this.$router.push, this.$router.replace, and this.$router.replace. When the target page's route parameters do not include the first service parameter, the first two APIs can call their own encapsulated functions to add the first service parameter to the target page's route parameters. The third API requires manual configuration of the function to add the first service parameter to the target page's route parameters.
[0128] In this embodiment of the application, to differentiate it from scenarios where the interaction request does not carry a first service parameter, a friendly reminder is added to the current page of the front-end application, such as... Figure 6 As shown, when the interaction request contains a first service parameter, the current page of the front-end application will display a prominent prompt to indicate that the current interaction request carries a first service parameter. It should be noted that... Figure 6 The friendly reminders shown are for illustrative purposes only, and the specific form of the friendly reminders is not limited in the embodiments of this application.
[0129] In the technical solution provided in this application embodiment, by adding a first service parameter to the interaction request, the first service parameter can be transmitted to the gateway. Then, the gateway can determine the second backend service corresponding to the interaction request based on the first service parameter, ensuring that the frontend application can successfully call the newly deployed second backend service.
[0130] In one embodiment of this application, the second backend service is used to jump from the current page of the frontend application to the target page. The interaction request is a jump request based on the a tag. The first service parameter can be added to the jump request through the following steps three to five.
[0131] Step 3: Obtain the first service parameters.
[0132] In this embodiment, the front-end application can use `` tags to navigate from its current page to a target page. The path address of the current page is typically derived from the system menu configuration or user input in the browser. Since the first service parameter is pre-defined after the new back-end service is deployed, the front-end device can modify the front-end application's system menu configuration, adding the first service parameter to the address configured in the system menu, or adding it when the user enters the path address in the browser's search bar. Therefore, the front-end device can obtain the first service parameter from the address of the current page of the front-end application.
[0133] Step 4: Monitor changes in elements within the Document Object Model (DOM) tree of the current page;
[0134] Step 5: If changes occur, add the first service parameter to the redirect request.
[0135] The Document Object Model (DOM) tree of a webpage is a tree-structured document model that constructs a hierarchical system of nodes. The DOM tree typically consists of a root node, element nodes, text nodes, and attribute nodes. When a front-end application loads a page, it reads the Hypertext Markup Language (HTML) document, parses each tag, and converts it into a node on the DOM tree. This is the process of building the page's DOM tree.
[0136] In this embodiment of the application, the front-end application listens for changes in the elements of the DOM tree of the current page. When an element in the DOM tree changes, it indicates that the current page needs to be redirected, so the first change parameter is added to the redirect request.
[0137] Specifically, front-end applications can call the MutationObserve API to monitor changes in the entire DOM tree of the current page. Considering the complexity of the page, monitoring the entire DOM tree would increase performance overhead. Therefore, it's better to only monitor the DOM elements containing a specific class, thus saving performance. For example, the front-end application can only monitor the DOM elements containing the el-table (table component) class to save performance.
[0138] In the technical solution provided in this application embodiment, by adding a first service parameter to the interaction request, the first service parameter can be transmitted to the gateway. Then, the gateway can determine the second backend service corresponding to the interaction request based on the first service parameter, ensuring that the frontend application can successfully call the newly deployed second backend service.
[0139] In one embodiment of this application, the second backend service is used to process data, and the interaction request is an operation request for processing data. The first service parameter is added to the operation request through the following steps six to seven.
[0140] Step 6: Obtain the first service parameters.
[0141] For details on how this step is implemented, please refer to the description of this step above.
[0142] Step 7: Before sending the interaction request to the gateway, add the first service parameter to the interaction request.
[0143] In this embodiment of the application, before the front-end device sends an interaction request to the gateway, it obtains the first service parameter from the path address of the current page of the front-end application, and then adds the first service parameter to the interaction request.
[0144] Specifically, front-end applications can set up request interceptors based on Axios to add a first service parameter to the interaction request before the front-end application sends the interaction request to the gateway. Axios is a promise-based HTTP library with functions such as intercepting requests and responses, and transforming request and response data.
[0145] In the technical solution provided in this application embodiment, by adding a first service parameter to the interaction request, the first service parameter can be transmitted to the gateway. Then, the gateway can determine the second backend service corresponding to the interaction request based on the first service parameter, ensuring that the frontend application can successfully call the newly deployed second backend service.
[0146] Based on the same inventive concept, embodiments of this application also provide a data interaction method, such as... Figure 7 As shown, the method is applied to a gateway with reverse proxy capabilities, and the method includes steps S71-S74.
[0147] S71 receives interaction requests sent by the front-end device.
[0148] The interaction request carries a first matching parameter, which identifies the original first backend service.
[0149] S72, if the interaction request also carries the first service parameter, determine the backend service identifier according to the first matching parameter and the first service parameter, determine the second address of the second backend service according to the preset routing rules and the backend service identifier, and send the interaction request to the second backend service according to the second address.
[0150] The first service parameter is used to identify the second backend service updated from the first backend service. The preset routing rule represents the correspondence between the backend service identifier and the address of the backend service. Only when the original backend service is updated to obtain the new backend service can the original backend service and the new backend service run simultaneously. For the original backend service that has not been updated, there is no backup of the backend service.
[0151] S73, if the interaction request does not carry the first service parameter, determine the address of the first backend service according to the first matching parameter and the preset routing rules, and send the interaction request to the first backend service;
[0152] S74 sends response data to the front-end device.
[0153] The response data is obtained by the first or second backend service in processing the interactive request.
[0154] For a detailed description of steps S71-S74, please refer to the relevant descriptions of steps S41-S44 above.
[0155] In the technical solution provided in this application embodiment, the front-end device sends an interaction request to the gateway. The interaction request carries a first matching parameter identifying the original first back-end service. If the interaction request also carries a first service parameter identifying a newly added second back-end service, the gateway determines the back-end service identifier based on the first matching parameter and the first service parameter. Then, based on preset routing rules and the back-end service identifier, it determines the address of the second back-end service and sends the interaction request to the second back-end service. If the interaction request does not carry the first service parameter, the gateway determines the address of the first back-end service based on the first matching parameter and preset routing rules and sends the interaction request to the first back-end service. The first or second back-end service processes the interaction request, obtains response data, and sends the response data back to the front-end device through the gateway, completing the front-end and back-end data interaction process.
[0156] Since the first backend service is the original backend service, and the second backend service is a new backend service updated based on the original first backend service, and only when the original backend service is updated to obtain the new backend service, both the original backend service and the new backend service run simultaneously. For the original backend service that has not been updated, there is no backup of that backend service. That is, in this embodiment, only the backend service with update requirements (the second backend service) is deployed separately. Backend services that have not changed are not deployed (backed up). Compared to deploying all backend services, this reduces the investment in manpower, time, and machine operation costs for service deployment. Moreover, the original first backend service and the newly added second backend service run simultaneously. The original first backend service can provide normal original services to the frontend application, while the newly added second backend service can support the integration and testing of new requirements. Therefore, the technical solution provided by this embodiment can reduce the investment in manpower, time, and machine operation costs for service deployment while ensuring the normal use of the original service and supporting the integration and testing of new requirements.
[0157] Furthermore, in the technical solution provided in this application embodiment, by carrying a first service parameter in the interaction request, the first service parameter is used to identify the second backend service updated from the original first backend service, so that the gateway can determine the sending object corresponding to the interaction request, i.e. the second backend service, based on the first matching parameter, ensuring that the frontend application can successfully call the newly deployed backend service and realize the data interaction between the frontend and the backend.
[0158] Based on the same inventive concept, embodiments of this application also provide a data exchange system, such as... Figure 8As shown, the system includes: a front-end device 81, a gateway 82, and a back-end device 83. The back-end device can specifically be a back-end server, and the back-end device can run and call one or more back-end services.
[0159] Front-end device 81 is used to send an interaction request to the gateway. The interaction request carries a first matching parameter, which identifies the original first back-end service.
[0160] Gateway 82 is used to determine the backend service identifier based on the first matching parameter and the first service parameter when the interaction request still carries the first service parameter, determine the second address of the second backend service based on the preset routing rule and the backend service identifier, and send the interaction request to the second backend service based on the second address; wherein, the first service parameter is used to identify the second backend service updated based on the first backend service, and the preset routing rule represents the correspondence between the backend service identifier and the address of the backend service; when the interaction request does not carry the first service parameter, it determines the address of the first backend service based on the first matching parameter and the preset routing rule, and sends the interaction request to the first backend service.
[0161] Backend device 83 is used to, upon receiving an interaction request sent by the gateway, invoke the second backend service to process the interaction request, obtain response data, and send the response data back to the gateway; or
[0162] Backend device 83 is used to call the first backend service to process the interaction request after receiving the interaction request sent by the gateway, obtain response data, and send the response data back to the gateway.
[0163] Gateway 82 is also used to receive response data sent by the backend device and send response data to the frontend device.
[0164] Based on the same inventive concept, embodiments of this application also provide a data interaction device, applied to a front-end device, such as... Figure 9 As shown, the device includes:
[0165] The first sending module 91 is used to send an interaction request to the gateway. The interaction request carries a first matching parameter, which identifies the original first backend service.
[0166] The second sending module 92 is configured to, when the interaction request also carries a first service parameter, cause the gateway to determine a backend service identifier based on the first matching parameter and the first service parameter, determine a second address of a second backend service based on a preset routing rule and the backend service identifier, and send the interaction request to the second backend service based on the second address; wherein, the first service parameter is used to identify the second backend service updated from the first backend service, and the preset routing rule represents the correspondence between the backend service identifier and the address of the backend service;
[0167] The third sending module 93 is used to, when the interaction request does not carry the first service parameter, enable the gateway to determine the address of the first backend service based on the first matching parameter and the preset routing rules, and send the interaction request to the first backend service.
[0168] The first receiving module 94 is used to receive response data sent by the gateway, wherein the response data is obtained by the first backend service or the second backend service in response to the interaction request.
[0169] Optionally, the second backend service is used to jump from the current page of the frontend application running on the frontend device to the target page, and the interaction request is a jump request based on route jump. The device may also include an adding module.
[0170] The adding module is used to obtain the first service parameter from the routing parameters of the current page; if the routing parameters of the target page do not include the first service parameter, then the first service parameter is added to the routing parameters of the target page, and the routing parameters of the target page after adding the first service parameter are added to the redirect request.
[0171] Optionally, the second backend service is used to jump from the current page of the frontend application running on the frontend device to the target page, and the interaction request is a jump request based on the a tag.
[0172] The adding module is used to obtain the first service parameter; monitor changes in elements in the document object model (DOM) tree of the current page; and if a change occurs, add the first service parameter to the redirect request.
[0173] Optionally, the second backend service is used to process the data.
[0174] The adding module is used to obtain the first service parameter; and to add the first service parameter to the interaction request before sending the interaction request to the gateway.
[0175] Based on the same inventive concept, embodiments of this application also provide a data interaction device applied to a gateway, such as... Figure 10 As shown, the device includes:
[0176] The second receiving module 101 is used to receive an interaction request sent by the front-end device. The interaction request carries a first matching parameter, which identifies the original first back-end service.
[0177] The fourth sending module 102 is configured to, when the interaction request also carries a first service parameter, determine a backend service identifier based on a first matching parameter and the first service parameter, determine a second address of a second backend service based on a preset routing rule and the backend service identifier, and send the interaction request to the second backend service based on the second address; wherein, the first service parameter is used to identify the second backend service updated from the first backend service, and the preset routing rule represents the correspondence between the backend service identifier and the address of the backend service;
[0178] The fifth sending module 103 is used to determine the address of the first backend service based on the first matching parameter and the preset routing rule, and send the interaction request to the first backend service when the interaction request does not carry the first service parameter.
[0179] The sixth sending module 104 is used to send response data to the front-end device, wherein the response data is obtained by the first back-end service or the second back-end service in response to the interaction request.
[0180] Optionally, the preset routing rules are obtained based on dynamic registration.
[0181] Optionally, the response data includes the service identifier of the first backend service or the second backend service.
[0182] In the technical solution provided in this application embodiment, the front-end device sends an interaction request to the gateway. The interaction request carries a first matching parameter identifying the original first back-end service. If the interaction request also carries a first service parameter identifying a newly added second back-end service, the gateway determines the back-end service identifier based on the first matching parameter and the first service parameter. Then, based on preset routing rules and the back-end service identifier, it determines the address of the second back-end service and sends the interaction request to the second back-end service. If the interaction request does not carry the first service parameter, the gateway determines the address of the first back-end service based on the first matching parameter and preset routing rules and sends the interaction request to the first back-end service. The first or second back-end service processes the interaction request, obtains response data, and sends the response data back to the front-end device through the gateway, completing the front-end and back-end data interaction process.
[0183] Since the first backend service is the original backend service, and the second backend service is a new backend service updated based on the original first backend service, and only when the original backend service is updated to obtain the new backend service, both the original backend service and the new backend service run simultaneously. For the original backend service that has not been updated, there is no backup of that backend service. That is, in this embodiment, only the backend service with update requirements (the second backend service) is deployed separately. Backend services that have not changed are not deployed (backed up). Compared to deploying all backend services, this reduces the investment in manpower, time, and machine operation costs for service deployment. Moreover, the original first backend service and the newly added second backend service run simultaneously. The original first backend service can provide normal original services to the frontend applications running on the frontend devices, while the newly added second backend service can support the integration and testing of new requirements. Therefore, the technical solution provided by this embodiment can reduce the investment in manpower, time, and machine operation costs for service deployment while ensuring the normal use of the original service and supporting the integration and testing of new requirements.
[0184] Furthermore, in the technical solution provided in this application embodiment, by carrying a first service parameter in the interaction request, the first service parameter is used to identify the second backend service updated from the original first backend service, so that the gateway can determine the sending object corresponding to the interaction request, i.e. the second backend service, based on the first matching parameter, ensuring that the frontend application can successfully call the newly deployed backend service and realize the data interaction between the frontend and the backend.
[0185] This application also provides an electronic device, such as... Figure 11 As shown, it includes a processor 111, a communication interface 112, a memory 113, and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114.
[0186] Memory 113 is used to store computer programs;
[0187] The processor 111, when executing the program stored in the memory 113, implements any of the above-mentioned data interaction methods.
[0188] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.
[0189] The communication interface is used for communication between the aforementioned terminal and other devices.
[0190] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.
[0191] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0192] In another embodiment provided in this application, a computer-readable storage medium is also provided, wherein a computer program is stored therein, and when the computer program is executed by a processor, it implements any of the data interaction methods described in the above embodiments.
[0193] In another embodiment provided in this application, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to perform any of the data interaction methods described in the above embodiments.
[0194] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).
[0195] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0196] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments, device embodiments, electronic device embodiments, and computer storage medium embodiments are basically similar to the method embodiments, so the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.
[0197] The above description is merely a preferred embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application are included within the scope of protection of this application.
Claims
1. A data interaction method, characterized in that, Applied to a front-end device, the method includes: Send an interaction request to the gateway, the interaction request carrying a first matching parameter, the first matching parameter being used to identify the original first backend service; If the interaction request also carries a first service parameter, the gateway determines the backend service identifier based on the first matching parameter and the first service parameter, determines the second address of the second backend service based on the preset routing rule and the backend service identifier, and sends the interaction request to the second backend service based on the second address; wherein, the first service parameter is used to identify the second backend service updated from the first backend service, and the preset routing rule represents the correspondence between the backend service identifier and the address of the backend service; If the interaction request does not carry the first service parameter, the gateway determines the address of the first backend service based on the first matching parameter and the preset routing rules, and sends the interaction request to the first backend service. Receive response data sent by the gateway, wherein the response data is obtained by the first backend service or the second backend service in response to the interaction request.
2. The method according to claim 1, characterized in that, The second backend service is used to redirect from the current page of the frontend application running on the frontend device to the target page. The interaction request is a route-based redirection request, and the first service parameter is added to the redirection request through the following steps: Obtain the first service parameter from the routing parameters in the current page; If the routing parameters of the target page do not include the first service parameter, then the first service parameter is added to the routing parameters of the target page, and the routing parameters of the target page after adding the first service parameter are added to the redirect request.
3. The method according to claim 1, characterized in that, The second backend service is used to redirect from the current page of the frontend application running on the frontend device to the target page. The interaction request is a redirection request based on the tag. The first service parameter is added to the redirection request through the following steps: Obtain the first service parameter; Listen for changes in elements within the Document Object Model (DOM) tree of the current page; If changes occur, add the first service parameter to the redirect request.
4. The method according to claim 1, characterized in that, The second backend service is used to process the data, and adds the first service parameter to the interaction request through the following steps: Obtain the first service parameter; Before sending the interaction request to the gateway, the first service parameter is added to the interaction request.
5. A data interaction method, characterized in that, Applied to a gateway, the method includes: Receive an interaction request sent by a front-end device, the interaction request carrying a first matching parameter, the first matching parameter being used to identify the original first back-end service; If the interaction request also carries a first service parameter, a backend service identifier is determined based on the first matching parameter and the first service parameter. A second address of the second backend service is determined based on the preset routing rule and the backend service identifier. The interaction request is then sent to the second backend service based on the second address. The first service parameter is used to identify the second backend service updated from the first backend service. The preset routing rule represents the correspondence between the backend service identifier and the address of the backend service. If the interaction request does not carry the first service parameter, the address of the first backend service is determined according to the first matching parameter and the preset routing rule, and the interaction request is sent to the first backend service. Send response data to the front-end device, wherein the response data is obtained by the first back-end service or the second back-end service in response to the interaction request.
6. The method according to claim 5, characterized in that, The preset routing rules are obtained based on dynamic registration.
7. The method according to claim 5 or 6, characterized in that, The response data includes the backend service identifier of the first backend service or the second backend service.
8. A data exchange system, characterized in that, The system includes: front-end devices, gateways, and back-end devices; The front-end device is used to send an interaction request to the gateway. The interaction request carries a first matching parameter, which is used to identify the original first back-end service. The gateway is configured to, when the interaction request also carries a first service parameter, determine a backend service identifier based on a first matching parameter and the first service parameter, determine a second address of a second backend service based on a preset routing rule and the backend service identifier, and send the interaction request to the second backend service based on the second address; wherein, the first service parameter is used to identify the second backend service updated from the first backend service, and the preset routing rule represents the correspondence between the backend service identifier and the address of the backend service; when the interaction request does not carry the first service parameter, determine the address of the first backend service based on the first matching parameter and the preset routing rule, and send the interaction request to the first backend service; The backend device is configured to, upon receiving an interaction request sent by the gateway, invoke the second backend service to process the interaction request, obtain response data, and send the response data back to the gateway; or The backend device is used to, after receiving the interaction request sent by the gateway, call the first backend service to process the interaction request, obtain response data, and send the response data to the gateway. The gateway is also configured to receive response data sent by the backend device and send the response data to the frontend device.
9. A data interaction device, characterized in that, Applied to a front-end device, the device includes: The first sending module is used to send an interaction request to the gateway. The interaction request carries a first matching parameter, which is used to identify the original first backend service. The second sending module is configured to, when the interaction request also carries a first service parameter, enable the gateway to determine a backend service identifier based on the first matching parameter and the first service parameter, determine a second address of a second backend service based on a preset routing rule and the backend service identifier, and send the interaction request to the second backend service based on the second address; wherein, the first service parameter is used to identify the second backend service updated from the first backend service, and the preset routing rule represents the correspondence between the backend service identifier and the address of the backend service; The third sending module is used to, when the interaction request does not carry the first service parameter, enable the gateway to determine the address of the first backend service based on the first matching parameter and the preset routing rules, and send the interaction request to the first backend service. The first receiving module is used to receive response data sent by the gateway, wherein the response data is obtained by the first backend service or the second backend service in response to the interaction request.
10. A data interaction device, characterized in that, Applied to a gateway, the device includes: The second receiving module is used to receive an interaction request sent by the front-end device. The interaction request carries a first matching parameter, which is used to identify the original first back-end service. The fourth sending module is configured to, when the interaction request also carries a first service parameter, determine a backend service identifier based on a first matching parameter and the first service parameter, determine a second address of a second backend service based on a preset routing rule and the backend service identifier, and send the interaction request to the second backend service based on the second address; wherein, the first service parameter is used to identify the second backend service updated from the first backend service, and the preset routing rule represents the correspondence between the backend service identifier and the address of the backend service; The fifth sending module is used to determine the address of the first backend service based on the first matching parameter and the preset routing rules, and send the interaction request to the first backend service when the interaction request does not carry the first service parameter. The sixth sending module is used to send response data to the front-end device, wherein the response data is obtained by the first back-end service or the second back-end service in response to the interaction request.
11. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus. The processor, communication interface, and memory communicate with each other through the communication bus. Memory, used to store computer programs: A processor, when executing a program stored in memory, implements the steps of the method described in any one of claims 1-4 or 5-7.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method described in any one of claims 1-4 or 5-7.
Citation Information
Patent Citations
Gray release method, application server and gray release system
CN113014651A
Service access method and device, gateway equipment and storage medium
CN113472831A