A distributed service processing method, device and system
By receiving and processing key values and operation information in service processing information, using load balancing devices and SQL reverse analysis, the problems of low processing efficiency and data consistency of distributed services are solved, applicable scenarios are expanded and fault tolerance is improved.
Patent Information
- Application Number
- CN202110373823.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-07
- Publication Date
- 2025-01-14
- Estimated Expiration
- 2041-04-07
Smart Images

Figure CN113761056B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, device and system for processing distributed services. Background Art
[0002] Existing methods mainly use two-phase submission method, three-phase submission method, redo log method and other methods to solve the problem of data consistency between application systems that needs to be guaranteed in the process of distributed business processing.
[0003] There are at least the following problems in the prior art:
[0004] The existing distributed business processing methods have low business efficiency because they need to embed code to obtain database resources. At the same time, they still cannot solve the data consistency problem in special situations such as network disconnection and message loss, resulting in few business processing adaptation scenarios. Summary of the invention
[0005] In view of this, the embodiments of the present invention provide a method, device and system for processing distributed services, which can improve service processing efficiency, ensure data consistency, and expand applicable scenarios of service processing.
[0006] To achieve the above object, according to a first aspect of an embodiment of the present invention, a method for processing a distributed service is provided, comprising:
[0007] Receive business processing information sent by the first business system, obtain key values and operation information in the business processing information, and send a first response to the first business system; so that the first business processing system performs business processing on the business method, and sends a call request containing the key value to the second business system; wherein the key value is generated by the first business system according to the business method intercepted by the method annotation;
[0008] Receiving a business processing request including a key value sent by the second business system according to the call request, and sending operation information corresponding to the key value to the second business system, so that the second business system performs corresponding business processing according to the operation information;
[0009] When it is determined that both the first service system and the second service system have processed successfully, it is determined that the distributed service processing is successful.
[0010] Furthermore, before the first business processing system performs the step of business processing on the business method, the method further includes:
[0011] The first business system is used to determine target data in the business processing information according to SQL reverse analysis, and the target data is backed up.
[0012] Furthermore, after the steps of receiving the business processing information sent by the first business system and acquiring the key value and operation information in the business processing information, the method further includes:
[0013] Determine the message type of the business processing message, and determine the first response method according to the message type.
[0014] Furthermore, when the message type is a conversation message, the method further includes:
[0015] Determine the session type of the session message;
[0016] A first session is determined according to the session type and the key value, and a first response is sent to the first system.
[0017] Furthermore, if at least one of the processing of the first business system and the second business system fails, the target data after the backup processing is rolled back and the business processing is performed again.
[0018] Furthermore, before the step of receiving the service processing information sent by the first service system, the method further includes:
[0019] Respectively obtaining access requests from the first business system and the second business system;
[0020] The access rights of the first business system and the second business system are determined according to the right setting information and the access request.
[0021] Furthermore, the system states of the first business system and the second business system are monitored, and feedback information is sent to the first business system and the second business system according to the system states.
[0022] According to a second aspect of an embodiment of the present invention, a distributed service processing device is provided, including:
[0023] An information receiving module is used to receive business processing information sent by the first business system, obtain key values and operation information in the business processing information, and send a first response to the first business system; so that the first business processing system performs business processing on the business method, and sends a call request containing the key value to the second business system; wherein the key value is generated by the first business system according to the business method intercepted by the method annotation;
[0024] The response sending module receives the business processing request containing the key value sent by the second business system according to the call request, and sends the operation information corresponding to the key value to the second business system, so that the second business system performs the corresponding business processing according to the operation information;
[0025] The business processing module is used to determine that the distributed business processing is successful when it is determined that both the first business system and the second business system have processed successfully.
[0026] According to a third aspect of an embodiment of the present invention, a distributed service processing system is provided, including a first service system, a second service system and the distributed service processing device.
[0027] According to a fourth aspect of an embodiment of the present invention, there is provided an electronic device, including:
[0028] one or more processors;
[0029] a storage device for storing one or more programs,
[0030] When one or more programs are executed by one or more processors, the one or more processors implement any of the above-mentioned distributed service processing methods.
[0031] According to a fifth aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored, and when the program is executed by a processor, any of the above-mentioned distributed service processing methods is implemented.
[0032] An embodiment of the above invention has the following advantages or beneficial effects: because it adopts the method of receiving business processing information sent by the first business system, obtaining the key value and operation information in the business processing information, and sending a first response to the first business system; so that the first business processing system performs business processing on the business method, and sends a call request containing the key value to the second business system; wherein the key value is generated by the business method intercepted by the first business system according to the method annotation; receiving the business processing request containing the key value sent by the second business system according to the call request, and sending the operation information corresponding to the key value to the second business system, so that the second business system performs the corresponding business processing according to the operation information; when it is determined that both the first business system and the second business system have successfully processed, the technical means for determining the successful processing of the distributed business is overcome, thereby overcoming the technical problems of low business efficiency and few business processing adaptation scenarios in the existing distributed business processing methods, thereby achieving the technical effect of improving business processing efficiency, ensuring data consistency, and expanding the applicable scenarios of business processing.
[0033] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0035] Figure 1 is a schematic diagram of the main process of the method for processing distributed services provided according to the first embodiment of the present invention;
[0036] Figure 2is a schematic diagram of the main process of a method for processing distributed services provided according to a second embodiment of the present invention;
[0037] Figure 3 is a schematic diagram of main modules of a distributed service processing device provided according to an embodiment of the present invention;
[0038] Figure 4 is a schematic diagram of the main framework of a distributed service processing system provided according to an embodiment of the present invention;
[0039] Figure 5 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0040] Figure 6 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0041] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0042] Figure 1 is a schematic diagram of the main flow of the method for processing distributed services provided according to the first embodiment of the present invention; Figure 1 As shown, the distributed service processing method provided by the embodiment of the present invention mainly includes:
[0043] Step S101, receiving business processing information sent by the first business system, obtaining key values and operation information in the business processing information, and sending a first response to the first business system; so that the first business processing system performs business processing on the business method, and sends a call request containing the key value to the second business system; wherein the key value is generated by the first business system according to the business method intercepted by the method annotation.
[0044] Specifically, according to an embodiment of the present invention, the present invention connects the first business system and the second business system respectively through a load balancing device. According to a specific implementation of the embodiment of the present invention, the load balancer ZooKeeper (a distributed, open source distributed application coordination service) can be used to execute the steps in the above processing method.
[0045] Preferably, according to an embodiment of the present invention, before the step of receiving the service processing information sent by the first service system, the method further includes:
[0046] Respectively obtaining access requests from the first service system and the second service system;
[0047] The access rights of the first business system and the second business system are determined according to the right setting information and the access request.
[0048] Specifically, according to an embodiment of the present invention, the first business system and the second system connected to the load balancing device are authenticated and authorized (by sending appkey) through permission settings, so as to facilitate the subsequent monitoring of the system status and processing status of the connected business system, thereby ensuring data consistency. According to a specific implementation of the embodiment of the present invention, the first business system and the second business system can use JSF (JavaServer Faces, a user interface framework based on server-side components) to implement calls (message interactions) between systems.
[0049] Further, according to an embodiment of the present invention, before the first business processing system performs the business processing on the business method, the method further includes:
[0050] The first business system is used to determine target data in the business processing information according to SQL reverse analysis, and the target data is backed up.
[0051] Specifically, according to an embodiment of the present invention, based on SQL reverse analysis (generating a code that can be executed by the database based on a single database table of an SQL statement), the affected data (target data, the object of the business processing) in the business processing message is determined, and then the target data is backed up. Through the above settings, after the business system executes the corresponding business processing, the received business data can be deleted to save the storage space occupied by the business system. Another convenience is that since the target data is backed up, if the business system fails to execute the business processing later, different logical data rollbacks can be performed according to the type of SQL statement, thereby realizing the re-execution of the business processing on the corresponding data (i.e., the target data that needs to be processed).
[0052] Preferably, according to an embodiment of the present invention, after the steps of receiving the business processing information sent by the first business system and acquiring the key value and operation information in the business processing information, the method further includes:
[0053] Determine the message type of the business processing message, and determine the first response method according to the message type.
[0054] Specifically, according to an embodiment of the present invention, message types include pong message types (Ping-pong is essentially a means of data buffering (a data transmission technology), which can use two data buffers at the same time to achieve the purpose of continuous data transmission, thereby improving the data transmission rate. Since the data obtained by a single buffer is easily overwritten during transmission and processing, the Ping-pong buffer method can always keep the data in one buffer being used, and the other buffer is used to store data. That is, two identical objects are read and written alternately as buffers) and session types, and different response methods are executed for different types of business processing messages. If the business processing message is a pong message, it only needs to confirm receipt (ack).
[0055] Exemplarily, according to an embodiment of the present invention, when the message type is a conversation message, the method further includes:
[0056] Determine the session type of the session message;
[0057] A first session is determined according to the session type and the key value, and a first response is sent to the first system.
[0058] Specifically, according to an embodiment of the present invention, the session types include creating a new session, joining a session, and session notification.
[0059] If the session type of the session message is a new session, the load balancing device determines whether a message record corresponding to the key is stored locally according to the current key value; if so, it means that the session type corresponding to the service processing message is not a new session, and a first response indicating an error needs to be returned; if not, the service processing message corresponding to the key value is saved, and then the first response received is returned;
[0060] If the session type of the session message is to join a session, the load balancing device determines whether there is a corresponding session for the current key value key; if not, a new session is created for the service processing message corresponding to the key value; if yes, the service processing message corresponding to the key value is saved to the corresponding existing session and a first response is returned;
[0061] If the session type of the session message is a session notification received from an application, the load balancer is required to determine whether there is an exception in the current notification result; if so, all business processing message records saved in the load balancing device are searched according to the key, and a recovery operation is sent. If the exception still exists, the business processing message is prioritized in the queue for subsequent compensation operations. According to a specific implementation of an embodiment of the present invention, if the current notification result is normal, the business processing message corresponding to the key value is stored in redis, and an update expiration time is set for the stored business processing message, so that after the expiration time is reached, it is determined whether the stored business processing message is successfully processed in both the first business system and the second business system. If both are successfully processed, the stored message is transferred and stored to confirm the end of distributed business processing.
[0062] Step S102, receiving a business processing request including a key value sent by the second business system according to the call request, and sending operation information corresponding to the key value to the second business system, so that the second business system performs corresponding business processing according to the operation information.
[0063] Specifically, according to an embodiment of the present invention, the load balancing device supports a master-slave mode, where the first service system is the master system. After the master system completes processing, the second service system is called to perform corresponding service processing to achieve distributed processing of services.
[0064] Step S103: When it is determined that both the first service system and the second service system have processed successfully, it is determined that the distributed service processing is successful.
[0065] Specifically, the processing results of the first business system and the second business system are checked to ensure data consistency in the distributed business system. This avoids the situation where the first business system and the second business system cannot communicate or fail to communicate when the network is disconnected or the message is lost, and the data consistency problem cannot be guaranteed, thus expanding the applicable scenarios of business processing.
[0066] On the other hand, according to an embodiment of the present invention, if at least one of the processing of the first business system and the second business system fails, the target data after the backup processing is rolled back and the business processing is performed again.
[0067] According to the embodiment of the present invention, by rolling back the backed-up data and executing business processing on it again, the business processing efficiency is improved and the fault tolerance in the business processing process is enhanced.
[0068] Further, according to an embodiment of the present invention, the system states of the first business system and the second business system are monitored, and feedback information is sent to the first business system and the second business system according to the system states.
[0069] Specifically, according to an embodiment of the present invention, the application heartbeat of the business system is monitored. When the business system loses the heartbeat, a system status corresponding to the business system is logged, and the log is sent to the business system in a timely manner. When the business system resumes normal operation, it can determine based on the log whether the corresponding business processing message completely executes the corresponding business processing during the abnormal system status, thereby expanding the applicable scenarios of business processing.
[0070] According to the technical solution of the embodiment of the present invention, because the business processing information sent by the first business system is received, the key value and operation information in the business processing information are obtained, and the first response is sent to the first business system; so that the first business processing system performs business processing on the business method, and sends a call request containing the key value to the second business system; wherein the key value is generated by the first business system according to the business method intercepted by the method annotation; the business processing request containing the key value sent by the second business system according to the call request is received, and the operation information corresponding to the key value is sent to the second business system, so that the second business system performs corresponding business processing according to the operation information; when it is determined that both the first business system and the second business system have successfully processed, the technical means for determining the success of the distributed business processing is overcome, thereby overcoming the technical problems of low business efficiency and few business processing adaptation scenarios in the existing distributed business processing methods, thereby achieving the technical effect of improving business processing efficiency, ensuring data consistency, and expanding the applicable scenarios of business processing.
[0071] Figure 2 is a schematic diagram of the main process of the method for processing distributed services provided by the second embodiment of the present invention; Figure 2 As shown, the distributed service processing method provided by the embodiment of the present invention mainly includes:
[0072] Step S201, respectively obtaining access requests from the first business system and the second business system; and determining access permissions of the first business system and the second business system according to permission setting information and the access requests.
[0073] Specifically, according to an embodiment of the present invention, the present invention connects the first business system and the second business system respectively through a load balancing device. For the first business system and the second system connected to the load balancing device, authentication and authorization operations are implemented through permission settings, so as to facilitate subsequent monitoring of the system status and processing status of the connected business system, thereby ensuring data consistency.
[0074] Step S202, receiving business processing information sent by the first business system, and obtaining key values and operation information in the business processing information, wherein the key values are generated by the first business system according to the business method intercepted by the method annotation.
[0075] Specifically, according to an embodiment of the present invention, the first business system adds a method annotation to the target method, then intercepts the request through AOP (Aspect Oriented Programming), generates a globally unique key, and sends a business processing message containing the key to the load balancing device.
[0076] By adding method annotations, the intrusive embedding of code is replaced, database support is achieved, and business processing efficiency is improved.
[0077] Step S203, determining the message type of the business processing message, and determining the first response mode according to the message type.
[0078] Specifically, according to an embodiment of the present invention, message types include pong message types (Ping-pong is essentially a means of data buffering (a data transmission technology), which can use two data buffers at the same time to achieve the purpose of continuous data transmission, thereby improving the data transmission rate. Since the data obtained by a single buffer is easily overwritten during transmission and processing, the Ping-pong buffer method can always keep the data in one buffer being used, and the other buffer is used to store data. That is, two identical objects are read and written alternately as buffers) and session types, and different response methods are executed for different types of business processing messages. If the business processing message is a pong message, it only needs to confirm receipt (ack).
[0079] Exemplarily, according to an embodiment of the present invention, when the message type is a conversation message, the method further includes:
[0080] Determine the session type of the session message;
[0081] A first session is determined according to the session type and the key value, and a first response is sent to the first system.
[0082] Specifically, according to an embodiment of the present invention, the session types include creating a new session, joining a session, and session notification.
[0083] If the session type of the session message is a new session, the load balancing device determines whether a message record corresponding to the key is stored locally according to the current key value; if so, it means that the session type corresponding to the service processing message is not a new session, and a first response indicating an error needs to be returned; if not, the service processing message corresponding to the key value is saved, and then the first response received is returned;
[0084] If the session type of the session message is to join a session, the load balancing device determines whether there is a corresponding session for the current key value key; if not, a new session is created for the service processing message corresponding to the key value; if yes, the service processing message corresponding to the key value is saved to the corresponding existing session and a first response is returned;
[0085] If the session type of the session message is a session notification received from an application, the load balancer is required to determine whether there is an exception in the current notification result; if so, all business processing message records saved in the load balancing device are searched according to the key, and a recovery operation is sent. If the exception still exists, the business processing message is prioritized in the queue for subsequent compensation operations. According to a specific implementation of an embodiment of the present invention, if the current notification result is normal, the business processing message corresponding to the key value is stored in redis, and an update expiration time is set for the stored business processing message, so that after the expiration time is reached, it is determined whether the stored business processing message is successfully processed in both the first business system and the second business system. If both are successfully processed, the stored message is transferred and stored to confirm the end of distributed business processing.
[0086] Step S204: using the first business system to determine target data in the business processing information based on SQL reverse analysis, and backing up the target data.
[0087] Specifically, according to an embodiment of the present invention, based on SQL reverse analysis (generating code that can be executed by the database based on a single database table of the SQL statement), the affected data (target data, the object of business processing) in the business processing message is determined, and then the target data is backed up, so that if the business system fails to execute the business processing later, different logical data rollbacks are performed according to the type of SQL statement, thereby realizing the re-execution of business processing on the corresponding data.
[0088] Step S205, the first business processing system performs business processing on the business method, and sends a call request containing a key value to the second business system; wherein the key value is generated by the first business system according to the business method intercepted by the method annotation.
[0089] Specifically, according to an embodiment of the present invention, a global lock may be introduced during business processing to avoid concurrency problems caused by operating data corresponding to the database under high concurrency conditions. Locking the affected row data helps prevent data confusion.
[0090] Step S206, receiving a business processing request including a key value sent by the second business system according to the call request, and sending operation information corresponding to the key value to the second business system, so that the second business system performs corresponding business processing according to the operation information.
[0091] Specifically, after receiving the call request from the first business system, the second business system notifies the load balancing device according to the unique key contained in the call request, so that the load balancing device verifies and records the key and the corresponding operation information, and sends a second response containing the operation information to the second business system. After the response indicates that the verification is successful, the second business system executes the corresponding business logic. At the same time, before business processing, the second business system can also perform snapshot extraction and data backup and storage on the data involved.
[0092] Specifically, according to an embodiment of the present invention, the load balancing device supports a master-slave mode, where the first service system is the master system. After the master system completes processing, the second service system is called to perform corresponding service processing to achieve distributed processing of services.
[0093] Step S207, obtain the processing results of the first business system and the second business system, and determine whether both processing results are successful. If so, that is, both processing results are successful, execute step S209; if not, that is, at least one of the two processing results fails, go to step S208.
[0094] Specifically, the processing results of the first business system and the second business system are checked to ensure data consistency in the distributed business system. This avoids the situation where the first business system and the second business system cannot communicate or fail to communicate when the network is disconnected or the message is lost, and the data consistency problem cannot be guaranteed, thus expanding the applicable scenarios of business processing.
[0095] Step S208, using the business system that failed to process to roll back the target data after the backup process, and execute the business process again.
[0096] According to the embodiment of the present invention, by rolling back the backed-up data and executing business processing on it again, the business processing efficiency is improved and the fault tolerance in the business processing process is enhanced.
[0097] Step S209: determining that the distributed service processing is successful.
[0098] Further, according to an embodiment of the present invention, the system states of the first business system and the second business system are monitored, and feedback information is sent to the first business system and the second business system according to the system states.
[0099] Specifically, according to an embodiment of the present invention, the application heartbeat of the business system is monitored. When the business system loses the heartbeat, a system status corresponding to the business system is logged, and the log is sent to the business system in a timely manner. When the business system resumes normal operation, it can determine based on the log whether the corresponding business processing message completely executes the corresponding business processing during the abnormal system status, thereby expanding the applicable scenarios of business processing.
[0100] According to a specific implementation of an embodiment of the present invention, when the first business system and the second business system are started, a resident single thread is automatically started to perform a pong operation by embedding an SDK (Software Development Kit) to monitor and record system conditions such as unresponsive heartbeats.
[0101] According to the technical solution of the embodiment of the present invention, because the business processing information sent by the first business system is received, the key value and operation information in the business processing information are obtained, and the first response is sent to the first business system; so that the first business processing system performs business processing on the business method, and sends a call request containing the key value to the second business system; wherein the key value is generated by the first business system according to the business method intercepted by the method annotation; the business processing request containing the key value sent by the second business system according to the call request is received, and the operation information corresponding to the key value is sent to the second business system, so that the second business system performs corresponding business processing according to the operation information; when it is determined that both the first business system and the second business system have successfully processed, the technical means for determining the success of the distributed business processing is overcome, thereby overcoming the technical problems of low business efficiency and few business processing adaptation scenarios in the existing distributed business processing methods, thereby achieving the technical effect of improving business processing efficiency, ensuring data consistency, and expanding the applicable scenarios of business processing.
[0102] Figure 3 is a schematic diagram of main modules of a distributed service processing device provided according to an embodiment of the present invention; Figure 3 As shown, the distributed service processing device 300 provided in the embodiment of the present invention mainly includes:
[0103] The information receiving module 301 is used to receive the business processing information sent by the first business system, obtain the key value and operation information in the business processing information, and send a first response to the first business system; so that the first business processing system performs business processing on the business method, and sends a call request containing the key value to the second business system; wherein the key value is generated by the first business system according to the business method intercepted by the method annotation.
[0104] Specifically, according to an embodiment of the present invention, before the step of receiving the service processing information sent by the first service system, the method further includes:
[0105] Respectively obtaining access requests from the first service system and the second service system;
[0106] The access rights of the first business system and the second business system are determined according to the right setting information and the access request.
[0107] Specifically, according to an embodiment of the present invention, the present invention connects the first business system and the second business system respectively through a load balancing device. For the first business system and the second system connected to the load balancing device, authentication and authorization operations are implemented through permission settings, so as to facilitate subsequent monitoring of the system status and processing status of the connected business system, thereby ensuring data consistency.
[0108] Further, according to an embodiment of the present invention, the above-mentioned distributed service processing device 300 further includes a backup module, which is used before the first service processing system performs the service processing step on the service method to:
[0109] The first business system is used to determine target data in the business processing information according to SQL reverse analysis, and the target data is backed up.
[0110] Specifically, according to an embodiment of the present invention, based on SQL reverse analysis (generating a code that can be executed by the database based on a single database table of an SQL statement), the affected data (target data, the object of the business processing) in the business processing message is determined, and then the target data is backed up. Through the above settings, after the business system executes the corresponding business processing, the received business data can be deleted to save the storage space occupied by the business system. Another convenience is that the backup data is helpful for subsequent data rollbacks of different logics according to the type of SQL statement if the business system fails to execute the business processing, thereby realizing the re-execution of the business processing on the corresponding data.
[0111] Preferably, according to an embodiment of the present invention, the above-mentioned distributed service processing device 300 further includes a response mode determination module, which is used to:
[0112] Determine the message type of the business processing message, and determine the first response method according to the message type.
[0113] Specifically, according to an embodiment of the present invention, message types include pong message types (Ping-pong is essentially a means of data buffering (a data transmission technology), which can use two data buffers at the same time to achieve the purpose of continuous data transmission, thereby improving the data transmission rate. Since the data obtained by a single buffer is easily overwritten during transmission and processing, the Ping-pong buffer method can always keep the data in one buffer being used, and the other buffer is used to store data. That is, two identical objects are read and written alternately as buffers) and session types, and different response methods are executed for different types of business processing messages. If the business processing message is a pong message, it only needs to confirm receipt (ack).
[0114] Exemplarily, according to an embodiment of the present invention, when the message type is a conversation message, the response mode determination module is further configured to:
[0115] Determine the session type of the session message;
[0116] A first session is determined according to the session type and the key value, and a first response is sent to the first system.
[0117] Specifically, according to an embodiment of the present invention, the session types include creating a new session, joining a session, and session notification.
[0118] If the session type of the session message is a new session, the load balancing device determines whether a message record corresponding to the key is stored locally according to the current key value; if so, it means that the session type corresponding to the service processing message is not a new session, and a first response indicating an error needs to be returned; if not, the service processing message corresponding to the key value is saved, and then the first response received is returned;
[0119] If the session type of the session message is to join a session, the load balancing device determines whether there is a corresponding session for the current key value key; if not, a new session is created for the service processing message corresponding to the key value; if yes, the service processing message corresponding to the key value is saved to the corresponding existing session and a first response is returned;
[0120] If the session type of the session message is a session notification received from an application, the load balancer is required to determine whether there is an exception in the current notification result; if so, all business processing message records saved in the load balancing device are searched according to the key, and a recovery operation is sent. If the exception still exists, the business processing message is prioritized in the queue for subsequent compensation operations. According to a specific implementation of an embodiment of the present invention, if the current notification result is normal, the business processing message corresponding to the key value is stored in redis, and an update expiration time is set for the stored business processing message, so that after the expiration time is reached, it is determined whether the stored business processing message is successfully processed in both the first business system and the second business system. If both are successfully processed, the stored message is transferred and stored to confirm the end of distributed business processing.
[0121] The response sending module 302 receives the business processing request containing the key value sent by the second business system according to the call request, and sends the operation information corresponding to the key value to the second business system, so that the second business system performs corresponding business processing according to the operation information.
[0122] Specifically, according to an embodiment of the present invention, the load balancing device supports a master-slave mode, where the first service system is the master system. After the master system completes processing, the second service system is called to perform corresponding service processing to achieve distributed processing of services.
[0123] The business processing module 303 is used to determine that the distributed business processing is successful when it is determined that both the first business system and the second business system have processed successfully.
[0124] Specifically, the processing results of the first business system and the second business system are checked to ensure data consistency in the distributed business system. This avoids the situation where the first business system and the second business system cannot communicate or fail to communicate when the network is disconnected or the message is lost, and the data consistency problem cannot be guaranteed, thus expanding the applicable scenarios of business processing.
[0125] On the other hand, according to an embodiment of the present invention, if at least one of the first business system and the second business system fails in processing, the business processing module 303 is further used to: roll back the target data after the backup processing, and execute the business processing again.
[0126] According to the embodiment of the present invention, by rolling back the backed-up data and executing business processing on it again, the business processing efficiency is improved and the fault tolerance in the business processing process is enhanced.
[0127] Furthermore, according to an embodiment of the present invention, the distributed service processing device 300 further includes a monitoring module, which is used to:
[0128] Monitor the system status of the first business system and the second business system, and send feedback information to the first business system and the second business system according to the system status.
[0129] Specifically, according to an embodiment of the present invention, the application heartbeat of the business system is monitored. When the business system loses the heartbeat, a system status corresponding to the business system is logged, and the log is sent to the business system in a timely manner. When the business system resumes normal operation, it can determine based on the log whether the corresponding business processing message completely executes the corresponding business processing during the abnormal system status, thereby expanding the applicable scenarios of business processing.
[0130] According to the technical solution of the embodiment of the present invention, because the business processing information sent by the first business system is received, the key value and operation information in the business processing information are obtained, and the first response is sent to the first business system; so that the first business processing system performs business processing on the business method, and sends a call request containing the key value to the second business system; wherein the key value is generated by the first business system according to the business method intercepted by the method annotation; the business processing request containing the key value sent by the second business system according to the call request is received, and the operation information corresponding to the key value is sent to the second business system, so that the second business system performs corresponding business processing according to the operation information; when it is determined that both the first business system and the second business system have successfully processed, the technical means for determining the success of the distributed business processing is overcome, thereby overcoming the technical problems of low business efficiency and few business processing adaptation scenarios in the existing distributed business processing methods, thereby achieving the technical effect of improving business processing efficiency, ensuring data consistency, and expanding the applicable scenarios of business processing.
[0131] Figure 4 Schematic diagram of the main framework of the distributed service processing system provided according to an embodiment of the present invention; Figure 4 As shown, the distributed service processing system 400 provided in the embodiment of the present invention mainly includes:
[0132] The load balancer 401 (i.e., the processing device of the above-mentioned distributed business) is used to receive access requests for the first business system and the second business system respectively; determine the access rights of the first business system and the second business system according to the permission setting information and the access request; receive the business processing information sent by the first business system, obtain the key value and operation information in the business processing information, and send a first response to the first business system; receive the business processing request containing the key value sent by the second business system according to the call request, and send the operation information corresponding to the key value to the second business system; when it is determined that the first business system and the second business system have both processed successfully, it is determined that the distributed business processing is successful.
[0133] Specifically, the load balancer 401 further includes: a backup module, which is used before the first business processing system performs the business processing step on the business method:
[0134] The first business system is used to determine target data in the business processing information according to SQL reverse analysis, and the target data is backed up.
[0135] Specifically, according to an embodiment of the present invention, based on SQL reverse analysis (generating code that can be executed by the database based on a single database table of the SQL statement), the affected data (target data, the object of business processing) in the business processing message is determined, and then the target data is backed up, so that if the business system fails to execute the business processing later, different logical data rollbacks are performed according to the type of SQL statement, thereby realizing the re-execution of business processing on the corresponding data.
[0136] Further, according to an embodiment of the present invention, the load balancer 401 further includes a monitoring module, which is used to:
[0137] Monitor the system status of the first business system and the second business system, and send feedback information to the first business system and the second business system according to the system status.
[0138] Specifically, according to an embodiment of the present invention, the application heartbeat of the business system is monitored. When the business system loses the heartbeat, a system status corresponding to the business system is logged, and the log is sent to the business system in a timely manner. When the business system resumes normal operation, it can determine based on the log whether the corresponding business processing message completely executes the corresponding business processing during the abnormal system status, thereby expanding the applicable scenarios of business processing.
[0139] The first business system 402 is used to send an access request to the load balancer to determine the access authority, and send business processing information to the load balancer according to the access authority. After obtaining the first response returned by the load balancer, it performs business processing on the business method and sends a call request containing a key value to the second business system.
[0140] The second business system 403 is used to send an access request to the load balancer to determine the access authority; after receiving the call request containing the key value sent by the first business system, it sends the business processing request containing the key value to the load balancer according to the access authority, and performs corresponding business processing according to the operation information corresponding to the key value returned by the load balancer.
[0141] According to an embodiment of the present invention, if at least one of the first business system and the second business system fails in processing, the first business system and / or the second business system (the business system that failed in processing) is also used to: roll back the target data after backup processing and execute the business processing again.
[0142] According to the embodiment of the present invention, by rolling back the backed-up data and executing business processing on it again, the business processing efficiency is improved and the fault tolerance in the business processing process is enhanced.
[0143] According to the technical solution of the embodiment of the present invention, because the business processing information sent by the first business system is received, the key value and operation information in the business processing information are obtained, and the first response is sent to the first business system; so that the first business processing system performs business processing on the business method, and sends a call request containing the key value to the second business system; wherein the key value is generated by the first business system according to the business method intercepted by the method annotation; the business processing request containing the key value sent by the second business system according to the call request is received, and the operation information corresponding to the key value is sent to the second business system, so that the second business system performs corresponding business processing according to the operation information; when it is determined that both the first business system and the second business system have successfully processed, the technical means for determining the success of the distributed business processing is overcome, thereby overcoming the technical problems of low business efficiency and few business processing adaptation scenarios in the existing distributed business processing methods, thereby achieving the technical effect of improving business processing efficiency, ensuring data consistency, and expanding the applicable scenarios of business processing.
[0144] Figure 5 An exemplary system architecture 500 is shown to which a distributed service processing method or a distributed service processing apparatus according to an embodiment of the present invention can be applied.
[0145] like Figure 5 As shown, the system architecture 500 may include terminal devices 501, 502, 503, a network 504 and a server 505 (this architecture is only an example, and the components included in the specific architecture may be adjusted according to the specific application). The network 504 is used to provide a medium for a communication link between the terminal devices 501, 502, 503 and the server 505. The network 504 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0146] Users can use terminal devices 501, 502, 503 to interact with server 505 through network 504 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 501, 502, 503, such as business processing applications, web browser applications, search applications, instant messaging tools, data processing applications, etc. (only examples).
[0147] The terminal devices 501 , 502 , and 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0148] The server 505 may be a server that provides various services, such as a server that performs business processing / data processing (for example only) for users using the terminal devices 501, 502, and 503. The server may analyze and process the received business processing information and other data, and feed back the processing result (for example, the first response - for example only) to the terminal device.
[0149] It should be noted that the distributed service processing method provided in the embodiment of the present invention is generally executed by the server 505 , and accordingly, the distributed service processing device is generally disposed in the server 505 .
[0150] It should be understood that Figure 5 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0151] Reference below Figure 6 , which shows a schematic diagram of the structure of a computer system 600 of a terminal device or a server suitable for implementing an embodiment of the present invention. Figure 6 The terminal device or server shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0152] like Figure 6 As shown, the computer system 600 includes a central processing unit (CPU) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage part 608 into a random access memory (RAM) 603. In the RAM 603, various programs and data required for the operation of the system 600 are also stored. The CPU 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0153] The following components are connected to the I / O interface 605: an input section 606 including a keyboard, a mouse, etc.; an output section 607 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 608 including a hard disk, etc.; and a communication section 609 including a network interface card such as a LAN card, a modem, etc. The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the I / O interface 605 as needed. A removable medium 611, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 610 as needed, so that a computer program read therefrom is installed into the storage section 608 as needed.
[0154] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 609, and / or installed from the removable medium 611. When the computer program is executed by the central processing unit (CPU) 601, the above-mentioned functions defined in the system of the present invention are executed.
[0155] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0156] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0157] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be set in a processor. For example, they may be described as: a processor includes an information receiving module, a response sending module, and a business processing module. The names of these modules do not, in some cases, constitute limitations on the modules themselves. For example, the information receiving module may also be described as "a module for receiving business processing information sent by a first business system, obtaining key values and operation information in the business processing information, and sending a first response to the first business system; so that the first business processing system performs business processing on the business method, and sends a call request containing the key value to the second business system."
[0158] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs. When the above one or more programs are executed by a device, the device includes: receiving business processing information sent by the first business system, obtaining key values and operation information in the business processing information, and sending a first response to the first business system; so that the first business processing system performs business processing on the business method, and sends a call request containing a key value to the second business system; wherein the key value is generated by the first business system according to the business method intercepted by the method annotation; receiving the business processing request containing a key value sent by the second business system according to the call request, and sending the operation information corresponding to the key value to the second business system, so that the second business system performs corresponding business processing according to the operation information; when it is determined that both the first business system and the second business system have successfully processed, it is determined that the distributed business processing is successful.
[0159] According to the technical solution of the embodiment of the present invention, because the business processing information sent by the first business system is received, the key value and operation information in the business processing information are obtained, and the first response is sent to the first business system; so that the first business processing system performs business processing on the business method, and sends a call request containing the key value to the second business system; wherein the key value is generated by the first business system according to the business method intercepted by the method annotation; the business processing request containing the key value sent by the second business system according to the call request is received, and the operation information corresponding to the key value is sent to the second business system, so that the second business system performs corresponding business processing according to the operation information; when it is determined that both the first business system and the second business system have successfully processed, the technical means for determining the success of the distributed business processing is overcome, thereby overcoming the technical problems of low business efficiency and few business processing adaptation scenarios in the existing distributed business processing methods, thereby achieving the technical effect of improving business processing efficiency, ensuring data consistency, and expanding the applicable scenarios of business processing.
[0160] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for processing distributed services, characterized in that: Applicable to load balancing devices, including: Receive business processing information sent by the first business system, obtain the key value and operation information in the business processing information, determine the message type of the business processing message, and determine the response mode of the first response according to the message type; if the message type is a session message, determine the first session according to the session type and the key value, and send the first response to the first system; wherein the session type includes a new session, a join session, and a session notification; if the session type is a new session, save the business processing message corresponding to the key value, and then return the received first response; if the session type is a join session, save the business processing message corresponding to the key value to the corresponding existing session, and return the first response; If the session type is a session notification received from an application; determine whether there is an exception in the current notification result of the session notification; if there is an exception, search for all saved business processing message records according to the key value, and send a recovery operation; if there is still an exception, put the business processing message into the queue first to facilitate subsequent compensation operations; if the current notification result is normal, store the business processing message corresponding to the key value in redis, and set an update expiration time for the stored business processing message, so that after the expiration time is reached, determine whether the stored business processing message is successfully processed in both the first business system and the second business system. If both are successfully processed, transfer and store the stored message to confirm the end of distributed business processing; Sending a first response to the first business system; so that the first business processing system performs business processing on the business method, and sends a call request containing the key value to the second business system; wherein the key value is generated by the first business system according to the business method intercepted by the method annotation; receiving a business processing request including the key value sent by the second business system according to the calling request, and sending operation information corresponding to the key value to the second business system, so that the second business system performs corresponding business processing according to the operation information; When it is determined that both the first business system and the second business system have processed successfully, it is determined that the distributed business processing is successful.
2. The method for processing distributed services according to claim 1, characterized in that: Before the first business processing system performs business processing on the business method, the method further includes: The first business system is used to determine target data in the business processing information according to SQL reverse analysis, and the target data is backed up.
3. The method for processing distributed services according to claim 2, characterized in that: If at least one of the first business system and the second business system fails in processing, the target data after the backup processing is rolled back and the business processing is performed again.
4. The method for processing distributed services according to claim 1, characterized in that: Before the step of receiving the service processing information sent by the first service system, the method further includes: Respectively obtaining access requests from the first service system and the second service system; The access rights of the first business system and the second business system are determined according to the right setting information and the access request.
5. The method for processing distributed services according to claim 1, characterized in that: Monitor the system status of the first business system and the second business system, and send feedback information to the first business system and the second business system according to the system status.
6. A distributed service processing device, characterized in that: include: An information receiving module, used to receive business processing information sent by the first business system, obtain key values and operation information in the business processing information, determine a message type of the business processing message, and determine a response mode of the first response according to the message type; In the case where the message type is a session message, determining the session type of the session message; determining a first session according to the session type and the key value, and sending a first response to the first system; wherein the session types include a new session, a join session, and a session notification; if the session type is a new session, saving a service processing message corresponding to the key value, and then returning the received first response; if the session type is a join session, saving the service processing message corresponding to the key value to a corresponding existing session, and returning the first response; If the session type is a session notification received from an application; determine whether there is an exception in the current notification result of the session notification; if there is an exception, search for all saved business processing message records according to the key value, and send a recovery operation; if there is still an exception, put the business processing message into the queue first to facilitate subsequent compensation operations; if the current notification result is normal, store the business processing message corresponding to the key value in redis, and set an update expiration time for the stored business processing message, so that after the expiration time is reached, determine whether the stored business processing message is successfully processed in both the first business system and the second business system. If both are successfully processed, transfer and store the stored message to confirm the end of distributed business processing; Sending a first response to the first business system; so that the first business processing system performs business processing on the business method, and sends a call request containing the key value to the second business system; wherein the key value is generated by the first business system according to the business method intercepted by the method annotation; a response sending module, receiving a business processing request including the key value sent by the second business system according to the call request, and sending operation information corresponding to the key value to the second business system, so that the second business system performs corresponding business processing according to the operation information; The business processing module is used to determine that the distributed business processing is successful when it is determined that both the first business system and the second business system have processed successfully.
7. A distributed service processing system, characterized in that: It comprises a first business system, a second business system and the processing device as claimed in claim 6.
8. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.
9. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Session management method and device
CN109981715A
Data consistency verification method and device in case of abnormal data synchronization, and storage medium
CN110427422A
Service processing method and device
CN111198751A