Service room remote scheduling method and device, equipment and storage medium

Obtain verification logic and structure mapping templates through the configuration center, use the reflection mechanism to reassemble remote scheduling messages, and dynamically adjust inter-service scheduling protocols, solving the problem of frequent code release, reducing implementation costs, and enhancing scheduling flexibility and Monitoring capabilities.

CN118585352APending Publication Date: 2024-09-03CHINA EVERBRIGHT BANK
View PDF 0 Cites 3 Cited by

Patent Information

Application Number
CN202410714601.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-04
Publication Date
2024-09-03

AI Technical Summary

Technical Problem

Existing inter-service remote scheduling technology requires frequent code release and online release when requirements, interface protocols, or joint debugging scenarios change, resulting in high implementation costs.

Method used

By obtaining the legality verification logic and input/output structure mapping template from the configuration center, the reflection mechanism is used to reassemble the input/output structure of the remote call request and response message, dynamically adjust the protocol and verification logic, and avoid code Change to realize dynamic configuration of input/output structure.

Benefits of technology

It reduces duplicate code development, reduces the implementation cost of remote scheduling between services, and supports functions such as business monitoring, traffic recording, and simulated fault requests.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118585352A
    Figure CN118585352A
Patent Text Reader

Abstract

The invention relates to the technical field of service remote scheduling, and provides an inter-service remote scheduling method and device, equipment and a storage medium, and the method comprises the steps: receiving a remote call request message which is initiated by a first server and is used for scheduling a second server; obtaining a first legality verification logic and an incoming parameter service verification logic corresponding to the remote call request message from the configuration center, and performing legality verification and incoming parameter service verification logic according to the first legality verification logic and the incoming parameter service verification logic to obtain a first verification result; judging whether an incoming parameter structure of the remote call request message needs to be reassembled or not according to the first verification result; when the in-parameter structure needs to be reassembled, the corresponding in-parameter structure mapping template is acquired from the configuration center, and the in-parameter structure is reassembled by using the reflection mechanism and the in-parameter structure mapping template; and calling the second server according to the reassembled input parameter structure. According to the embodiment of the invention, the implementation cost of remote scheduling between services can be reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of remote business scheduling, and in particular to a method, device, equipment and storage medium for remote scheduling between services. Background Art

[0002] The interaction between business systems is generally provided by the service system to the access system, and the access adjusts the code according to the input and output parameter formats of the interface document. With the popularization of distributed architecture, in order to reduce the communication cost of docking and the problems caused by the adjustment of the access field name and the inconsistency between the service, the service system provides a software development kit (sdk) using remote procedure call (RPC). After the access party introduces the sdk, it can make remote calls like calling local services. However, when the demand changes and the interface protocol changes, the server needs to release a new version of the sdk package to the access party. Whenever the server goes online, it needs to consider the compatibility of different versions of the sdk package and whether it will cause serialization problems. In short, in the existing inter-service remote scheduling technology, when any of the demand, interface protocol or joint debugging scenario changes, it is necessary to frequently release the code online; thus greatly increasing the implementation cost of inter-service remote scheduling. Summary of the invention

[0003] The purpose of the embodiments of this specification is to provide a method, apparatus, device and storage medium for remote scheduling between services to reduce the implementation cost of remote scheduling between services.

[0004] To achieve the above objectives, on the one hand, an embodiment of this specification provides a remote scheduling method between services, including:

[0005] Receiving a remote call request message initiated by the first server for scheduling the second server;

[0006] Obtaining from the configuration center the first legitimacy verification logic and the input parameter business verification logic corresponding to the remote call request message;

[0007] Verify the legitimacy of the input parameter field of the remote call request message according to the first legitimacy verification logic, and verify the correctness of the input parameter business logic of the remote call request message according to the input parameter business verification logic to obtain a first verification result;

[0008] Determining whether it is necessary to reassemble the input parameter structure of the remote call request message according to the first verification result;

[0009] When the input parameter structure needs to be reassembled, the corresponding input parameter structure mapping template is obtained from the configuration center, and the input parameter structure is reassembled by using the reflection mechanism and the input parameter structure mapping template;

[0010] The second server is called according to the reassembled input parameter structure.

[0011] The inter-service remote scheduling method of the embodiment of this specification, wherein the input parameter structure is reassembled by using the reflection mechanism and the input parameter structure mapping template, comprises:

[0012] Based on the input parameter structure mapping template, the input parameter structure is reassembled using the ASM reflection mechanism.

[0013] The inter-service remote scheduling method of the embodiment of this specification, based on the input parameter structure mapping template, uses the ASM reflection mechanism to reassemble the input parameter structure, including:

[0014] Create a ClassReader object;

[0015] Call the ClassReader object to parse the bytecode file of the input parameter structure to obtain the input parameter field attributes, request method and bytecode of the input parameter structure;

[0016] Create a ClassVisitor class;

[0017] Call the visitField method of the ClassVisitor class to determine whether the input parameter field attributes are consistent with the input parameter field attributes in the input parameter structure mapping template; and call the visitMehod method in the ClassVisitor class to determine whether the request method is consistent with the request method in the input parameter structure mapping template;

[0018] Create the ClassWriter class;

[0019] If it is inconsistent with the input parameter field attributes in the input parameter structure mapping template, the FieldWriter method of the ClassWriter class is called to overwrite the input parameter field attributes of the input parameter structure to be consistent with the input parameter field attributes in the input parameter structure mapping template; if it is inconsistent with the request method in the input parameter structure mapping template, the MethodWriter method of the ClassWriter class is called to overwrite the input parameter field attributes of the input parameter structure to be consistent with the input parameter field attributes in the input parameter structure mapping template;

