Traffic switching method, device and storage medium
Through dynamic matching and execution of traffic switching rules, the problem of insufficient flexibility in the application system in the prior art is solved, and the flexibility and security of traffic are realized, ensuring the reliability and controllability of services.
Patent Information
- Application Number
- CN202210120152.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-07
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2042-02-07
AI Technical Summary
The existing technology lacks flexibility when applying system traffic switching, and cannot perform differentiation and gradual traffic switching according to specific needs, which may lead to excessive pressure on the new system or unreliable service.
By listening and intercepting service requests from the application system, dynamically match input parameters and preset parameters, performing preset traffic switching rules, including forwarding requests to one or more application systems for processing, and adjusting the switching mode in the switch state, ensuring that Flexibility and reliability of traffic.
It improves the flexibility and security of traffic switching, realizes differentiated and gradual switching of traffic, avoids excessive pressure on the new system, and ensures the reliability and controllability of services.
Smart Images

Figure CN114465960B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a flow switching method, device and storage medium. Background Art
[0002] In the process of providing services by the application system, when the application system needs to be replaced, the traffic needs to be switched from the original platform to the target platform. In the related art, the application system implements the switching of all traffic through fixed parameter configuration according to business needs. Summary of the invention
[0003] One object of the present disclosure is to improve the flexibility of traffic switching.
[0004] According to one aspect of some embodiments of the present disclosure, a traffic switching method is proposed, including: listening to and intercepting a service request for calling a first application system to obtain a pending request; matching preset parameters according to input parameters of the pending request; when the input parameters of the pending request successfully match the preset parameters, obtaining and executing preset traffic switching rules, wherein the forwarding object of the pending request in the preset traffic switching rules includes a second application system; when the input parameters of the pending request fail to match the preset parameters, sending the pending request to the first application system for processing.
[0005] In some embodiments, the method further includes: after intercepting the traffic calling the first application system, obtaining the state of the switch corresponding to the request to be processed; when the state of the switch is a matching switch, performing an operation of matching preset parameters according to the input parameters of the request to be processed.
[0006] In some embodiments, the method further includes at least one of the following: when the switch is in a fully switched state, forwarding the pending request to the second application system for processing; or when the switch is in a closed state, sending the pending request to the first application system for processing.
[0007] In some embodiments, matching preset parameters according to input parameters of the request to be processed includes: dynamically collecting input parameters of the request to be processed through dynamic reflection technology, and matching the collected input parameters with preset parameters.
[0008] In some embodiments, monitoring and intercepting the service request for calling the first application system to obtain the pending request includes: monitoring the interface of the first application system to determine the service request for calling the interface; intercepting the service request for calling the interface as the pending request.
[0009] In some embodiments, forwarding the pending request to at least one of the first application system and the second application system for processing according to the traffic switching rules includes: performing format conversion on the input parameters of the pending request according to the input parameter format of the first application system and the second application system to obtain the converted input parameters; forwarding the pending request to the corresponding application system based on the traffic switching rules according to at least one of the input parameters of the pending request and the converted input parameters, and the application systems include the first application system and the second application system.
[0010] In some embodiments, the preset traffic switching rule includes: sending the pending request to the second application system for processing.
[0011] In some embodiments, the preset traffic switching rule includes: sending the pending request to the first application system and the second application system for processing.
[0012] In some embodiments, the preset traffic switching rules include: sending the pending request to the second application system for processing; if the second application system fails to process, sending the pending request to the first application system for processing, and the processing result of the pending request is the output result of the first application system.
[0013] In some embodiments, the preset traffic switching rules include: sending the pending request to the first application system and the second application system for processing respectively, and comparing the output results of the first application system with the second application system to determine whether the output results of the first application system and the second application system are the same.
[0014] In some embodiments, monitoring and intercepting the service request of the first application system to obtain the request to be processed includes: monitoring the message queue of the service request of the first application system; intercepting the service request in the message queue to obtain the request to be processed.
[0015] In some embodiments, the method further includes: monitoring a message queue of a service request of the second application system, intercepting the service request in the message queue, obtaining pending requests, and performing an operation of matching preset parameters according to input parameters of the pending requests.
[0016] In some embodiments, the preset traffic switching rule includes: forwarding the pending request to the second application system for processing.
[0017] In some embodiments, obtaining pending requests includes: determining whether the message queue to which the intercepted service request belongs belongs to the traffic switching range; if the service request belongs to the traffic switching range, treating the service request as a pending request; if the service request does not belong to the traffic switching range, exiting the traffic switching operation on the service request.
[0018] According to one aspect of some embodiments of the present disclosure, a traffic switching device is proposed, including: a request acquisition unit, configured to listen to and intercept service requests that call a first application system, and obtain pending requests; a matching unit, configured as the first application system; a diversion unit, configured to, when the input parameters of the pending request successfully match the preset parameters, obtain and execute preset traffic switching rules, wherein the forwarding object of the pending request in the preset traffic switching rules includes the second application system; when the input parameters of the pending request fail to match the preset parameters, the pending request is sent to the first application system for processing.
[0019] In some embodiments, the device also includes: a state determination unit, which is configured to obtain the state of the switch corresponding to the pending request after the request acquisition unit intercepts the traffic calling the first application system; when the state of the switch is a matching switch, trigger the matching unit to perform an operation; when the state of the switch is a full switch, forward the pending request to the second application system for processing; or when the state of the switch is closed, send the pending request to the first application system for processing.
[0020] In some embodiments, the request acquisition unit is configured to: monitor the interface of the first application system, determine the service request for calling the interface, intercept the service request for calling the interface, and acquire the request to be processed.
[0021] In some embodiments, the request acquisition unit is configured to: monitor the message queue of the service request of the first application system, intercept the service request in the message queue, and acquire the request to be processed.
[0022] According to one aspect of some embodiments of the present disclosure, a flow switching device is proposed, comprising: a memory; and a processor coupled to the memory, wherein the processor is configured to execute any one of the flow switching methods described above based on instructions stored in the memory.
[0023] According to one aspect of some embodiments of the present disclosure, a computer-readable storage medium is provided, on which computer program instructions are stored, and when the instructions are executed by a processor, the steps of any one of the above traffic switching methods are implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The drawings described herein are used to provide a further understanding of the present disclosure and constitute a part of the present disclosure. The illustrative embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation on the present disclosure. In the drawings:
[0025] Figure 1 The flowcharts are of some embodiments of the traffic switching method disclosed in the present invention.
[0026] Figure 2Flow charts of other embodiments of the traffic switching method disclosed in the present invention.
[0027] Figure 3 Flowcharts of some further embodiments of the traffic switching method disclosed herein.
[0028] Figure 4 Flowcharts of some further embodiments of the traffic switching method disclosed herein.
[0029] Figure 5 The present invention is a flowchart of the configuration and operation process of the traffic switching method disclosed in the present invention.
[0030] Figure 6 Schematic diagrams of some embodiments of the flow switching device disclosed in the present invention.
[0031] Figure 7 Schematic diagrams of other embodiments of the flow switching device disclosed in the present invention.
[0032] Figure 8 Schematic diagrams of some further embodiments of the flow switching device disclosed herein. DETAILED DESCRIPTION
[0033] The technical solution of the present disclosure is further described in detail below through the accompanying drawings and embodiments.
[0034] The flow charts of some embodiments of the flow switching method disclosed in the present invention are as follows: Figure 1 As shown in the figure, taking a service request in the traffic as an example, the following steps are performed based on the traffic switching method.
[0035] In step 110, the service request for calling the first application system is monitored and intercepted to obtain the request to be processed. The first application system is a system that processes the current traffic, and the service request may include at least one of calling the first application system API (Application Programming Interface) and a request in MQ (Message Queue).
[0036] In step 130, preset parameters are matched according to input parameters of the pending request. In some embodiments, the input parameters of the pending request may include one or more of the operator name, store code, product code, etc. The preset parameters may include parameter values for executing traffic switching. By performing a parameter matching operation, it can be determined whether the current pending request is within the flow switching range, thereby realizing the ability to control the flow switching percentage.
[0037] In some embodiments, reflection technology may be used to recursively collect input parameters of requests to be processed, and then match the input parameters with preset parameters through a circular matching method.
[0038] In some embodiments, preset parameters can be stored in a distributed unified configuration center to ensure configuration consistency and flexibility.
[0039] In step 140, when the input parameters of the pending request successfully match the preset parameters, the preset traffic switching rule is obtained and executed. The forwarding object of the pending request in the preset traffic switching rule includes the second application system, so that the pending request is processed by the second application system.
[0040] In some embodiments, the traffic switching rule is to send the pending requests to the first and second application systems synchronously, and the first and second application systems output the processing results respectively, thereby ensuring the normal operation of the service while implementing the processing test of the second application system.
[0041] In some embodiments, the traffic switching rule is to send the pending request to the first application system and the second application system for separate processing, and the first and second application systems output the processing results respectively; and compare the output results of the first application system with those of the second application system to determine whether the output results of the first application system and the second application system are the same, and the processing result of the service request is based on the first application system. At the same time, it is determined whether the second application system is operating normally based on the output result, thereby facilitating the location of problems in the second application system while ensuring normal processing of the service, thereby improving system testing efficiency.
[0042] In some embodiments, the traffic switching rule is to send only the pending request to the second application system for processing, and the second application system outputs the processing result, thereby achieving complete switching of the traffic.
[0043] In some embodiments, the traffic switching rule is to send the pending request to the second application system for processing. If the processing is successful, the processing result of the pending request is the output result of the second application system; if the processing fails, the pending request that failed to be processed is sent to the first application system for processing, and the processing result of the pending request is the output result of the first application system. Through such a method, while achieving the best effort switching of the pending request, it is possible to ensure that the service request that failed to be successfully processed returns to the original system for processing, thereby ensuring the reliability of the service; at the same time, based on the number of times the interface of the first application system is called, the success ratio of the second application system can also be determined. For example, when the interface of the first application system is no longer called, it is determined that the test of the second application system is completed, thereby providing a basis for the complete switching of traffic.
[0044] In some embodiments, the traffic switching rule may also be to hand over all pending requests to the first application system for processing, thereby increasing the way to keep the traffic from switching and improving reliability.
[0045] In step 150, when the input parameters of the request to be processed do not match the preset parameters, the request to be processed is sent to the first application system for processing, and the first application system outputs the processing result, thereby not affecting the original processing method of the request to be processed and ensuring that the service request is processed normally.
[0046] Based on the method in the above embodiment, it is possible to determine whether to switch the traffic for the request to be processed, as well as the specific traffic switching rules, through the input parameters of the request to be processed, thereby realizing differentiated switching of traffic and improving the flexibility of traffic switching; in addition, by setting preset parameters, the effect of controlling the percentage of flow cutting can be achieved, thereby realizing gradual switching of traffic, avoiding excessive pressure on the new system caused by all switching, and improving the safety of traffic switching.
[0047] In some embodiments, the flow switching framework Starter can be introduced to the first application system, and flow switching annotations can be added to the interface that needs flow switching. In some embodiments, the first application system only needs to introduce the corresponding jar (Java Archive) format file package to start running the flow switching method, thereby reducing deployment difficulty and improving startup efficiency.
[0048] Flow charts of other embodiments of the flow switching method disclosed in the present invention are as follows: Figure 2 shown.
[0049] In step 210, the service request for calling the first application system is monitored and intercepted to obtain the request to be processed.
[0050] In step 220, the state of the switch corresponding to the pending request is obtained. In some embodiments, the switch can be configured based on existing configuration center technology (such as zookeeper). In some embodiments, when the switch is in a matching switching state, step 230 is executed to perform partial traffic switching.
[0051] In some embodiments, the switch may also have a full switching state, in which case step 260 is performed. In some embodiments, the switch may also have a closed state, in which case flow switching is prevented, and step 250 is performed.
[0052] In step 230, it is determined whether the input parameters of the request to be processed successfully match the preset parameters. If the match is successful, step 240 is executed; otherwise, step 250 is executed.
[0053] In step 240, a preset traffic switching rule is obtained and executed, in which the forwarding object of the request to be processed includes the second application system, thereby implementing the switching of part or all of the traffic to the second application system.
[0054] In step 250, the request to be processed is sent to the first application system for processing.
[0055] In step 260, the request to be processed is sent to the second application system for processing.
[0056] Based on the method in the above embodiment, the switch can be used to conveniently and quickly adjust the flow switching mode, and the controllability can be improved by adjusting the state of the switch to timely operate whether to switch the flow or whether to switch all the flows. In some embodiments, when the second application system is abnormal, the switch can be adjusted to a closed state to avoid missing the service request and improve the reliability of the service.
[0057] In some embodiments, the service request for executing traffic switching can be obtained from an API. Figure 3 shown.
[0058] In step 310, the traffic switching device monitors the API of the first application system and determines a service request for calling the API.
[0059] In some embodiments, the flow switching annotation may include one or more of a method for calling a new interface, a method for converting the format of an input parameter, a method for converting the format of an output parameter, and a method for handling an exception in an interface of the second application system.
[0060] In step 311, the traffic switching device intercepts the service request for calling the API as a request to be processed. In some embodiments, AOP (Aspect Oriented Programming) can be used to implement unified maintenance of program functions through pre-compilation and dynamic proxy during runtime to perform traffic interception.
[0061] In step 320, the state of the switch corresponding to the pending request is obtained. When the state of the switch is the matching flow switching state, step 330 is executed; when the state of the switch is the full flow switching state, step 360 is executed; when the state of the switch is the closed state, step 350 is executed.
[0062] In step 330 , the input parameters of the request to be processed are matched with the preset parameters. If the match is successful, step 370 is executed; otherwise, step 350 is executed.
[0063] In some embodiments, the preset parameters stored in the configuration center can be called according to the output value of the switch in the case of matching switching; the input parameters of the request to be processed are dynamically collected through dynamic reflection technology; and the collected input parameters are matched with the preset parameters to determine whether the match is successful.
[0064] In step 350, the pending request is sent to the first application system for processing, and the processing result output by the first application system is used as the processing result of the service request. In this case, all pending requests are handed over to the first application system for processing, and the original state is maintained without performing traffic switching.
[0065] In step 360, the pending requests are sent to the second application system for processing. In this case, all pending requests are processed by the second application system, and the traffic is switched to the second application system.
[0066] In step 340, format conversion is performed on the input parameters of the request to be processed according to the input parameter formats of the first application system and the second application system to obtain converted input parameters.
[0067] In step 370, a traffic switching rule is obtained. In some embodiments, the traffic switching rule may be a preset one, or a currently executed rule configured from a plurality of rules preset in a rule library.
[0068] Specifically, the traffic switching rule may be any one of steps 371 to 374 , and based on the currently selected traffic switching rule, the traffic switching device performs a corresponding operation.
[0069] In step 371, the traffic switching device only sends the pending requests to the second application system for processing, so that all pending requests are handled by the second application system, and the traffic is switched to the second application system. The traffic switching rule can be used after the second application system is tested or after the traffic switching, so as to complete the switching of all traffic without setting the switch or changing the switch state.
[0070] In step 372, the request to be processed is sent to the first application system and the second application system for processing. The two systems will output their own processing results respectively. The processing results of the request to be processed also include the processing results from the two systems, thereby achieving synchronization of the processing request and the processing results in the two systems and improving data consistency.
[0071] In step 373, the request to be processed is sent to the second application system for processing. If the processing is successful, the output result of the second application system is the processing result of the request to be processed. In some embodiments, the success callback interface can be called if the processing is successful; if the second application system fails to process, the traffic switching device will call the interface of the first application system, send the failed request to be processed to the first application system for processing, and use the processing result of the first application system as the final processing result of the request to be processed. Such rules are suitable for labeling and calculating the traffic switching ratio, and the labeling is recorded in redis (Remote Dictionary Server) or database to facilitate statistics of switched traffic data and reference MQ traffic switching data).
[0072] In step 374, the request to be processed is sent to the first application system and the second application system for processing respectively, and the output results of the first application system and the second application system are compared to determine whether the output results of the first application system and the second application system are the same. At this time, the processing result is based on the output result of the first application system, and the reliability of the second application system is determined based on the output result. If the output results are different, it can be considered that the second application system is still unreliable, and all traffic will not be switched to the second application system for processing temporarily.
[0073] In some embodiments, for the output results from the second application system, when the output results of the first and second application systems are based on different protocols, protocol conversion can be performed to convert the output results of the second application system into a form that conforms to the output results of the first application system, thereby achieving imperceptible traffic switching during the service process.
[0074] Based on the method in the above embodiment, it is possible to switch the traffic that calls the original application system API to the new system, determine whether to switch based on a single service request, and improve the accuracy and flexibility of traffic switching; improve the control ability of traffic switching by setting switches, rules and preset parameters, thereby facilitating various stages from testing and trial operation to actual operation of traffic switching, which is conducive to promotion and application.
[0075] In some embodiments, the service request for executing traffic switching can be obtained from MQ. Figure 4 shown.
[0076] In step 410, the MQ of the service request of the first application system is monitored. In some embodiments, the MQ of the service request of the second application system can also be monitored. In some embodiments, the monitored MQ can be preset according to demand.
[0077] In step 411, the service requests in each MQ are intercepted.
[0078] In step 412, it is determined whether the MQ to which the intercepted service request belongs belongs to the flow switching range. If it belongs to the flow switching range, step 413 is executed; otherwise, step 414 is executed.
[0079] In some embodiments, it is possible to determine whether it belongs to the flow switching range by the name of the MQ. In some embodiments, the name of the MQ that needs flow switching or the rule of the MQ name can be preset, and then the name of the MQ to which the obtained service request belongs is matched with the preset parameters. If the match is successful, it is determined whether it belongs to the flow switching range; if the match is not successful, it does not belong to the flow switching range.
[0080] In step 413 , the service request is treated as a request to be processed, and step 420 is executed.
[0081] In step 414, the traffic switching operation for the current service request is exited, and the processing of the current service request is completed. The service request will be handed over to the application system corresponding to the MQ to which it belongs for processing in a state where no traffic switching is performed.
[0082] In step 420, the state of the switch corresponding to the pending request is obtained. When the state of the switch is the matching flow switching state, step 430 is executed; when the state of the switch is the full flow switching state, step 460 is executed; when the state of the switch is the closed state, step 450 is executed.
[0083] In step 430, the preset parameters are extracted from the configuration center, and the input parameters of the request to be processed are matched with the preset parameters to determine whether the match is successful. If the match is successful, step 440 is executed; otherwise, step 450 is executed.
[0084] In step 440, it is determined that the pending request meets the traffic switching requirement, and the traffic switching rule is to send the pending request to the second application system for processing. The traffic switching device executes the rule, and sends the pending request to the second application system for execution, thereby achieving complete switching of MQ traffic.
[0085] In step 450, the request to be processed is sent to the first application system for processing, thereby preventing the switching of MQ traffic.
[0086] In step 460, the request to be processed is sent to the second application system for processing, thereby achieving complete switching of MQ traffic.
[0087] Based on the method in the above embodiment, it is possible to realize the switching of traffic in MQ to the new system, determine whether to switch based on a single service request, and improve the accuracy and flexibility of traffic switching; the control ability of traffic switching is improved by setting switches and preset parameters.
[0088] In some embodiments, during the traffic switching process, service requests can be obtained from both MQ and API. The same switch state and preset parameters are used for pending requests from different sources. Considering that order creation is through the RPC interface and subsequent state changes are completed asynchronously through MQ, the method in the above embodiment can make the traffic of the interface and MQ perform switching judgments under the same conditions, thereby improving the integrity of the traffic switching for the application system and making the traffic switching more comprehensive.
[0089] In some embodiments, the configuration and operation process flow chart of the flow switching method disclosed in the present invention is as follows: Figure 5 The traffic switching rules and operation processes involved in this embodiment are only examples and do not constitute an improper limitation to the present disclosure.
[0090] In the initial state 51 , all requests sent by the external application 511 are sent to the first application system 512 .
[0091] When traffic switching is required, the process proceeds to the step of formulating traffic switching rules 52. In some embodiments, the configuration enables external applications to access the first application system 512 and the second application system 513. The second application system 513 is configured to be able to call the interface of the second application system, and to call the interface of the first application system when the callback of the interface of the second application system is abnormal.
[0092] In the service takeover 53 stage, traffic switching starts, the first application system interface and the second application system interface share traffic, and part of the traffic is taken over by the second application system.
[0093] In the complete takeover and old application offline phase 54, all traffic is switched to the second application system 513 to take over, and the first application system can be offline.
[0094] Based on the method in the above embodiment, flexibly configured traffic switching can be applied to different links of traffic switching, and the switching ratio can be adjusted according to the needs of each link, thereby improving the reliability and security of switching while expanding the scope of application, which is conducive to promotion and application.
[0095] Schematic diagrams of some embodiments of the flow switching device disclosed in the present invention are as follows Figure 6 shown.
[0096] The request acquisition unit 601 can monitor and intercept the service request of calling the first application system and obtain the request to be processed. The first application system is a system that processes the current traffic. The service request may include at least one of calling the first application system API (Application Programming Interface) or a request in MQ (Message Queue).
[0097] The matching unit 602 can match the preset parameters according to the input parameters of the pending request. In some embodiments, the input parameters of the pending request may include one or more of the operator name, store code, product code, etc. The preset parameters may include parameter values for executing traffic switching. By performing a parameter matching operation, it can be determined whether the current pending request is within the flow switching range, thereby achieving the ability to control the flow switching percentage. In some embodiments, reflection technology can be used to recursively collect the input parameters of the pending request, and then match the input parameters with the preset parameters through a loop matching method.
[0098] The diversion unit 603 can obtain and execute the preset traffic switching rules when the input parameters of the pending request successfully match the preset parameters. The forwarding object of the pending request in the preset traffic switching rules includes the second application system, so that the second application system is used to process the pending request. In addition, when the input parameters of the pending request do not successfully match the preset parameters, the pending request is sent to the first application system for processing, so as not to affect the original processing method of the pending request, ensuring that the service request is processed normally.
[0099] Such a traffic switching device can determine whether to switch the traffic for the request to be processed, as well as the specific traffic switching rules, through the input parameters of the request to be processed, thereby realizing differentiated switching of traffic and improving the flexibility of traffic switching; in addition, by setting preset parameters, it can achieve the effect of controlling the percentage of flow cutting, thereby realizing gradual switching of traffic, avoiding excessive pressure on the new system due to total switching, and improving the safety of traffic switching.
[0100] In some embodiments, Figure 6 As shown, the traffic switching device also includes a state determination unit 604, which can obtain the state of the switch corresponding to the pending request after the request acquisition unit 601 obtains the pending request. In some embodiments, the switch can be configured based on existing configuration center technology (such as zookeeper). In some embodiments, when the switch is in a matching switching state, the state determination unit 604 triggers the matching unit 602 to perform a parameter matching operation.
[0101] In some embodiments, when the state determination unit 604 determines that the switch is in a fully switched state, the pending request is forwarded to the second application system for processing; in some embodiments, when the state determination unit 604 determines that the switch is in a closed state, traffic switching is blocked and the pending request is sent to the first application system for processing.
[0102] Such a device can use the switch to conveniently and quickly adjust the flow switching mode, and timely operate whether to switch the flow or switch all the flow by adjusting the state of the switch, thereby improving controllability. In some embodiments, when the second application system is abnormal, the switch can be adjusted to a closed state, thereby avoiding the service request from being missed and improving the reliability of the service.
[0103] In some embodiments, the request acquisition unit 601 can acquire service requests from both MQ and API, thereby implementing traffic switching for service requests in both API and MQ; and using the same switch state and preset parameters for requests to be processed from different sources. Such a device can make the switching judgment of the traffic of the interface and MQ under the same conditions, thereby improving the integrity of the traffic switching for the application system and making the traffic switching more comprehensive.
[0104] A structural schematic diagram of an embodiment of the flow switching device disclosed in the present invention is shown in FIG. Figure 7 As shown. The flow switching device includes a memory 701 and a processor 702. Wherein: the memory 701 can be a disk, a flash memory or any other non-volatile storage medium. The memory is used to store the instructions in the corresponding embodiment of the flow switching method above. The processor 702 is coupled to the memory 701 and can be implemented as one or more integrated circuits, such as a microprocessor or a microcontroller. The processor 702 is used to execute the instructions stored in the memory, which can improve the flexibility of flow switching.
[0105] In one embodiment, it is also possible to Figure 8 As shown, the flow switching device 800 includes a memory 801 and a processor 802. The processor 802 is coupled to the memory 801 via a BUS bus 803. The flow switching device 800 can also be connected to an external storage device 805 via a storage interface 804 to call external data, and can also be connected to a network or another computer system (not shown) via a network interface 806. No further detailed description will be given here.
[0106] In this embodiment, the flexibility of traffic switching can be improved by storing data instructions in a memory and processing the instructions through a processor.
[0107] In another embodiment, a computer-readable storage medium stores thereon computer program instructions, which, when executed by a processor, implement the steps of the method in the corresponding embodiment of the flow switching method. It should be understood by those skilled in the art that the embodiments of the present disclosure may be provided as methods, devices, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present disclosure may take the form of a computer program product implemented on one or more computer-usable non-transient storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0108] The present disclosure is described with reference to flowcharts and / or block diagrams of methods, devices (systems) and computer program products according to embodiments of the present disclosure. It should be understood that each process and / or block in the flowchart and / or block diagram and the combination of processes and / or blocks in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0109] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0110] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0111] So far, the present disclosure has been described in detail. In order to avoid obscuring the concept of the present disclosure, some details known in the art are not described. Based on the above description, those skilled in the art can fully understand how to implement the technical solution disclosed here.
[0112] The method and apparatus of the present disclosure may be implemented in many ways. For example, the method and apparatus of the present disclosure may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above order of steps for the method is for illustration only, and the steps of the method of the present disclosure are not limited to the order specifically described above, unless otherwise specifically stated. In addition, in some embodiments, the present disclosure may also be implemented as a program recorded in a recording medium, which includes machine-readable instructions for implementing the method according to the present disclosure. Therefore, the present disclosure also covers a recording medium storing a program for executing the method according to the present disclosure.
[0113] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present disclosure rather than to limit it. Although the present disclosure has been described in detail with reference to the preferred embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present disclosure can still be modified or some technical features can be replaced by equivalents without departing from the spirit of the technical solution of the present disclosure, which should be included in the scope of the technical solution for protection of the present disclosure.
Claims
1. A flow switching method, comprising: Monitor and intercept the service request for calling the first application system, and obtain the request to be processed; Matching preset parameters according to the input parameters of the request to be processed, including: dynamically collecting the input parameters of the request to be processed through dynamic reflection technology, and matching the collected input parameters with the preset parameters; When the input parameters of the request to be processed successfully match the preset parameters, a preset traffic switching rule is obtained and executed, wherein the preset parameters include parameter values for executing traffic switching, and the preset traffic switching rule includes: Sending the pending request to a second application system for processing; Sending the pending request to the first application system and the second application system for processing; Sending the pending request to the second application system for processing; if the second application system fails to process, sending the pending request to the first application system for processing; or Sending the pending request to the first application system and the second application system for processing respectively, and comparing the output results of the first application system with those of the second application system to determine whether the output results of the first application system and the second application system are the same; When the input parameters of the request to be processed do not match the preset parameters, the request to be processed is sent to the first application system for processing.
2. The method according to claim 1, further comprising: After intercepting the traffic that calls the first application system, obtaining the state of the switch corresponding to the pending request; When the state of the switch is a matching switch, the operation of matching the preset parameters according to the input parameters of the request to be processed is performed.
3. The method according to claim 2, further comprising at least one of the following: When the state of the switch is fully switched, forwarding the pending request to the second application system for processing; or When the switch is in the off state, the pending request is sent to the first application system for processing.
4. The method according to claim 1, wherein: The monitoring and intercepting of the service request for calling the first application system to obtain the request to be processed includes: Monitoring the interface of the first application system to determine the service request for calling the interface; The service request for calling the interface is intercepted as the request to be processed.
5. The method according to claim 4, wherein: The forwarding the pending request to at least one of the first application system and the second application system for processing according to the traffic switching rule includes: According to the input parameter formats of the first application system and the second application system, format conversion is performed on the input parameters of the request to be processed to obtain converted input parameters; According to at least one of the input parameters of the pending request and the conversion input parameters, the pending request is forwarded to a corresponding application system based on the traffic switching rule, and the application system includes the first application system and the second application system.
6. The method according to claim 1 or 4, wherein: The monitoring and intercepting of the service request for calling the first application system to obtain the request to be processed includes: A message queue monitoring the service request of the first application system; Intercept the service requests in the message queue and obtain the requests to be processed.
7. The method according to claim 6, further comprising: The message queue of the service request of the second application system is monitored, and the service request in the message queue is intercepted to obtain the request to be processed so as to perform the operation of matching the preset parameters according to the input parameters of the request to be processed.
8. The method according to claim 6, wherein: The preset traffic switching rule includes: forwarding the pending request to the second application system for processing.
9. The method according to claim 6, wherein: The obtaining of pending requests comprises: Determine whether the message queue to which the intercepted service request belongs belongs to a traffic switching range; If the service request belongs to the traffic switching range, taking the service request as the pending request; If the service request does not belong to the traffic switching range, exit the traffic switching operation on the service request.
10. A flow switching device, comprising: A request acquisition unit, configured to monitor and intercept a service request for calling the first application system, and acquire a request to be processed; A matching unit is configured to match preset parameters according to the input parameters of the request to be processed, including: dynamically collecting the input parameters of the request to be processed through dynamic reflection technology, and matching the collected input parameters with the preset parameters; The traffic diversion unit is configured to obtain and execute a preset traffic switching rule if the input parameter of the request to be processed successfully matches the preset parameter; if the input parameter of the request to be processed does not successfully match the preset parameter, send the request to be processed to the first application system for processing, wherein the preset parameter includes a parameter value for executing traffic switching, and the preset traffic switching rule includes: Sending the pending request to a second application system for processing; Sending the pending request to the first application system and the second application system for processing; Sending the pending request to the second application system for processing; if the second application system fails to process, sending the pending request to the first application system for processing; or The request to be processed is sent to the first application system and the second application system for processing respectively, and the output results of the first application system are compared with those of the second application system to determine whether the output results of the first application system and the second application system are the same.
11. The apparatus according to claim 10, further comprising: A state determination unit is configured to: after the request acquisition unit intercepts the traffic that calls the first application system, acquire the state of the switch corresponding to the request to be processed; When the state of the switch is matching switching, triggering the matching unit to perform an operation; When the state of the switch is fully switched, forwarding the pending request to the second application system for processing; or When the switch is in the off state, the pending request is sent to the first application system for processing.
12. The device according to claim 10, wherein: The request acquisition unit is configured to perform at least one of the following: Monitor the interface of the first application system, determine the service request for calling the interface, intercept the service request for calling the interface, and obtain the request to be processed; or The message queue of the service request of the first application system is monitored, the service request in the message queue is intercepted, and the request to be processed is obtained.
13. A flow switching device, comprising: Memory; as well as A processor coupled to the memory, the processor being configured to execute the method according to any one of claims 1 to 9 based on instructions stored in the memory.
14. A computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, implement the steps of the method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Traffic switching methods and devices based on multiple active data centers
CA3162740A1
Method and device for saving traffic based on advertisement blocking
CN104468551A