[0020] Modify the bytecode of the input parameter structure after overwriting the input parameter field attributes and / or request method.

[0021] The inter-service remote scheduling method of the embodiment of the present specification, after determining whether it is necessary to reassemble the input parameter structure of the remote call request message according to the first verification result, further includes:

[0022] When the input parameter structure does not need to be reassembled, the input parameter structure is transparently transmitted to the second server.

[0023] The inter-service remote scheduling method of the embodiment of the present specification, after calling the second server according to the reassembled input parameter structure, further includes:

[0024] Receive a remote call response message returned by the second server;

[0025] Obtaining the second legitimacy verification logic and the parameter output business verification logic of the remote call response message from the configuration center;

[0026] Verify the legitimacy of the outgoing parameter field of the remote call response message according to the second legitimacy verification logic, and verify the correctness of the outgoing parameter business logic of the remote call response message according to the outgoing parameter business verification logic to obtain a second verification result;

[0027] Determining whether it is necessary to reassemble the output parameter structure of the remote call response message according to the second verification result;

[0028] When the output parameter structure needs to be reassembled, the corresponding output parameter structure mapping template is obtained from the configuration center, and the output parameter structure is reassembled by using the reflection mechanism and the output parameter structure mapping template;

[0029] The reassembled output parameter structure is returned to the first server.

[0030] The inter-service remote scheduling method of the embodiment of this specification, wherein the output parameter structure is reassembled by using the reflection mechanism and the output parameter structure mapping template, comprises:

[0031] Based on the output parameter structure mapping template, the output parameter structure is reassembled using Javassist reflection.

[0032] The inter-service remote scheduling method of the embodiment of this specification, based on the output parameter structure mapping template, uses Javassist reflection to reassemble the output parameter structure, including:

[0033] Get the CtClass object from the ClassPool class pool;

[0034] Call the CtClass object to obtain the output parameter field attributes, return method and bytecode of the output parameter structure;

[0035] Create CtField objects and CtMethod objects;

[0036] Call the CtField object to check whether the output parameter field attribute is consistent with the output parameter field attribute in the output parameter structure mapping template, and call the CtMethod object to check whether the return method is consistent with the return method in the output parameter structure mapping template;

[0037] If it is inconsistent with the output parameter field attributes in the output parameter structure mapping template, the addFileld method, removeField method and / or setModifiers method in the CtField object are called to overwrite the output parameter field attributes of the output parameter structure to be consistent with the output parameter field attributes in the output parameter structure mapping template; if it is inconsistent with the return method in the output parameter structure mapping template, the instrument method of the CtMethod object is called to overwrite the return method of the output parameter structure to be consistent with the return method in the output parameter structure mapping template.

[0038] The inter-service remote scheduling method of the embodiment of the present specification, after receiving a remote call request initiated by a first server for scheduling a second server, further includes:

[0039] When receiving the remote call request message returned by the first server, calling the preset JVM sandbox interception method to process the specified transaction; the specified transaction includes business monitoring, traffic recording and / or simulated fault request;

[0040] Return to execute the main logic of remote call business.

[0041] The inter-service remote scheduling method of the embodiment of this specification, wherein the calling of a preset JVM sandbox interception method to process a specified transaction, comprises:

[0042] Execute the before method of the JVM sandbox to intercept the remote call request message and obtain the input parameter data of the remote call request message;

[0043] Parse the input parameter data to obtain the business identity, and perform heap mapping processing on the business identity according to the business dimension;

[0044] The request density of each of the service identities is calculated asynchronously by multiple threads, and the request density of each of the service identities is sent to a local designated queue.

[0045] On the other hand, the embodiment of this specification also provides a remote scheduling device between services, including:

[0046] A receiving module, used to receive a remote call request message initiated by the first server for scheduling the second server;

[0047] An acquisition module, used to acquire the first legitimacy verification logic and the input parameter business verification logic corresponding to the remote call request message from the configuration center;

[0048] A verification module, used to verify the legitimacy of the input parameter field of the remote call request message according to the first legitimacy verification logic, and verify the correctness of the input parameter business logic of the remote call request message according to the input parameter business verification logic, to obtain a first verification result;

[0049] A judgment module, used for judging whether it is necessary to reassemble the input parameter structure of the remote call request message according to the first verification result;

[0050] An assembly module, used for obtaining a corresponding input parameter structure mapping template from the configuration center when the input parameter structure needs to be reassembled, and reassembling the input parameter structure by using a reflection mechanism and the input parameter structure mapping template;

[0051] A calling module is used to call the second server according to the reassembled input parameter structure.

[0052] On the other hand, an embodiment of the present specification further provides a computer device, including a memory, a processor, and a computer program stored in the memory, wherein when the computer program is executed by the processor, the instructions of the above method are executed.

[0053] On the other hand, an embodiment of the present specification further provides a computer storage medium on which a computer program is stored. When the computer program is executed by a processor of a computer device, the instructions of the above method are executed.

[0054] On the other hand, an embodiment of the present specification further provides a computer program product, wherein the computer program product includes a computer program, and when the computer program is executed by a processor of a computer device, the computer program executes instructions of the above method.

[0055] It can be seen from the technical solutions provided in the above embodiments of this specification that, in the embodiments of this specification, when receiving a remote call request message from one server to another server, the legitimacy verification logic and input parameter business verification logic corresponding to the request message can be obtained from the configuration center, and the legitimacy verification and input parameter business verification can be performed on the request message accordingly; when the input parameter structure needs to be reassembled, the corresponding input parameter structure mapping template can be obtained from the configuration center, and the input parameter structure can be reassembled using the reflection mechanism and the input parameter structure mapping template; thereby, the reflection mechanism and the configuration center are used to realize dynamic adjustment of the input parameter protocol, dynamic configuration of the verification logic, and dynamic configuration of the input parameter structure mapping template during scheduling between services, without the need to change the relevant code, thereby reducing repeated code development and reducing the implementation cost of remote scheduling between services.

[0056] Furthermore, the reflection mechanism and configuration center can also realize dynamic adjustment of the output parameter protocol, dynamic configuration of the verification logic, and dynamic configuration of the output parameter structure mapping template during scheduling between services without making changes to the relevant code, thereby further reducing repeated code development and further reducing the implementation cost of remote scheduling between services.

[0057] In addition, the embodiments of the present specification can also call the preset JVM sandbox interception method to process the specified transaction when receiving the remote call request message; and return to execute the main logic of the remote call service after processing the specified transaction. In this way, the JVM sandbox interception method can also be used during the remote scheduling service to implement specified transactions such as business monitoring, traffic recording and / or simulated fault requests. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] In order to more clearly illustrate the technical solutions in the embodiments of this specification or the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art description. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. In the drawings:

[0059] Figure 1 A schematic diagram of a remote scheduling system between services in some embodiments of the present specification is shown;

[0060] Figure 2 A flowchart of a remote scheduling method between services in some embodiments of this specification is shown;

[0061] Figure 3 Shows Figure 2 The method shown is a flowchart of reassembling the input parameter structure using the ASM reflection mechanism based on the input parameter structure mapping template;

[0062] Figure 4 A flowchart showing a remote scheduling method between services in other embodiments of this specification is shown;

[0063] Figure 5 Shows Figure 4 The method shown is a flowchart of reassembling the output parameter structure using Javassist reflection based on the output parameter structure mapping template;

[0064] Figure 6 A flowchart of using a JVM sandbox to perform business monitoring in an exemplary embodiment of this specification is shown;

[0065] Figure 7 A structural block diagram of a remote scheduling device between services in some embodiments of this specification is shown;

[0066] Figure 8 The structure block diagram of the computer device in some embodiments of the present specification is shown.

[0067] [Description of Reference Numerals]

[0068] 10. The first server;

[0069] 20. Remote scheduling server;

[0070] 30. Second server;

[0071] 40. Configuration center;

[0072] 71. Receiving module;

[0073] 72. Get module;

[0074] 73. Verification module;

[0075] 74. Judgment module;

[0076] 75. Assemble modules;

[0077] 76. Call module;

[0078] 802. Computer equipment;

[0079] 804, processor;

[0080] 806. Memory;

[0081] 808, driving mechanism;

[0082] 810, input / output interface;

[0083] 812. Input device;

[0084] 814. Output device;

[0085] 816. Presentation equipment;

[0086] 818. Graphical user interface;

[0087] 820, network interface;

[0088] 822, communication link;

[0089] 824. Communication bus. DETAILED DESCRIPTION

[0090] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this specification.

[0091] Figure 1 , a schematic diagram of a remote scheduling system between services in some embodiments of the present specification is shown; the remote scheduling system between services includes a first server 10, a remote scheduling server 20, a second server 30 and a configuration center 40. The remote scheduling server 20 can receive a remote call request message initiated by the first server 10 for scheduling the second server 30; obtain a first legitimacy verification logic and an input parameter business verification logic corresponding to the remote call request message from the configuration center 40; verify the legitimacy of the input parameter field of the remote call request message according to the first legitimacy verification logic, and verify the correctness of the input parameter business logic of the remote call request message according to the input parameter business verification logic to obtain a first verification result; determine whether it is necessary to reassemble the input parameter structure of the remote call request message according to the first verification result; when it is necessary to reassemble the input parameter structure, obtain the corresponding input parameter structure mapping template from the configuration center 40, and reassemble the input parameter structure using the reflection mechanism and the input parameter structure mapping template; call the second server 30 according to the reassembled input parameter structure. In this way, the reflection mechanism and configuration center can be used to realize the dynamic adjustment and verification capability configuration of the input parameter protocol during scheduling between services, thereby reducing repeated code development and lowering the implementation cost of remote scheduling between services.

[0092] Furthermore, the remote scheduling server 20 can also receive the remote call response message returned by the second server 30; obtain the second legitimacy verification logic and the parameter output business verification logic of the remote call response message from the configuration center 40; verify the legitimacy of the parameter output field of the remote call response message according to the second legitimacy verification logic, and verify the correctness of the parameter output business logic of the remote call response message according to the parameter output business verification logic to obtain a second verification result; determine whether it is necessary to reassemble the parameter output structure of the remote call response message according to the second verification result; when it is necessary to reassemble the parameter output structure, obtain the corresponding parameter output structure mapping template from the configuration center 40, and reassemble the parameter output structure using the reflection mechanism and the parameter output structure mapping template; return the reassembled parameter output structure to the first server 10. In this way, the reflection mechanism and the configuration center can be used to realize the dynamic adjustment of the parameter output protocol and the non-invasive injection of business logic during inter-service scheduling, thereby further reducing repeated code development and further reducing the implementation cost of inter-service remote scheduling.

[0093] Furthermore, the remote scheduling service end 20 can also call the preset JVM-Sandbox interception method to process the specified transaction when receiving the remote call request message returned by the first service end 10; and return to execute the main logic of the remote call service after processing the specified transaction. In this way, the JVM sandbox interception method can also be used during the remote scheduling service to implement specified transactions such as business monitoring, traffic recording and / or simulated fault requests.

[0094] In some embodiments of the present specification, the first server 10 and the second server 30 may be any two servers with remote scheduling requirements, and the remote scheduling between these servers needs to be implemented using the remote scheduling server 20. The remote scheduling server 20 may be a remote scheduling component.

[0095] The embodiment of this specification provides a remote scheduling method between services, which can be applied to the above remote scheduling server. Figure 2 As shown, in some embodiments of this specification, the inter-service remote scheduling method may include the following steps:

[0096] Step 201: Receive a remote call request message initiated by a first server for scheduling a second server.

[0097] Step 202: Obtain the first legitimacy verification logic and input parameter business verification logic corresponding to the remote call request message from the configuration center.

[0098] Step 203: verify the legitimacy of the input parameter fields of the remote call request message according to the first legitimacy verification logic, and verify the correctness of the input parameter business logic of the remote call request message according to the input parameter business verification logic to obtain a first verification result.

[0099] Step 204: Determine whether it is necessary to reassemble the input parameter structure of the remote call request message according to the first verification result.

[0100] Step 205: When the input parameter structure needs to be reassembled, the corresponding input parameter structure mapping template is obtained from the configuration center, and the input parameter structure is reassembled using the reflection mechanism and the input parameter structure mapping template.

[0101] Step 206: Call the second server according to the reassembled input parameter structure.

[0102] In an embodiment of the present specification, when receiving a remote call request message from one server to another server, the legitimacy verification logic and input parameter business verification logic corresponding to the request message can be obtained from the configuration center, and the legitimacy verification and input parameter business verification can be performed on the request message accordingly; when the input parameter structure needs to be reassembled, the corresponding input parameter structure mapping template can be obtained from the configuration center, and the input parameter structure can be reassembled using the reflection mechanism and the input parameter structure mapping template; thereby, the reflection mechanism and the configuration center are used to realize dynamic adjustment of the input parameter protocol, dynamic configuration of the verification logic, and dynamic configuration of the input parameter structure mapping template during scheduling between services, without the need to change the relevant code, thereby reducing repeated code development and reducing the implementation cost of remote scheduling between services.

[0103] In some embodiments of the present specification, the first server may call the remote scheduling server by assembling request parameters like calling a local method. Since the remote scheduling server may use Object generics or Map key value parameters, the actual service method of the second server may be different.

[0104] In some embodiments of this specification, the legality check mainly refers to the legality check of the input parameter fields such as user identity (such as non-empty judgment, etc.); the verification logic of the legality check can be dynamically customized on the configuration center side according to actual needs; complex legality check judgments can be implemented through regular expressions, where regular expressions can be introduced through the configuration center and can be dynamically adjusted. In addition to the legality check, it is sometimes necessary to perform business dimension verification (i.e., input parameter business verification) in combination with the actual business scenario; the parameter business verification mainly refers to the verification of the correctness and eligibility of the business logic. For example, when a deposit request is written, the limits for ordinary users and enterprises are different, and the limit judgment needs to be made based on the incoming business identity; among them, the verification logic for different business identities can also be obtained from the configuration center.

[0105] For example, taking a deposit request message as an example, the request parameters (request input fields) of the deposit request message may include key business information such as the transfer-in account, deposit type, transaction amount, and transfer-out account. The legitimacy check of the request input fields may include legitimacy checks on the transfer-in account, transfer-out account, etc. If the conditions are not met, subsequent operations will be rejected directly to reduce the request pressure on the service. The verification rules for legitimacy verification can be flexibly implemented using regular expressions, and can be dynamically configured in conjunction with the configuration center. Of course, there are many ways to formulate verification rules. In some simple scenarios, judgments can also be made based on the configured agreed rules to avoid regular expressions affecting the overall performance of the service due to backtracking.

[0106] When the input parameter business verification of the remote call request message fails, in order to ensure the success rate of remote scheduling, the input parameter structure of the remote call request message needs to be reassembled. When the legitimacy verification and input parameter business verification of the remote call request message are successful, it is generally not necessary to reassemble the input parameter structure, so that the input parameter structure can be transparently transmitted to the second server for processing.

[0107] In some embodiments of the present specification, reassembling the input parameter structure using the reflection mechanism and the input parameter structure mapping template may include: reassembling the input parameter structure using the ASM reflection mechanism based on the input parameter structure mapping template. The corresponding input parameter structure mapping template may refer to: the input parameter structure template expected by the second server for this type of remote call request message.

[0108] ASM (Reflection Mechanism) is a Java bytecode manipulation framework used to dynamically generate classes or enhance the functionality of existing classes. ASM can directly generate binary class files, and can also dynamically change class behavior before the class is loaded into the Java virtual machine. ASM can be used to change class behavior, analyze class information, and even generate new classes according to user requirements.

[0109] refer to Figure 3 As shown, in some embodiments of the present specification, based on the input parameter structure mapping template, reassembling the input parameter structure using the ASM reflection mechanism may include the following steps:

[0110] Step 301: Create a ClassReader object.

[0111] The ClassReader object is mainly used to parse bytecode files, that is, to parse the bytecode files of the input structure.

[0112] Step 302: Call the ClassReader object to parse the bytecode file of the input parameter structure to obtain the input parameter field attributes, request method and bytecode of the input parameter structure.

[0113] Step 303: Create a ClassVisitor class.

[0114] Some specific methods of the ClassVisitor class can access the fields, methods, and bytecodes of the input structure.

[0115] Step 304: call the visitField method of the ClassVisitor class to determine whether the input parameter field attributes are consistent with the input parameter field attributes in the input parameter structure mapping template; and call the visitMehod method in the ClassVisitor class to determine whether the request method is consistent with the request method in the input parameter structure mapping template.

[0116] When the passed in attribute matches the actual field name of the class, just return null. In addition, to enhance the extensibility of the code, you can add corresponding decoration layers to different operations to make each operation hot-swappable.

[0117] Step 305: Create a ClassWriter class.

[0118] Some specific methods of the ClassVisitor class can modify the fields and methods of the input structure.

[0119] Step 306: If the input parameter field attributes are inconsistent with the input parameter structure mapping template, the FieldWriter method of the ClassWriter class is called to overwrite the input parameter field attributes of the input parameter structure to be consistent with the input parameter field attributes in the input parameter structure mapping template; if the request method is inconsistent with the input parameter structure mapping template, the MethodWriter method of the ClassWriter class is called to overwrite the input parameter field attributes of the input parameter structure to be consistent with the input parameter field attributes in the input parameter structure mapping template. The written content of the ClassWriter class is in string format and can be pre-configured through the configuration center.

[0120] Step 307: Modify the bytecode of the input parameter structure after overwriting the input parameter field attributes and / or the request method.

[0121] Figure 3 In the illustrated embodiment, by using ASM to obtain the bytecode of the JAVA class, the existing class or dynamically generated class can be modified directly in binary form, and the adjustment execution efficiency is high and more convenient. In addition, the above-mentioned use of the ASM reflection mechanism to reassemble the input parameter structure is only used as an illustrative example. In other embodiments of this specification, other reflection technologies can also be used as needed, and this specification does not limit this.

[0122] refer to Figure 4 As shown, the embodiment of this specification provides another inter-service remote scheduling method, which can be applied to the above-mentioned remote scheduling server. The inter-service remote scheduling method may include the following steps:

[0123] Step 401: Receive a remote call request message initiated by a first server for scheduling a second server.

[0124] Step 402: Obtain the first legitimacy verification logic and input parameter business verification logic corresponding to the remote call request message from the configuration center.

[0125] Step 403: verify the legitimacy of the input parameter fields of the remote call request message according to the first legitimacy verification logic, and verify the correctness of the input parameter business logic of the remote call request message according to the input parameter business verification logic to obtain a first verification result.

[0126] Step 404: Determine whether it is necessary to reassemble the input parameter structure of the remote call request message according to the first verification result.

[0127] Step 405: When the input parameter structure needs to be reassembled, the corresponding input parameter structure mapping template is obtained from the configuration center, and the input parameter structure is reassembled using the reflection mechanism and the input parameter structure mapping template.

[0128] Step 406: Call the second server according to the reassembled input parameter structure.

[0129] Step 407: Receive the remote call response message returned by the second server.

[0130] Step 408: Obtain the second legitimacy verification logic and the parameter output business verification logic of the remote call response message from the configuration center.

[0131] In some query scenarios, different callers require different query results. In order to avoid exposing too much information, redundant response fields need to be shielded. Some scenarios that require priority display or involve multi-field superposition calculations can also be implemented in the parameter verification stage. For example, if there are three types of business identities A, B, and C for querying account information, the return fields required for each business identity are different, so the return fields required for each business identity can be preset in the configuration center. The configuration template can be in json format, with the key being the name of each business identity and the value being the specific return field name, separated by English colons. When different business identities request, the business identity and field mapping relationship is obtained, the field information corresponding to the corresponding business identity is matched for filtering, and only the fields actually required by the business identity are returned to the caller.

[0132] Step 409: verify the legitimacy of the output parameter field of the remote call response message according to the second legitimacy verification logic, and verify the correctness of the output parameter business logic of the remote call response message according to the output parameter business verification logic to obtain a second verification result.

[0133] Step 410: Determine whether it is necessary to reassemble the output parameter structure of the remote call response message according to the second verification result.

[0134] Step 411: When the output parameter structure needs to be reassembled, the corresponding output parameter structure mapping template is obtained from the configuration center, and the output parameter structure is reassembled using the reflection mechanism and the output parameter structure mapping template.

[0135] The output parameter structure mapping template may refer to: the output parameter structure template expected by the first server for this type of remote call response message.

[0136] Step 412: Return the reassembled output parameter structure to the first server.

[0137] and Figure 2 Compared with the embodiment shown, Figure 4 The illustrated embodiment utilizes the reflection mechanism and the configuration center to realize dynamic adjustment of the input parameter protocol and the output parameter protocol during scheduling between services, dynamic configuration of the verification logic, and dynamic configuration of the input parameter structure and the output parameter structure mapping template without making changes to the relevant code, thereby further reducing repeated code development and further reducing the implementation cost of remote scheduling between services.

[0138] exist Figure 4 In the embodiment of the illustrated embodiment, reassembling the output parameter structure by using the reflection mechanism and the output parameter structure mapping template may include: taking the output parameter structure mapping template as a reference, and reassembling the output parameter structure by using Javassist reflection.

[0139] refer to Figure 5 As shown, in some embodiments of this specification, based on the output parameter structure mapping template, reassembling the output parameter structure using Javassist reflection may include the following steps:

[0140] Step 501: Get a CtClass object from the ClassPool class pool.

[0141] Step 502: Call the CtClass object to obtain the output parameter field attributes, return method and bytecode of the output parameter structure.

[0142] Step 503: Create a CtField object and a CtMethod object.

[0143] Step 504: Call the CtField object to check whether the output parameter field attributes are consistent with the output parameter field attributes in the output parameter structure mapping template, and call the CtMethod object to check whether the return method is consistent with the return method in the output parameter structure mapping template.

[0144] Step 505: If the output parameter field attributes are inconsistent with the output parameter structure mapping template, the addFileld method, removeField method and / or setModifiers method in the CtField object are called to overwrite the output parameter field attributes of the output parameter structure to be consistent with the output parameter field attributes in the output parameter structure mapping template; if the output parameter structure is inconsistent with the return method in the output parameter structure mapping template, the instrument method of the CtMethod object is called to overwrite the return method of the output parameter structure to be consistent with the return method in the output parameter structure mapping template.

[0145] For example, when the dispatcher requires that the account opening institution code is not fully displayed, but only the first and last two digits are displayed, the relevant code for partially shielding the account opening institution code field can be dynamically woven into the application to achieve the purpose of dynamic adjustment.

[0146] Javassist (Java Programming Assistant) is a lightweight Java bytecode manipulation library. It provides a set of easy-to-use APIs that enable developers to dynamically create, modify, and analyze Java classes without having to worry about the underlying bytecode details. The core feature of Javassist is to embed source code snippets as strings into existing classes, and then compile and load them at runtime, which makes code modification very flexible and convenient; allowing developers to focus on business logic rather than generating bytecode itself.

[0147] In some embodiments of the present specification, after receiving a remote call request initiated by a first server for scheduling a second server, the method further includes: upon receiving a remote call request message returned by the first server, calling a preset JVM sandbox interception method to process a specified transaction (incoming business monitoring, traffic recording and / or simulating fault requests, etc.); returning to execute the main logic of the remote call business (e.g. Figure 2 or Figure 4 In this way, the JVM sandbox interception method can also be used during the remote scheduling service to implement specified transactions such as business monitoring, traffic recording and / or simulated fault requests.

[0148] JVM-Sandbox does not need to rely on the spring container. By providing beforeEvent and returnEvent methods, you can customize the logic of the front-end and back-end aspects. In the embodiment of this specification, JVM-Sandbox is introduced into the remote call component, which is intercepted during the actual call to complete business monitoring, traffic recording, simulated fault requests, and interception or adjustment of input and output parameters. When not needed, the specified module can also be quickly cooled and uninstalled.

[0149] There are two modes for installing JVM-Sandbox: agent and attach. If you want to load the module when the online application starts, you can directly use the attach mode. However, when a large number of classes are rendered at one time and a large number of modules are loaded, if they are loaded in the attach mode, it may cause the target JVM to freeze or pause (GC), which requires enabling the agent startup mode. If the agent mode is selected, add the JVM startup parameter -javaagent:+JVM-Sandbox jar package path when the application starts. If the attach mode is selected, introduce mode={information.mode.ATTACH}, transfer the JVM-Sandbox and sandbox modules to the service container for startup to take effect.

[0150] There are two modes for event monitoring in JVM-Sandbox: module loading and command execution. If module loading is selected, loadCompleted is executed (module loading is completed, and the module is called after loading is completed), and the corresponding method logic is injected into loadCompleted. If command execution is selected, the corresponding method logic is activated through http or the command line encapsulated by JVM-Sandbox, and event detection is dynamically added to the method logic.

[0151] After the JVM-Sandbox is installed, the application is injected with the specified business logic (i.e., the enhanced code is woven). If you want to restore the original logic, there are two ways to invalidate the module: module unloading and module freezing; if you choose module unloading, the onUnload method is executed. If you choose module freezing, the onFrozen method is executed. The difference between onFrozen and onUnload is that module freezing will not delete the woven enhanced code while completing the closure of JVM-Sandbox.

[0152] refer to Figure 6 As shown, in an exemplary embodiment of the present specification, taking request density monitoring in business monitoring as an example, calling a preset JVM sandbox interception method to process a specified transaction may include the following steps:

[0153] Step 601, execute the before method of the JVM sandbox to intercept the remote call request message and obtain the input parameter data of the remote call request message.

[0154] Step 602: parse the input parameter data to obtain the business identity, and perform heap mapping processing on the business identity according to the business dimension.

[0155] For the versatility of the interface method, the interface method definition generally adopts List or Map to meet the business call form of single or batch, and adds a business identification field to the input parameter to distinguish requests from different businesses. In this exemplary embodiment, a Map structure (such as a key-value pair) can be used; the key is a specific business identity, and the value is a set of all requests under the business identity.

[0156] Step 603: A multi-threaded asynchronous calculation of the request density of each of the service identities is performed, and the request density of each of the service identities is sent to a local designated queue.

[0157] In order not to affect the performance of the main business process, multi-threaded asynchronous parallel processing can be used to process the divided data, and the divided results can be sent to a local specified queue (for example, the results can be sent to storage such as redis and DB), and then used for visual analysis of the data. For example, to obtain the size of the set in each key, the calculation result is reassembled in combination with the request time, and the result is defined as:

[0158] Map<business identity_request time, request set size of the business>;

[0159] This result set can be used to count the request density of each business identity at the second level.

[0160] Although the process flows described above include multiple operations that occur in a particular order, it should be clearly understood that the processes may include more or fewer operations, which may be performed sequentially or in parallel (eg, using parallel processors or a multi-threaded environment).

[0161] Corresponding to the above-mentioned inter-service remote scheduling method, the embodiment of this specification also provides an inter-service remote scheduling device, which can be configured on the above-mentioned remote call server, referring to Figure 7 As shown, in some embodiments of the present specification, the inter-service remote scheduling device may include:

[0162] The receiving module 71 is used to receive a remote call request message initiated by the first server for scheduling the second server;

[0163] An acquisition module 72 is used to acquire the first legitimacy verification logic and the input parameter business verification logic corresponding to the remote call request message from the configuration center;

[0164] A verification module 73 is used to verify the legitimacy of the input parameter field of the remote call request message according to the first legitimacy verification logic, and verify the correctness of the input parameter business logic of the remote call request message according to the input parameter business verification logic to obtain a first verification result;

[0165] A judging module 74, configured to judge whether it is necessary to reassemble the input parameter structure of the remote call request message according to the first verification result;

[0166] An assembling module 75, configured to obtain a corresponding input parameter structure mapping template from the configuration center when the input parameter structure needs to be reassembled, and to reassemble the input parameter structure by using a reflection mechanism and the input parameter structure mapping template;

[0167] The calling module 76 is used to call the second server according to the reassembled input parameter structure.

[0168] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing this specification, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0169] It should be noted that in the embodiments of this specification, the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user and fully authorized by all parties, that is, the acquisition, transmission, storage, use, and processing of data in the technical solution of this application comply with the relevant provisions of national laws and regulations.

[0170] The embodiments of this specification also provide a computer device. Figure 8As shown, in some embodiments of the present specification, the computer device 802 may include one or more processors 804, such as one or more central processing units (CPUs) or graphics processing units (GPUs), and each processing unit may implement one or more hardware threads. The computer device 802 may also include any memory 806, which is used to store any kind of information such as code, settings, data, etc. In a specific embodiment, the computer program on the memory 806 and can be run on the processor 804, when the computer program is run by the processor 804, the instructions of the inter-service remote scheduling method described in any of the above embodiments may be executed. Non-limiting, for example, the memory 806 may include any one or more combinations of the following: any type of RAM, any type of ROM, flash memory device, hard disk, optical disk, etc. More generally, any memory may use any technology to store information. Further, any memory may provide volatile or non-volatile retention of information. Further, any memory may represent a fixed or removable component of the computer device 802. In one case, when the processor 804 executes an associated instruction stored in any memory or combination of memories, the computer device 802 may perform any operation of the associated instruction. The computer device 802 also includes one or more drive mechanisms 808 for interacting with any storage, such as a hard disk drive mechanism, an optical disk drive mechanism, etc.

[0171] The computer device 802 may also include an input / output interface 810 (I / O) for receiving various inputs (via input devices 812) and for providing various outputs (via output devices 814). A specific output mechanism may include a presentation device 816 and an associated graphical user interface 818 (GUI). In other embodiments, the input / output interface 810 (I / O), input device 812, and output device 814 may not be included, and the computer device 802 may be used as a computer device in a network. The computer device 802 may also include one or more network interfaces 820 for exchanging data with other devices via one or more communication links 822. One or more communication buses 824 couple the components described above together.

[0172] The communication link 822 may be implemented in any manner, for example, through a local area network, a wide area network (e.g., the Internet), a point-to-point connection, etc., or any combination thereof. The communication link 822 may include any combination of hardwired links, wireless links, routers, gateway functions, name servers, etc. governed by any protocol or combination of protocols.

[0173] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), computer-readable storage media, and computer program products of some embodiments of the present specification. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes 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 processor to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processor 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.

[0174] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processor to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including 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.

[0175] These computer program instructions can also be loaded onto a computer or other programmable data processor so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable device to implement 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.

[0176] In a typical configuration, a computer device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0177] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0178] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computer device. As defined in this specification, computer-readable media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0179] Those skilled in the art will appreciate that the embodiments of this specification may be provided as methods, systems or computer program products. Therefore, the embodiments of this specification may take the form of complete hardware embodiments, complete software embodiments or embodiments combining software and hardware. Moreover, the embodiments of this specification may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0180] The present specification embodiments may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present specification embodiments may also be practiced in distributed computing environments where tasks are performed by remote processors connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0181] It should also be understood that in the embodiments of this specification, the term "and / or" is only a description of the association relationship of the associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article generally indicates that the associated objects before and after are in an "or" relationship.

[0182] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0183] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiments of this specification. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0184] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims

1. A remote scheduling method between services, characterized in that: include: Receiving a remote call request message initiated by the first server for scheduling the second server; Obtaining from the configuration center the first legitimacy verification logic and the input parameter business verification logic corresponding to the remote call request message; Verify the legitimacy of the input parameter field of the remote call request message according to the first legitimacy verification logic, and verify the correctness of the input parameter business logic of the remote call request message according to the input parameter business verification logic to obtain a first verification result; Determining whether it is necessary to reassemble the input parameter structure of the remote call request message according to the first verification result; When the input parameter structure needs to be reassembled, the corresponding input parameter structure mapping template is obtained from the configuration center, and the input parameter structure is reassembled by using the reflection mechanism and the input parameter structure mapping template; The second server is called according to the reassembled input parameter structure.

2. The inter-service remote scheduling method according to claim 1, characterized in that: The reassembling of the input parameter structure by using the reflection mechanism and the input parameter structure mapping template includes: Based on the input parameter structure mapping template, the input parameter structure is reassembled using the ASM reflection mechanism.

3. The inter-service remote scheduling method according to claim 2, characterized in that: The step of reassembling the input parameter structure based on the input parameter structure mapping template and using the ASM reflection mechanism includes: Create a ClassReader object; Call the ClassReader object to parse the bytecode file of the input parameter structure to obtain the input parameter field attributes, request method and bytecode of the input parameter structure; Create a ClassVisitor class; Call the visitField method of the ClassVisitor class to determine whether the input parameter field attributes are consistent with the input parameter field attributes in the input parameter structure mapping template; and call the visitMehod method in the ClassVisitor class to determine whether the request method is consistent with the request method in the input parameter structure mapping template; Create the ClassWriter class; If it is inconsistent with the input parameter field attributes in the input parameter structure mapping template, the FieldWriter method of the ClassWriter class is called to overwrite the input parameter field attributes of the input parameter structure to be consistent with the input parameter field attributes in the input parameter structure mapping template; if it is inconsistent with the request method in the input parameter structure mapping template, the MethodWriter method of the ClassWriter class is called to overwrite the input parameter field attributes of the input parameter structure to be consistent with the input parameter field attributes in the input parameter structure mapping template; Modify the bytecode of the input parameter structure after overwriting the input parameter field attributes and / or request method.

4. The inter-service remote scheduling method according to claim 1, characterized in that: After determining whether it is necessary to reassemble the input parameter structure of the remote call request message according to the first verification result, the method further includes: When the input parameter structure does not need to be reassembled, the input parameter structure is transparently transmitted to the second server.

5. The inter-service remote scheduling method according to claim 1, characterized in that: After calling the second server according to the reassembled input parameter structure, the method further includes: Receive a remote call response message returned by the second server; Obtaining the second legitimacy verification logic and the parameter output business verification logic of the remote call response message from the configuration center; Verify the legitimacy of the outgoing parameter field of the remote call response message according to the second legitimacy verification logic, and verify the correctness of the outgoing parameter business logic of the remote call response message according to the outgoing parameter business verification logic to obtain a second verification result; Determining whether it is necessary to reassemble the output parameter structure of the remote call response message according to the second verification result; When the output parameter structure needs to be reassembled, the corresponding output parameter structure mapping template is obtained from the configuration center, and the output parameter structure is reassembled by using the reflection mechanism and the output parameter structure mapping template; The reassembled output parameter structure is returned to the first server.

6. The inter-service remote scheduling method according to claim 5, characterized in that: The reassembling of the output parameter structure by using the reflection mechanism and the output parameter structure mapping template includes: Based on the output parameter structure mapping template, the output parameter structure is reassembled using Javassist reflection.

7. The inter-service remote scheduling method according to claim 6, characterized in that: Based on the output parameter structure mapping template, the output parameter structure is reassembled using Javassist reflection, including: Get the CtClass object from the ClassPool class pool; Call the CtClass object to obtain the output parameter field attributes, return method and bytecode of the output parameter structure; Create CtField objects and CtMethod objects; Call the CtField object to check whether the output parameter field attribute is consistent with the output parameter field attribute in the output parameter structure mapping template, and call the CtMethod object to check whether the return method is consistent with the return method in the output parameter structure mapping template; If it is inconsistent with the output parameter field attributes in the output parameter structure mapping template, the addFileld method, removeField method and / or setModifiers method in the CtField object are called to overwrite the output parameter field attributes of the output parameter structure to be consistent with the output parameter field attributes in the output parameter structure mapping template; if it is inconsistent with the return method in the output parameter structure mapping template, the instrument method of the CtMethod object is called to overwrite the return method of the output parameter structure to be consistent with the return method in the output parameter structure mapping template.

8. The inter-service remote scheduling method according to claim 1, characterized in that: After receiving the remote call request initiated by the first server for scheduling the second server, the method further includes: When receiving the remote call request message returned by the first server, calling the preset JVM sandbox interception method to process the specified transaction; the specified transaction includes business monitoring, traffic recording and / or simulated fault request; Return to execute the main logic of remote call business.

9. The inter-service remote scheduling method according to claim 8, characterized in that: The calling of a preset JVM sandbox interception method to process a specified transaction includes: Execute the before method of the JVM sandbox to intercept the remote call request message and obtain the input parameter data of the remote call request message; Parse the input parameter data to obtain the business identity, and perform heap mapping processing on the business identity according to the business dimension; The request density of each of the service identities is calculated asynchronously by multiple threads, and the request density of each of the service identities is sent to a local designated queue.

10. A remote scheduling device between services, characterized in that: include: A receiving module, used to receive a remote call request message initiated by the first server for scheduling the second server; An acquisition module, used to acquire the first legitimacy verification logic and the input parameter business verification logic corresponding to the remote call request message from the configuration center; A verification module, used to verify the legitimacy of the input parameter field of the remote call request message according to the first legitimacy verification logic, and verify the correctness of the input parameter business logic of the remote call request message according to the input parameter business verification logic, to obtain a first verification result; A judgment module, used for judging whether it is necessary to reassemble the input parameter structure of the remote call request message according to the first verification result; An assembly module, used for obtaining a corresponding input parameter structure mapping template from the configuration center when the input parameter structure needs to be reassembled, and reassembling the input parameter structure by using a reflection mechanism and the input parameter structure mapping template; A calling module is used to call the second server according to the reassembled input parameter structure.

11. A computer device comprising a memory, a processor, and a computer program stored in the memory, characterized in that: When the computer program is executed by the processor, the computer program executes the instructions of the method according to any one of claims 1 to 9.

12. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor of a computer device, the computer program executes the instructions of the method according to any one of claims 1 to 9.

13. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor of a computer device, the computer program executes instructions of the method according to any one of claims 1 to 9.

Citation Information

Cited By

  • Fault alarm method based on JVM-Sandbox

    CN119537161A

  • A Fault Warning Method Based on JVM-Sandbox

    CN119537161B