[go: up one dir, main page]

CN111258723A - Transaction processing method, device, system, medium and equipment of distributed system - Google Patents

Transaction processing method, device, system, medium and equipment of distributed system Download PDF

Info

Publication number
CN111258723A
CN111258723A CN201911236917.0A CN201911236917A CN111258723A CN 111258723 A CN111258723 A CN 111258723A CN 201911236917 A CN201911236917 A CN 201911236917A CN 111258723 A CN111258723 A CN 111258723A
Authority
CN
China
Prior art keywords
service
event
request message
message
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201911236917.0A
Other languages
Chinese (zh)
Other versions
CN111258723B (en
Inventor
陆国际
张霞
葛东
贾璐
邢铁军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Sparkling Enterprise Management Planning Co.,Ltd.
Original Assignee
Neusoft Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Neusoft Corp filed Critical Neusoft Corp
Priority to CN201911236917.0A priority Critical patent/CN111258723B/en
Publication of CN111258723A publication Critical patent/CN111258723A/en
Application granted granted Critical
Publication of CN111258723B publication Critical patent/CN111258723B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/466Transaction processing
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/547Remote procedure calls [RPC]; Web services
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/547Messaging middleware
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/549Remote execution

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer And Data Communications (AREA)

Abstract

本公开涉及一种分布式系统的事务处理方法、装置、系统、介质及设备,所述方法包括:拦截服务调用者应用发起的服务调用请求,其中,服务调用请求中包含请求调用的服务;若所述服务调用请求中存在预设的一致性标识,根据所述请求调用的服务的方法元数据构建事件对象并存储所述事件对象至发布事件列表,其中,所述事件对象的初始状态为未发布;从所述发布事件列表中状态为未发布的事件对象中选择目标对象,并将所述目标对象对应的请求消息发布至消息中间件,所述请求消息中包括所述目标对象对应的目标服务的方法元数据,以使提供所述目标服务的服务提供者应用基于所述请求消息提供所述目标服务。由此,可以保证分布式系统的事务处理最终一致性。

Figure 201911236917

The present disclosure relates to a transaction processing method, device, system, medium and device for a distributed system. The method includes: intercepting a service invocation request initiated by a service caller application, wherein the service invocation request includes the service requested to be invoked; There is a preset consistency identifier in the service invocation request, construct an event object according to the method metadata of the service invoked by the request, and store the event object in the published event list, wherein the initial state of the event object is Unavailable. Publish; select a target object from the event objects whose status is unpublished in the published event list, and publish a request message corresponding to the target object to the message middleware, where the request message includes the target corresponding to the target object Method metadata for a service to enable a service provider application that provides the target service to provide the target service based on the request message. Thus, the eventual consistency of transaction processing in the distributed system can be guaranteed.

Figure 201911236917

Description

分布式系统的事务处理方法、装置、系统、介质及设备Transaction processing method, apparatus, system, medium and device for distributed system

技术领域technical field

本公开涉及计算机技术领域,具体地,涉及一种分布式系统的事务处理方法、装置、系统、介质及设备。The present disclosure relates to the field of computer technologies, and in particular, to a transaction processing method, apparatus, system, medium and device for a distributed system.

背景技术Background technique

随着分布式服务架构的流行与普及,原来在单体应用中执行的多个逻辑操作,现在被拆分成了多个服务之间的远程调用,随之而来的挑战就是分布式事务问题。由于每个服务都使用其单独维护的数据库,因此在不同服务的远程调用时对数据的操作并不在同一个事务中,比如服务A调用服务B,服务A执行成功,服务B执行失败,此时由于服务A的事务已经提交,无法回滚,这就会导致数据不一致的问题。With the popularity and popularity of distributed service architecture, multiple logical operations that were originally performed in a single application are now split into remote calls between multiple services. The challenge that comes with it is the problem of distributed transactions . Since each service uses its own separately maintained database, the data operations are not in the same transaction when different services are called remotely. For example, when service A calls service B, service A executes successfully, but service B fails. Since the transaction of service A has been committed and cannot be rolled back, this will lead to data inconsistency.

现有技术中,在解决服务调用的数据不一致问题时,通常是基于TCC (TCC服务是由Try/Confirm/Cancel业务构成的)、消息最终一致性事务等柔性事务的分布式事务,其中,TCC是基于补偿机制实现的,而消息最终一致事务中,在进行分布式系统的事务处理时,可能会出现服务调用者应用的服务调用请求消息多次重复发送,从而使得服务提供者应用存在同一消息被多次消费的风险。并且在网络中断或网络不稳定时,需要多次重发服务调用请求或确认消息以实现服务调用者应用和服务提供者应用的事务交互。In the prior art, when solving the problem of data inconsistency in service calls, it is usually a distributed transaction based on TCC (TCC service is composed of Try/Confirm/Cancel services), message eventual consistency transactions and other flexible transactions. Among them, TCC It is implemented based on the compensation mechanism, and in the eventual consistent message transaction, when the transaction processing of the distributed system is performed, the service call request message of the service caller application may be repeatedly sent multiple times, so that the same message exists in the service provider application. Risk of being consumed multiple times. And when the network is interrupted or the network is unstable, the service invocation request or confirmation message needs to be resent multiple times to realize the transaction interaction between the service caller application and the service provider application.

发明内容SUMMARY OF THE INVENTION

本公开的目的是提供一种安全、稳定地分布式系统的事务处理方法、装置、系统、介质及设备。The purpose of the present disclosure is to provide a transaction processing method, apparatus, system, medium and device for a secure and stable distributed system.

为了实现上述目的,根据本公开的第一方面,提供一种分布式系统的事务处理方法,所述方法包括:In order to achieve the above object, according to a first aspect of the present disclosure, a transaction processing method for a distributed system is provided, the method comprising:

拦截服务调用者应用发起的服务调用请求,其中,所述服务调用请求中包含请求调用的服务;Intercepting the service invocation request initiated by the service caller application, wherein the service invocation request includes the service requested to be invoked;

若所述服务调用请求中存在预设的一致性标识,根据所述请求调用的服务的方法元数据构建事件对象并存储所述事件对象至发布事件列表,其中,所述事件对象的初始状态为未发布;If there is a preset consistency identifier in the service invocation request, construct an event object according to the method metadata of the service invoked by the request and store the event object in the published event list, where the initial state of the event object is Unpublished;

从所述发布事件列表中状态为未发布的事件对象中选择目标对象,并将所述目标对象对应的请求消息发布至消息中间件,其中,所述请求消息中包括所述目标对象对应的目标服务的方法元数据,以使提供所述目标服务的服务提供者应用基于所述请求消息提供所述目标服务。Select a target object from the event objects whose status is unpublished in the published event list, and publish a request message corresponding to the target object to the message middleware, where the request message includes the target corresponding to the target object Method metadata for a service to enable a service provider application that provides the target service to provide the target service based on the request message.

可选地,所述将所述目标对象对应的请求消息发布至消息中间件,包括:Optionally, the publishing the request message corresponding to the target object to the message middleware includes:

将所述请求消息发布至消息中间件中、与所述服务提供者应用的标识信息对应的消息队列中,以由所述服务提供者应用从所述消息队列中获取所述请求消息。The request message is published to a message queue corresponding to the identification information of the service provider application in the message middleware, so that the service provider application can obtain the request message from the message queue.

可选地,所述服务调用者应用初始化有发布锁;在所述从所述发布事件列表中状态为未发布的事件对象中选择目标对象的步骤之前,所述方法还包括:Optionally, the service caller application is initialized with a publishing lock; before the step of selecting a target object from the event objects whose status is unpublished in the publishing event list, the method further includes:

确定所述发布锁的状态;determining the state of the release lock;

若所述发布锁的状态为空闲状态,将所述发布锁的状态更新为使用状态,并执行所述从所述发布事件列表中状态为未发布的事件对象中选择目标对象的步骤;If the state of the release lock is an idle state, update the state of the release lock to a use state, and perform the step of selecting a target object from the event objects whose state is unreleased in the release event list;

在所述将所述目标对象对应的请求消息发布至消息中间件的步骤之后,所述方法还包括:After the step of publishing the request message corresponding to the target object to the message middleware, the method further includes:

将所述发布锁的状态更新为空闲状态。The state of the release lock is updated to an idle state.

根据本公开的第二方面,提供一种分布式系统的事务处理方法,应用于服务提供者应用,所述方法包括:According to a second aspect of the present disclosure, there is provided a transaction processing method for a distributed system, applied to a service provider application, the method comprising:

从消息中间件获取请求消息,其中,所述请求消息中包括服务的方法元数据;Obtain a request message from the message middleware, wherein the request message includes method metadata of the service;

根据所述服务的方法元数据构建事件对象并存储所述事件对象至处理事件列表中,其中,所述事件对象的初始状态为未处理;Build an event object according to the method metadata of the service and store the event object in a list of processing events, wherein the initial state of the event object is unprocessed;

从所述处理事件列表中状态为未处理的事件对象中选择目标对象,并根据所述目标对象对应的目标服务的方法元数据,执行所述目标服务的方法,以为发起所述目标对象对应的请求消息的服务调用者应用提供所述目标服务。A target object is selected from the event objects whose status is unprocessed in the processing event list, and according to the method metadata of the target service corresponding to the target object, the method of the target service is executed, so as to initiate an event corresponding to the target object. The service caller application requesting the message provides the target service.

可选地,所述从消息中间件获取请求消息,包括:Optionally, the obtaining the request message from the message middleware includes:

从所述消息中间件中、与所述服务提供者应用的标识信息对应的消息队列中获取所述请求消息。The request message is acquired from a message queue corresponding to the identification information of the service provider application in the message middleware.

可选地,所述服务提供者应用初始化有处理锁;在所述从所述处理事件列表中状态为未处理的事件对象中选择目标对象的步骤之前,所述方法还包括:Optionally, the service provider application is initialized with a processing lock; before the step of selecting a target object from the event objects whose status is unprocessed in the processing event list, the method further includes:

确定所述处理锁的状态;determining the state of the processing lock;

在所述处理锁的状态为空闲状态时,将所述处理锁的状态更新为使用状态,并执行从所述处理事件列表中状态为未处理的事件对象中选择目标对象的步骤;When the state of the processing lock is an idle state, update the state of the processing lock to a use state, and perform the step of selecting a target object from the event objects whose state is unprocessed in the processing event list;

在所述根据所述目标对象对应的目标服务的方法元数据,执行所述目标服务的方法的步骤之后,所述方法还包括:After the step of executing the method for the target service according to the method metadata of the target service corresponding to the target object, the method further includes:

将所述处理锁的状态更新为空闲状态。The state of the processing lock is updated to an idle state.

根据本公开的第三方面,提供一种分布式系统的事务处理装置,所述装置包括:According to a third aspect of the present disclosure, there is provided a transaction processing apparatus of a distributed system, the apparatus comprising:

拦截模块,用于拦截服务调用者应用发起的服务调用请求,其中,所述服务调用请求中包含请求调用的服务;An interception module, configured to intercept a service invocation request initiated by a service caller application, wherein the service invocation request includes the service requested to be invoked;

第一存储模块,用于在所述服务调用请求中存在预设的一致性标识的情况下,根据所述请求调用的服务的方法元数据构建事件对象并存储所述事件对象至发布事件列表,其中,所述事件对象的初始状态为未发布;a first storage module, configured to construct an event object according to the method metadata of the service invoked by the request in the case of a preset consistency identifier in the service invocation request, and store the event object in a published event list, Wherein, the initial state of the event object is unpublished;

发布模块,用于从所述发布事件列表中状态为未发布的事件对象中选择目标对象,并将所述目标对象对应的请求消息发布至消息中间件,其中,所述请求消息中包括所述目标对象对应的目标服务的方法元数据,以使提供所述目标服务的服务提供者应用基于所述请求消息提供所述目标服务。A publishing module, configured to select a target object from the event objects whose status is unpublished in the publishing event list, and publish a request message corresponding to the target object to the message middleware, wherein the request message includes the Method metadata of the target service corresponding to the target object, so that the service provider application that provides the target service provides the target service based on the request message.

可选地,所述发布模块包括:Optionally, the publishing module includes:

将所述请求消息发布至消息中间件中、与所述服务提供者应用的标识信息对应的消息队列中,以由所述服务提供者应用从所述消息队列中获取所述请求消息。The request message is published to a message queue corresponding to the identification information of the service provider application in the message middleware, so that the service provider application can obtain the request message from the message queue.

可选地,所述服务调用者应用初始化有发布锁;所述装置还包括:Optionally, the service caller application is initialized with a release lock; the device further includes:

第一确定模块,用于在所述发布模块从所述发布事件列表中状态为未发布的事件对象中选择目标对象之前,确定所述发布锁的状态;a first determining module, configured to determine the state of the release lock before the release module selects a target object from the event objects whose state is unreleased in the release event list;

第一更新模块,用于在所述发布锁的状态为空闲状态的情况下,将所述发布锁的状态更新为使用状态,并触发所述发布模块从所述发布事件列表中状态为未发布的事件对象中选择目标对象;a first update module, configured to update the state of the release lock to a use state when the state of the release lock is an idle state, and trigger the release module to change the state from the release event list to unreleased Select the target object from the event object;

所述装置还包括:The device also includes:

第二更新模块,用于在所述发布模块将所述目标对象对应的请求消息发布至消息中间件之后,将所述发布锁的状态更新为空闲状态。The second update module is configured to update the state of the release lock to an idle state after the release module releases the request message corresponding to the target object to the message middleware.

根据本公开的第四方面,提供一种分布式系统的事务处理装置,应用于服务提供者应用,所述装置包括:According to a fourth aspect of the present disclosure, there is provided a transaction processing apparatus of a distributed system, applied to a service provider application, the apparatus comprising:

获取模块,用于从消息中间件获取请求消息,其中,所述请求消息中包括服务的方法元数据;an obtaining module, configured to obtain a request message from the message middleware, wherein the request message includes method metadata of the service;

第二存储模块,用于根据所述服务的方法元数据构建事件对象并存储所述事件对象至处理事件列表中,其中,所述事件对象的初始状态为未处理;a second storage module, configured to construct an event object according to the method metadata of the service and store the event object in the processing event list, wherein the initial state of the event object is unprocessed;

执行模块,用于从所述处理事件列表中状态为未处理的事件对象中选择目标对象,并根据所述目标对象对应的目标服务的方法元数据,执行所述目标服务的方法,以为发起所述目标对象对应的请求消息的服务调用者应用提供所述目标服务。The execution module is used to select a target object from the event objects whose status is unprocessed in the processing event list, and execute the method of the target service according to the method metadata of the target service corresponding to the target object, so as to initiate all the events. The service caller application of the request message corresponding to the target object provides the target service.

可选地,所述获取模块包括:Optionally, the obtaining module includes:

从所述消息中间件中、与所述服务提供者应用的标识信息对应的消息队列中获取所述请求消息。The request message is acquired from a message queue corresponding to the identification information of the service provider application in the message middleware.

可选地,所述服务提供者应用初始化有处理锁;所述装置还包括:Optionally, the service provider application is initialized with a processing lock; the device further includes:

第二确定模块,用于在所述执行模块从所述处理事件列表中状态为未处理的事件对象中选择目标对象之前,确定所述处理锁的状态;a second determining module, configured to determine the state of the processing lock before the execution module selects a target object from the event objects whose status is unprocessed in the processing event list;

第三更新模块,用于在所述处理锁的状态为空闲状态时,将所述处理锁的状态更新为使用状态,并触发所述执行模块从所述处理事件列表中状态为未处理的事件对象中选择目标对象;A third update module, configured to update the state of the process lock to a use state when the state of the process lock is an idle state, and trigger the execution module to select the unprocessed event from the process event list Select the target object in the object;

所述装置还包括:The device also includes:

第四更新模块,用于在所述执行模块根据所述目标对象对应的目标服务的方法元数据,执行所述目标服务的方法之后,将所述处理锁的状态更新为空闲状态。The fourth update module is configured to update the state of the processing lock to an idle state after the execution module executes the method of the target service according to the method metadata of the target service corresponding to the target object.

根据本公开的第五方面,提供一种分布式系统的事务处理系统,所述系统包括:According to a fifth aspect of the present disclosure, there is provided a transaction processing system of a distributed system, the system comprising:

消息发布组件,所述消息发布组件与服务调用者应用耦合,所述消息发布组件用于执行上述第一方面任一所述方法的步骤;a message publishing component, the message publishing component is coupled to the service caller application, and the message publishing component is configured to perform the steps of any one of the methods in the first aspect above;

消息中间件,用于对请求消息进行存储;Message middleware, which is used to store request messages;

服务提供者应用,所述服务提供者应用用于执行上述第二方面任一所述方法的步骤。A service provider application, where the service provider application is configured to perform the steps of any one of the methods of the second aspect above.

根据本公开的第六方面,提供一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时实现上述第一方面和第二方面任一所述方法的步骤。According to a sixth aspect of the present disclosure, there is provided a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, implements the steps of any of the methods described in the first and second aspects above.

根据本公开的第七方面,提供一种电子设备,包括:According to a seventh aspect of the present disclosure, there is provided an electronic device, comprising:

存储器,其上存储有计算机程序;a memory on which a computer program is stored;

处理器,用于执行所述存储器中的所述计算机程序,以实现上述第一方面和第二方面任一所述方法的步骤。A processor, configured to execute the computer program in the memory, so as to implement the steps of the method in any one of the first aspect and the second aspect.

在上述技术方案中,拦截服务调用者应用发起的服务调用请求,若该服务调用请求中存在预设的一致性标识,则可以根据请求调用的服务的方法元数据构建事件对象并将事件对象存储至发布事件列表中。因此,在发布服务调用请求对应的请求消息时,并不是直接基于该服务调用请求进行发布,而是从本地发布事件列表中状态为未发布的事件对象中选择目标对象,从而将目标对象对应的请求消息发布至消息中间件,实现服务调用请求对应的请求消息发布。通过上述技术方案,基于发布事件列表对服务调用请求对应的请求消息进行发布,可以将远程服务调用请求转换为本地消息发布,从而在分布式事务处理过程中,可以有效避免由于网络中断、事务异常等原因而导致的服务调用者应用多次发起服务调用请求的问题,既可以避免重复发起服务调用请求造成的资源浪费,同时也可以保证服务调用请求对应的请求消息能够发布至消息中间件,进而保证事务最终一致性,提高分布式系统的事务处理稳定性和安全性。另外,在上述技术方案中,通过拦截服务调用请求,并确定服务调用请求中是否存在预设的一致性标识的方式,也可以有效降低实现事务最终一致性时对微服务应用的侵入性,从而可以降低分布式系统的事务处理的复杂性,并进一步提高事务处理的安全性和健壮性。In the above technical solution, the service call request initiated by the service caller application is intercepted. If there is a preset consistency identifier in the service call request, an event object can be constructed according to the method metadata of the service called by the request and stored in the event object. to the list of published events. Therefore, when publishing the request message corresponding to the service invocation request, it is not directly based on the service invocation request, but selects the target object from the event objects whose status is unpublished in the local publishing event list, so that the corresponding The request message is published to the message middleware, and the request message corresponding to the service call request is published. Through the above technical solution, the request message corresponding to the service invocation request is released based on the release event list, and the remote service invocation request can be converted into local message release, so that in the process of distributed transaction processing, network interruption and transaction exception can be effectively avoided. The problem that the service caller application initiates service invocation requests multiple times due to other reasons can not only avoid the waste of resources caused by repeated service invocation requests, but also ensure that the request message corresponding to the service invocation request can be published to the message middleware, and then Ensure the eventual consistency of transactions and improve the transaction stability and security of distributed systems. In addition, in the above technical solution, by intercepting the service invocation request and determining whether there is a preset consistency identifier in the service invocation request, the intrusiveness of the microservice application when realizing the eventual consistency of the transaction can also be effectively reduced, thereby The complexity of transaction processing of distributed systems can be reduced, and the security and robustness of transaction processing can be further improved.

本公开的其他特征和优点将在随后的具体实施方式部分予以详细说明。Other features and advantages of the present disclosure will be described in detail in the detailed description that follows.

附图说明Description of drawings

附图是用来提供对本公开的进一步理解,并且构成说明书的一部分,与下面的具体实施方式一起用于解释本公开,但并不构成对本公开的限制。在附图中:The accompanying drawings are used to provide a further understanding of the present disclosure, and constitute a part of the specification, and together with the following detailed description, are used to explain the present disclosure, but not to limit the present disclosure. In the attached image:

图1是根据本公开的一种实施方式提供的分布式系统的事务处理方法的流程图。FIG. 1 is a flowchart of a transaction processing method of a distributed system provided according to an embodiment of the present disclosure.

图2是根据本公开的一种实施方式提供的分布式系统的事务处理方法的流程图;FIG. 2 is a flowchart of a transaction processing method of a distributed system provided according to an embodiment of the present disclosure;

图3是根据本公开的一种实施方式提供的分布式系统的事务处理装置的框图;3 is a block diagram of a transaction processing apparatus of a distributed system provided according to an embodiment of the present disclosure;

图4是根据本公开的一种实施方式提供的分布式系统的事务处理装置的框图;4 is a block diagram of a transaction processing apparatus of a distributed system provided according to an embodiment of the present disclosure;

图5是根据一示例性实施例示出的一种电子设备的框图;5 is a block diagram of an electronic device according to an exemplary embodiment;

图6是根据一示例性实施例示出的一种电子设备的框图。Fig. 6 is a block diagram of an electronic device according to an exemplary embodiment.

具体实施方式Detailed ways

以下结合附图对本公开的具体实施方式进行详细说明。应当理解的是,此处所描述的具体实施方式仅用于说明和解释本公开,并不用于限制本公开。The specific embodiments of the present disclosure will be described in detail below with reference to the accompanying drawings. It should be understood that the specific embodiments described herein are only used to illustrate and explain the present disclosure, but not to limit the present disclosure.

在分布式服务架构中需要保证事务处理过程中的数据一致性。而在微服务应用间进行异步调用时,部分微服务的调用只需要保证事务最终一致性即可,其中,事务最终一致性是指系统中所有数据副本经过一定时间后,最终能够达到一致的状态。例如,在不要求实时性的场景下,例如用户A在对用户B转账X,在用户A的账户扣费X之后,保证用户B的账户中最终可以入账X,从而保证数据的一致性,即实现该转账事务最终一致性。In a distributed service architecture, it is necessary to ensure data consistency during transaction processing. When asynchronous calls are made between microservice applications, the invocation of some microservices only needs to ensure the eventual consistency of transactions. The eventual consistency of transactions means that all data copies in the system can eventually reach a consistent state after a certain period of time. . For example, in a scenario that does not require real-time performance, for example, when user A transfers X to user B, after deducting X from user A's account, it is guaranteed that user B's account can eventually be credited to X, so as to ensure data consistency, that is, Realize the eventual consistency of the transfer transaction.

基于此,本公开提供一种分布式系统的事务处理系统,所述系统包括:Based on this, the present disclosure provides a transaction processing system of a distributed system, the system comprising:

消息发布组件,所述消息发布组件与服务调用者应用耦合,所述消息发布组件用于发布服务调用请求对应的请求消息;a message publishing component, the message publishing component is coupled with the service caller application, and the message publishing component is used to publish a request message corresponding to a service invocation request;

消息中间件,用于对请求消息进行存储;Message middleware, which is used to store request messages;

服务提供者应用,所述服务提供者应用用于对请求消息进行处理,以提供相应的服务。A service provider application, where the service provider application is used to process the request message to provide a corresponding service.

以下,对本方案的具体实施方式进行详细说明。Hereinafter, specific embodiments of the present solution will be described in detail.

本公开提供一种分布式系统的事务处理方法。图1所示,为根据本公开的一种实施方式提供的分布式系统的事务处理方法的流程图,该方法可以应用于与服务调用者应用耦合的消息发布组件,该消息发布组件可以独立于该服务调用者应用,也可以集成在该服务调用者应用中,如图1所示,所述方法包括:The present disclosure provides a transaction processing method for a distributed system. FIG. 1 is a flowchart of a transaction processing method of a distributed system provided according to an embodiment of the present disclosure. The method can be applied to a message publishing component coupled with a service caller application, and the message publishing component can be independent of The service caller application can also be integrated in the service caller application, as shown in FIG. 1 , the method includes:

在S11中,拦截服务调用者应用发起的服务调用请求,其中,所述服务调用请求中包含请求调用的服务。In S11, intercept the service invocation request initiated by the service caller application, wherein the service invocation request includes the service requested to be invoked.

其中,服务调用者应用可以为一微服务应用,各个微服务应用之间可以进行远程调用。示例地,若微服务应用A调用微服务应用B,则该服务调用请求中则可以包含该微服务应用B对应的标识信息,该标识信息可以是该微服务应用B的应用名称。例如,在为用户发放代金券的应用场景中,可以通过用户服务调用代金券服务实现,则用户服务可以发送包括代金券服务的应用名称的服务调用请求,以调用该代金券服务。可选地,拦截服务调用者应用发起的服务调用请求可以通过拦截器实现,在用户服务发起该服务调用请求时,可以通过该拦截器对该服务调用请求进行拦截。示例地,在Dubbo 服务框架中可以采用拦截器(filter)进行拦截,对于Spring Cloud服务框架而言,可以在feign的拦截器中进行拦截。其中,Dubbo服务框架、Spring Cloud 服务框架中进行拦截的方式均为现有技术,在此不再赘述。The service caller application may be a microservice application, and remote calls may be made between the microservice applications. For example, if microservice application A calls microservice application B, the service invocation request may include identification information corresponding to microservice application B, and the identification information may be the application name of microservice application B. For example, in the application scenario of issuing vouchers to users, this can be achieved by invoking the voucher service through the user service, and the user service can send a service invocation request including the application name of the voucher service to invoke the voucher service. Optionally, intercepting the service invocation request initiated by the service caller application may be implemented by an interceptor, and when the user service initiates the service invocation request, the service invocation request may be intercepted by the interceptor. For example, in the Dubbo service framework, an interceptor (filter) can be used to intercept, and for the Spring Cloud service framework, it can be intercepted in feign's interceptor. Among them, the interception methods in the Dubbo service framework and the Spring Cloud service framework are all existing technologies, which will not be repeated here.

在S12中,若服务调用请求中存在预设的一致性标识,根据请求调用的服务的方法元数据构建事件对象并存储事件对象至发布事件列表,其中,所述事件对象的初始状态为未发布。In S12, if there is a preset consistency identifier in the service invocation request, construct an event object according to the method metadata of the service invoked by the request and store the event object in the published event list, wherein the initial state of the event object is unpublished .

其中,针对需要保证事务最终一致性的调用服务,可以在调用远程服务时的接口中添加预设的一致性标识,示例地,该一致性标识可以是注解,该注解用于表示在调用该服务时,需要保证事务最终一致性。其中,预设的一致性标识可以根据实际使用场景进行设置和添加。Among them, for the calling service that needs to ensure the eventual consistency of the transaction, a preset consistency identifier can be added to the interface when calling the remote service. For example, the consistency identifier can be an annotation, and the annotation is used to indicate that the service is being called. , the eventual consistency of the transaction needs to be guaranteed. Among them, the preset consistency identification can be set and added according to actual usage scenarios.

示例地,拦截到的服务调用请求如下:For example, the intercepted service call request is as follows:

Figure RE-GDA0002465924500000091
Figure RE-GDA0002465924500000091

即,在上述服务调用请求中,请求调用的服务为sayHi,TestServerBLO 为调用该服务sayHi的接口。通过拦截该服务调用请求,确定在该服务调用请求中存在一致性标识,即注解@BaseTransaction,该注解为用于表示在调用该服务时需要保证事务最终一致性的注解,即此时可以确定在基于该服务调用请求对该服务进行调用时,需要保证事务最终一致性。That is, in the above service invocation request, the service requested to be invoked is sayHi, and TestServerBLO is the interface for invoking the service sayHi. By intercepting the service invocation request, it is determined that there is a consistency identifier in the service invocation request, that is, the annotation @BaseTransaction, which is used to indicate that the final consistency of the transaction needs to be guaranteed when the service is invoked, that is, it can be determined at this time. When invoking the service based on the service invocation request, it is necessary to ensure the eventual consistency of the transaction.

示例地,服务的方法元数据可以包括服务的方法的签名,方法的参数,以及参数的描述等,根据请求调用的服务的方法元数据构建事件对象可以是将该请求调用的服务的方法元数据按照事件对象(EVENT对象)对应的结构进行结构化处理,从而构建事件对象,并将该事件对象存储至发布事件列表,便于对该请求调用的服务的方法元数据进行统一管理。需要说明的是,该服务调用者应用可以对应有多个服务实例,该多个服务实例处于同一数据库,该发布事件列表存储在该数据库中,多个服务实例共享该发布事件列表。For example, the method metadata of the service may include the signature of the method of the service, the parameters of the method, and the description of the parameters, etc. The event object constructed according to the method metadata of the service called by the request may be the method metadata of the service called by the request. Structural processing is performed according to the structure corresponding to the event object (EVENT object), thereby constructing the event object, and storing the event object in the published event list, so as to facilitate unified management of the method metadata of the service invoked by the request. It should be noted that the service caller application may correspond to multiple service instances, the multiple service instances are in the same database, the published event list is stored in the database, and the multiple service instances share the published event list.

在S13中,从发布事件列表中状态为未发布的事件对象中选择目标对象,并将目标对象对应的请求消息发布至消息中间件,其中,所述请求消息中包括所述目标对象对应的目标服务的方法元数据,以使提供所述目标服务的服务提供者应用基于所述请求消息提供所述目标服务。In S13, a target object is selected from the event objects whose status is unpublished in the published event list, and a request message corresponding to the target object is published to the message middleware, wherein the request message includes the target corresponding to the target object Method metadata for a service to enable a service provider application that provides the target service to provide the target service based on the request message.

其中,发布事件列表中可以存在多个状态为未发布的事件对象,在选择目标对象时,可以将该发布事件列表中的全部状态为未发布的事件对象作为目标对象,也可以将该发布事件列表中状态为未发布的事件对象按照创建时间由早至晚的顺序排序在前N的事件对象作为目标对象,其中,N可以根据实际使用场景进行设置。Among them, there can be multiple event objects whose status is unpublished in the publishing event list. When selecting the target object, all the event objects whose status is unpublished in the publishing event list can be used as the target object, or the publishing event can be selected as the target object. The event objects whose status is unpublished in the list are the top N event objects in the order of creation time from early to late as the target object, where N can be set according to the actual usage scenario.

示例地,可以通过定时轮询的方式选择目标对象,示例地,可以每隔2s 执行从发布事件列表中状态为未发布的事件对象中选择目标对象的步骤。并且,基于本地的发布事件列表中的事件对象进行请求消息的发布,可以使得存储在发布事件列表中的状态为未发布的事件对象所对应的请求消息最终都可以被发布出去,保证数据处理的可靠性。For example, the target object may be selected by means of regular polling. For example, the step of selecting the target object from the event objects whose status is unpublished in the published event list may be performed every 2s. In addition, publishing the request message based on the event object in the local publishing event list can make the request message corresponding to the event object whose status is unpublished stored in the publishing event list can be finally published, ensuring data processing. reliability.

在上述技术方案中,拦截服务调用者应用发起的服务调用请求,若该服务调用请求中存在预设的一致性标识,则可以根据请求调用的服务的方法元数据构建事件对象并将事件对象存储至发布事件列表中。因此,在发布服务调用请求对应的请求消息时,并不是直接基于该服务调用请求进行发布,而是从本地发布事件列表中状态为未发布的事件对象中选择目标对象,从而将目标对象对应的请求消息发布至消息中间件,实现服务调用请求对应的请求消息发布。通过上述技术方案,基于发布事件列表对服务调用请求对应的请求消息进行发布,可以将远程服务调用请求转换为本地消息发布,从而在分布式事务处理过程中,可以有效避免由于网络中断、事务异常等原因而导致的服务调用者应用多次发起服务调用请求的问题,既可以避免重复发起服务调用请求造成的资源浪费,同时也可以保证服务调用请求对应的请求消息能够发布至消息中间件,进而保证事务最终一致性,提高分布式系统的事务处理稳定性和安全性。另外,在上述技术方案中,通过拦截服务调用请求,并确定服务调用请求中是否存在预设的一致性标识的方式,也可以有效降低实现事务最终一致性时对微服务应用的侵入性,从而可以降低分布式系统的事务处理的复杂性,并进一步提高事务处理的安全性和健壮性。In the above technical solution, the service call request initiated by the service caller application is intercepted. If there is a preset consistency identifier in the service call request, an event object can be constructed according to the method metadata of the service called by the request and stored in the event object. to the list of published events. Therefore, when publishing the request message corresponding to the service invocation request, it is not directly based on the service invocation request, but selects the target object from the event objects whose status is unpublished in the local publishing event list, so that the corresponding The request message is published to the message middleware, and the request message corresponding to the service call request is published. Through the above technical solution, the request message corresponding to the service invocation request is released based on the release event list, and the remote service invocation request can be converted into local message release, so that in the process of distributed transaction processing, network interruption and transaction exception can be effectively avoided. The problem that the service caller application initiates service invocation requests multiple times due to other reasons can not only avoid the waste of resources caused by repeated service invocation requests, but also ensure that the request message corresponding to the service invocation request can be published to the message middleware, and then Ensure the eventual consistency of transactions and improve the transaction stability and security of distributed systems. In addition, in the above technical solution, by intercepting the service invocation request and determining whether there is a preset consistency identifier in the service invocation request, the intrusiveness of the microservice application when realizing the eventual consistency of the transaction can also be effectively reduced, thereby The complexity of transaction processing of distributed systems can be reduced, and the security and robustness of transaction processing can be further improved.

本公开还提供一种分布式系统的事务处理方法,应用于服务提供者应用,如图2所示,所述方法包括:The present disclosure also provides a transaction processing method for a distributed system, which is applied to a service provider application. As shown in FIG. 2 , the method includes:

在S21中,从消息中间件获取请求消息,其中,所述请求消息中包括服务的方法元数据。因此,该服务提供者应用通过获取请求消息,可以获得该服务的方法元数据。示例地,该消息中间件可以是MQ消息队列,则服务提供者应用可以从该消息中间件中订阅消息,从而获取该请求消息。In S21, a request message is obtained from the message middleware, wherein the request message includes method metadata of the service. Therefore, the service provider application can obtain the method metadata of the service by obtaining the request message. For example, the message middleware may be an MQ message queue, and the service provider application may subscribe to messages from the message middleware to obtain the request message.

在S22中,根据服务的方法元数据构建事件对象并存储事件对象至处理事件列表中,其中,所述事件对象的初始状态为未处理。In S22, an event object is constructed according to the method metadata of the service, and the event object is stored in the processing event list, wherein the initial state of the event object is unprocessed.

其中,根据服务的方法元数据构建事件对象的方式已在上文进行详述,在此不再赘述。示例地,该服务提供者应用为一微服务应用,该微服务应用对应有多个服务实例,且该多个服务实例处于同一数据库,该处理事件列表存储在该数据库中,多个服务实例共享该处理事件列表。The method of constructing the event object according to the method metadata of the service has been described in detail above, and will not be repeated here. For example, the service provider application is a microservice application, the microservice application corresponds to multiple service instances, and the multiple service instances are in the same database, the processing event list is stored in the database, and multiple service instances share A list of the processing events.

在S23中,从处理事件列表中状态为未处理的事件对象中选择目标对象,并根据目标对象对应的目标服务的方法元数据,执行目标服务的方法,以为发起目标对象对应的请求消息的服务调用者应用提供目标服务。In S23, the target object is selected from the event objects whose status is unprocessed in the processing event list, and according to the method metadata of the target service corresponding to the target object, the method of the target service is executed, so as to initiate the service of the request message corresponding to the target object The caller application provides the target service.

其中,处理事件列表中可以存在多个状态为未处理的事件对象,在选择目标对象时,可以将该处理事件列表中的全部状态为未处理的事件对象作为目标对象,也可以将该处理事件列表中状态为未处理的事件对象按照创建时间由早至晚的顺序排序在前M的事件对象作为目标对象,其中,M可以根据实际使用场景进行设置。Among them, there can be multiple event objects whose status is unprocessed in the processing event list. When selecting the target object, all the event objects whose status is unprocessed in the processing event list can be used as the target object, or the processing event can be selected as the target object. The event objects whose status is unprocessed in the list are the event objects with the top M in the order of creation time from early to late as the target object, where M can be set according to the actual usage scenario.

同样,可以通过定时轮询的方式选择该目标对象,且基于本地的处理事件列表中的事件对象进行消息处理,从而可以保证处理事件列表中状态为未处理的事件对象最终都会被处理,保证事务最终一致性。Similarly, the target object can be selected by regular polling, and the message processing is performed based on the event objects in the local processing event list, so as to ensure that the unprocessed event objects in the processing event list will eventually be processed, ensuring that the transaction eventual consistency.

示例地,根据目标对象对应的目标服务的方法元数据,执行目标服务的方法,可以根据该方法元数据中的方法名称和参数反射调用的目标服务的方法。例如在上述为用户发放代金券的应用场景下,服务提供者应用可以为代金券服务,则代金券服务可以根据方法元数据,反射调用代金券服务的方法,从而执行该方法以为用户发放代金券。其中对方法进行发射调用为现有技术,在此不再赘述。For example, according to the method metadata of the target service corresponding to the target object, the method of the target service is executed, and the method of the called target service can be reflected according to the method name and parameters in the method metadata. For example, in the above application scenario of issuing vouchers to users, the service provider application can serve vouchers, and the voucher service can reflect the method of calling the voucher service according to the method metadata, so as to execute the method to issue vouchers to users . The transmitting and calling of the method is the prior art, which will not be repeated here.

在上述技术方案中,根据从消息中间件中获取的请求消息构建事件对象,并将事件对象存储至处理事件列表中。因此,在对请求消息进行处理时,并不直接基于该请求消息进行处理,而是基于本地的处理事件列表中的选择的目标对象进行处理。由于目标对象是处理事件列表中的未处理的事件对象,由此可以避免对同一请求消息的重复处理,也可以保证处理事件中状态为未处理的事件对象可以最终被处理,保证事务最终一致性和可靠性。同时,基于本地事务进行请求消息处理,从而无需消息中间件进行消息重发,既可以避免多次发送请求消息造成的资源浪费,也可以避免同一消息被重复处理,提高分布式系统的事务处理稳定性和安全性。In the above technical solution, the event object is constructed according to the request message obtained from the message middleware, and the event object is stored in the processing event list. Therefore, when processing the request message, it is not directly processed based on the request message, but is processed based on the selected target object in the local processing event list. Since the target object is the unprocessed event object in the processing event list, repeated processing of the same request message can be avoided, and the event object whose status is unprocessed in the processing event can be finally processed, ensuring the eventual consistency of the transaction. and reliability. At the same time, request message processing is performed based on local transactions, so that message retransmission is not required by message middleware, which can not only avoid resource waste caused by sending request messages multiple times, but also avoid repeated processing of the same message, and improve the transaction processing stability of the distributed system. sex and safety.

可选地,所述将所述目标对象对应的请求消息发布至消息中间件的示例方式如下,该步骤可以包括:Optionally, an exemplary manner of publishing the request message corresponding to the target object to the message middleware is as follows, and this step may include:

将所述请求消息发布至消息中间件中、与所述服务提供者应用的标识信息对应的消息队列中,以由所述服务提供者应用从所述消息队列中获取所述请求消息。The request message is published to a message queue corresponding to the identification information of the service provider application in the message middleware, so that the service provider application can obtain the request message from the message queue.

对应地,当该方法应用于服务提供者应用时,所述从消息中间件获取请求消息,包括:Correspondingly, when the method is applied to the service provider application, the obtaining the request message from the message middleware includes:

从所述消息中间件中、与所述服务提供者应用的标识信息对应的消息队列中获取所述请求消息。The request message is acquired from a message queue corresponding to the identification information of the service provider application in the message middleware.

其中,每个微服务应用在启动时,都可以在消息中间件中初始化一与该微服务应用的标识信息对应的消息队列和路由,其中,该微服务应用的标识信息可以是该微服务应用的应用名称。其中,每个微服务应用可以作为服务调用者应用的身份,也可以作为服务提供者应用的身份,其具体身份的确定可以根据实际服务调用场景确定。例如,微服务应用A调用微服务应用B,微服务应用B作为服务提供者应用;微服务应用B调用微服务应用C时,微服务应用B作为服务调用者应用。Wherein, when each microservice application is started, a message queue and route corresponding to the identification information of the microservice application may be initialized in the message middleware, wherein the identification information of the microservice application may be the microservice application application name. Among them, each microservice application can be used as the identity of the service caller application, and can also be used as the identity of the service provider application, and its specific identity can be determined according to the actual service invocation scenario. For example, when microservice application A calls microservice application B, microservice application B acts as a service provider application; when microservice application B calls microservice application C, microservice application B acts as a service caller application.

示例地,标识信息为应用名称,在微服务应用A调用微服务应用B时,在发布调用微服务应用B对应的请求消息时,可以基于初始化的路由将该请求消息发布至消息中间件中与微服务应用B的应用名称对应的消息队列中。由此,在微服务应用B从消息中间件中订阅消息时,则可以直接以微服务应用B的应用名称获取请求消息,即直接从与微服务应用B的应用名称对应的消息队列获取请求消息。For example, the identification information is the application name. When microservice application A calls microservice application B, when publishing a request message corresponding to calling microservice application B, the request message can be published to the message middleware based on the initialized routing In the message queue corresponding to the application name of microservice application B. Therefore, when microservice application B subscribes to messages from the message middleware, the request message can be obtained directly with the application name of microservice application B, that is, the request message can be directly obtained from the message queue corresponding to the application name of microservice application B .

通过上述技术方案,在分布式系统中进行服务调用时,可以直接将请求消息发送至消息中间件中与服务提供者应用的标识信息对应的消息队列中,一方面可以便于消息中间件中的消息管理,另一方面使得服务提供者应用可以快速且准确地获取其需要处理的请求消息,降低消息订阅的开销,同时可以提高请求消息的处理效率,在保证事务最终一致性的同时,提高事务最终一致性的处理效率。Through the above technical solution, when a service invocation is performed in a distributed system, the request message can be directly sent to the message queue corresponding to the identification information of the service provider application in the message middleware. Management, on the other hand, enables the service provider application to quickly and accurately obtain the request messages it needs to process, reduces the overhead of message subscription, and improves the processing efficiency of request messages. Consistent processing efficiency.

可选地,在微服务应用初始化时,可以分别初始化一发布锁和一处理锁,其中,该发布锁用于保证在同一时刻发布事件列表的查询是唯一的,该处理锁用于保证在同一时刻处理事件列表的查询是唯一的。Optionally, when the microservice application is initialized, a publishing lock and a processing lock can be initialized respectively, wherein the publishing lock is used to ensure that the query of the list of published events at the same time is unique, and the processing lock is used to ensure that the query at the same time is unique. Queries that process the list of events are unique at all times.

示例地,所述服务调用者应用初始化有发布锁;在所述从所述发布事件列表中状态为未发布的事件对象中选择目标对象的步骤之前,所述方法还包括:Exemplarily, the service caller application is initialized with a publishing lock; before the step of selecting a target object from the event objects whose status is unpublished in the publishing event list, the method further includes:

确定所述发布锁的状态,其中该发布锁初始状态为空闲状态;determining the state of the release lock, wherein the initial state of the release lock is an idle state;

若所述发布锁的状态为空闲状态,将所述发布锁的状态更新为使用状态,并执行所述从所述发布事件列表中状态为未发布的事件对象中选择目标对象的步骤。If the state of the release lock is the idle state, the state of the release lock is updated to the use state, and the step of selecting a target object from the event objects whose state is unreleased in the release event list is performed.

在所述将所述目标对象对应的请求消息发布至消息中间件的步骤之后,所述方法还包括:After the step of publishing the request message corresponding to the target object to the message middleware, the method further includes:

将所述发布锁的状态更新为空闲状态。The state of the release lock is updated to an idle state.

在该技术方案中,在服务调用者应用将请求消息发布至消息中间件中时,需要保证每个请求消息都需要进行发布,并且每个请求消息在消息中间件上唯一。基于此,为了保证分布式系统的高效率和吞吐量,在本公开中为微服务应用初始化一发布锁,使得服务调用者应用在发布请求消息时,对发布事件列表的查询是唯一的,从而保证请求消息发布的唯一性。在从所述发布事件列表中状态为未发布的事件对象中选择目标对象之前,通过确定发布锁的状态可以确定微服务应用中当前是否有服务实例正在查询该发布事件列表,若发布锁的状态处于空闲状态,则表示当前没有服务实例查询发布事件列表,此时可以执行从所述发布事件列表中状态为未发布的事件对象中选择目标对象的步骤;若发布锁的状态处于使用状态,则表示当前有服务实例查询发布事件列表,此时需要等待发布锁的状态更新为空闲状态之后,才可允许查询发布事件列表。In this technical solution, when the service caller application publishes the request message to the message middleware, it needs to ensure that each request message needs to be published, and each request message is unique on the message middleware. Based on this, in order to ensure the high efficiency and throughput of the distributed system, a release lock is initialized for the microservice application in this disclosure, so that when the service caller application publishes the request message, the query of the published event list is unique, thereby Guarantee the uniqueness of request message publication. Before selecting the target object from the unpublished event objects in the publishing event list, by determining the state of the publishing lock, it can be determined whether there is currently a service instance in the microservice application querying the publishing event list, if the status of the publishing lock is In the idle state, it means that there is currently no service instance to query the published event list. At this time, the step of selecting the target object from the event objects whose state is unpublished in the published event list can be performed; if the state of the publishing lock is in the use state, then Indicates that there is currently a service instance querying the publishing event list. At this time, it is necessary to wait for the status of the publishing lock to be updated to the idle state before allowing the querying of the publishing event list.

在上述技术方案中,服务调用者应用初始化有发布锁,在发布锁的状态为空闲状态时,才能够查询发布事件列表,并从发布事件列表中状态为未发布的事件对象中选择目标对象,从而将目标对象对应的请求消息发布至消息中间件。通过上述技术方案,通过该发布锁可以保证同一时刻对发布事件列表的查询是唯一的,并且该发布锁为与微服务应用对应的应用锁,即不会对数据库资源(如,发布事件列表)进行加锁,从而可以在保证数据库资源的一致性的同时,有效提高分布式系统高并发的性能需求,有效降低锁冲突,提高系统吞吐量。In the above technical solution, the application of the service caller is initialized with a release lock. When the state of the release lock is idle, it can query the release event list and select the target object from the event objects whose state is unreleased in the release event list. Thus, the request message corresponding to the target object is published to the message middleware. Through the above technical solution, the release lock can ensure that the query for the release event list at the same time is unique, and the release lock is an application lock corresponding to the microservice application, that is, it does not affect database resources (such as the release event list). Locking can effectively improve the high concurrency performance requirements of distributed systems while ensuring the consistency of database resources, effectively reduce lock conflicts, and improve system throughput.

可选地,所述方法还包括:Optionally, the method further includes:

若确定目标对象对应的请求消息成功发布至消息中间件中,将发布事件列表该目标对象的状态更新为已发布,从而可以避免对已经成功发布的请求消息的重复发布。If it is determined that the request message corresponding to the target object is successfully published to the message middleware, the status of the target object in the publication event list is updated to published, thereby avoiding repeated publication of the successfully published request message.

作为示例,可以通过消息中间件反馈消息的方式确定目标对象对应的请求消息是否成功发布至消息中间件,在接收到消息中间件的反馈消息时,确定与该反馈消息对应的请求消息成功发布至消息中间件中。As an example, it can be determined whether the request message corresponding to the target object is successfully published to the message middleware by means of the message middleware feedback message, and when the feedback message from the message middleware is received, it is determined that the request message corresponding to the feedback message is successfully published to the message middleware in the message middleware.

可选地,当该方法应用于服务提供者应用时,所述服务提供者应用初始化有处理锁;在所述从所述处理事件列表中状态为未处理的事件对象中选择目标对象的步骤之前,所述方法还包括:Optionally, when the method is applied to a service provider application, the service provider application is initialized with a processing lock; before the step of selecting a target object from the event objects whose status is unprocessed in the processing event list , the method also includes:

确定所述处理锁的状态;determining the state of the processing lock;

在所述处理锁的状态为空闲状态时,将所述处理锁的状态更新为使用状态,并执行从所述处理事件列表中状态为未处理的事件对象中选择目标对象的步骤;When the state of the processing lock is an idle state, update the state of the processing lock to a use state, and perform the step of selecting a target object from the event objects whose state is unprocessed in the processing event list;

在所述根据所述目标对象对应的目标服务的方法元数据,执行所述目标服务的方法的步骤之后,所述方法还包括:After the step of executing the method for the target service according to the method metadata of the target service corresponding to the target object, the method further includes:

将所述处理锁的状态更新为空闲状态。The state of the processing lock is updated to an idle state.

在该技术方案中,在服务提供者应用可以根据目标对象对应的目标服务的方法元数据,执行目标服务,从而对目标对象对应的请求消息进行处理。在该过程中,需要保证该请求消息只能够被成功处理一次。基于此,为了避免请求消息被重复处理,在本公开中为微服务应用初始化一处理锁,使得服务提供者应用在根据目标对象对应的目标服务的方法元数据,执行目标服务的方法时,只由其一个服务实例进行处理。In this technical solution, the service provider application can execute the target service according to the method metadata of the target service corresponding to the target object, so as to process the request message corresponding to the target object. In this process, it is necessary to ensure that the request message can only be successfully processed once. Based on this, in order to avoid repeated processing of request messages, a processing lock is initialized for the microservice application in this disclosure, so that the service provider application executes the method of the target service according to the method metadata of the target service corresponding to the target object, and only Processed by one of its service instances.

示例地,在从所述处理事件列表中状态为未处理的事件对象中选择目标对象之前,通过确定处理锁的状态可以确定微服务应用中当前是否有其他服务实例正在查询该处理事件列表,若处理锁的状态处于空闲状态,则表示当前没有服务实例查询处理事件列表,此时可以执行从所述处理事件列表中状态为未处理的事件对象中选择目标对象的步骤;若处理锁的状态处于使用状态,则表示当前有服务实例查询处理事件列表,为了避免请求消息的重复处理,则需要等待处理锁的状态更新为空闲状态之后,才可允许查询处理事件列表。For example, before selecting the target object from the event objects whose status is unprocessed in the processing event list, by determining the status of the processing lock, it can be determined whether there are other service instances in the microservice application currently querying the processing event list, if If the status of the processing lock is in the idle state, it means that there is currently no service instance to query the processing event list. At this time, the step of selecting the target object from the event objects whose status is unprocessed in the processing event list can be performed; if the status of the processing lock is in If the status is used, it means that there is currently a service instance querying the processing event list. In order to avoid repeated processing of request messages, it is necessary to wait for the status of the processing lock to be updated to the idle state before allowing the query processing event list.

在上述技术方案中,服务调用者应用初始化有处理锁,在处理锁的状态为空闲状态时,才能够查询处理事件列表,并从处理事件列表中状态为未处理的事件对象中选择目标对象,从而根据目标对象对应的目标服务的方法元数据执行目标服务的方法。通过上述技术方案,通过该处理锁可以保证同一时刻对处理事件列表的查询是唯一的,从而可以有效避免对请求消息的重复处理,并且可以保证处理事件列表中的目标对象对应的请求消息可以被处理,从而可以保证分布式系统的事务处理的最终一致性。并且该处理锁为与微服务应用对应的应用锁,即不会对数据库中的处理事件列表资源进行加锁,提高事务处理的并发性,保证分布式系统的稳定运行。In the above technical solution, the application of the service caller is initialized with a processing lock. When the status of the processing lock is idle, it can query the processing event list and select the target object from the unprocessed event objects in the processing event list. Thus, the method of the target service is executed according to the method metadata of the target service corresponding to the target object. Through the above technical solution, the processing lock can ensure that the query of the processing event list at the same time is unique, thereby effectively avoiding repeated processing of the request message, and ensuring that the request message corresponding to the target object in the processing event list can be processed. processing, so that the eventual consistency of transaction processing in distributed systems can be guaranteed. And the processing lock is an application lock corresponding to the microservice application, that is, the processing event list resource in the database will not be locked, which improves the concurrency of transaction processing and ensures the stable operation of the distributed system.

可选地,所述方法还包括:Optionally, the method further includes:

若确定目标服务的方法执行完成,将处理事件列表该目标对象的状态更新为已发布,可以避免对已经执行完成的请求消息的重复执行,保证事务处理一致性。同时,也可以基于发布事件列表和处理事件列表对请求消息的处理状态进行维护和记录,便于回溯。If it is determined that the execution of the method of the target service is completed, the status of the target object in the processing event list is updated to published, which can avoid repeated execution of the completed request message and ensure transaction processing consistency. At the same time, the processing status of the request message can also be maintained and recorded based on the release event list and the processing event list, so as to facilitate retrospective.

本公开还提供一种分布式系统的事务处理装置,如图3所示,所述装置10包括:The present disclosure also provides a transaction processing device for a distributed system. As shown in FIG. 3 , the device 10 includes:

拦截模块101,用于拦截服务调用者应用发起的服务调用请求,其中,所述服务调用请求中包含请求调用的服务;An interception module 101, configured to intercept a service invocation request initiated by a service caller application, wherein the service invocation request includes the service requested to be invoked;

第一存储模块102,用于在所述服务调用请求中存在预设的一致性标识的情况下,根据所述请求调用的服务的方法元数据构建事件对象并存储所述事件对象至发布事件列表,其中,所述事件对象的初始状态为未发布;The first storage module 102 is configured to construct an event object according to the method metadata of the service invoked by the request and store the event object in a published event list when there is a preset consistency identifier in the service invocation request , wherein the initial state of the event object is unpublished;

发布模块103,用于从所述发布事件列表中状态为未发布的事件对象中选择目标对象,并将所述目标对象对应的请求消息发布至消息中间件,其中,所述请求消息中包括所述目标对象对应的目标服务的方法元数据,以使提供所述目标服务的服务提供者应用基于所述请求消息提供所述目标服务。The publishing module 103 is configured to select a target object from the event objects whose status is unpublished in the publishing event list, and publish a request message corresponding to the target object to the message middleware, wherein the request message includes all Method metadata of the target service corresponding to the target object, so that the service provider application that provides the target service provides the target service based on the request message.

可选地,所述发布模块包括:Optionally, the publishing module includes:

将所述请求消息发布至消息中间件中、与所述服务提供者应用的标识信息对应的消息队列中,以由所述服务提供者应用从所述消息队列中获取所述请求消息。The request message is published to a message queue corresponding to the identification information of the service provider application in the message middleware, so that the service provider application can obtain the request message from the message queue.

可选地,所述服务调用者应用初始化有发布锁;所述装置还包括:Optionally, the service caller application is initialized with a release lock; the device further includes:

第一确定模块,用于在所述发布模块从所述发布事件列表中状态为未发布的事件对象中选择目标对象之前,确定所述发布锁的状态;a first determining module, configured to determine the state of the release lock before the release module selects a target object from the event objects whose state is unreleased in the release event list;

第一更新模块,用于在所述发布锁的状态为空闲状态的情况下,将所述发布锁的状态更新为使用状态,并触发所述发布模块从所述发布事件列表中状态为未发布的事件对象中选择目标对象;a first update module, configured to update the state of the release lock to a use state when the state of the release lock is an idle state, and trigger the release module to change the state from the release event list to unreleased Select the target object from the event object;

所述装置还包括:The device also includes:

第二更新模块,用于在所述发布模块将所述目标对象对应的请求消息发布至消息中间件之后,将所述发布锁的状态更新为空闲状态。The second update module is configured to update the state of the release lock to an idle state after the release module releases the request message corresponding to the target object to the message middleware.

本公开还提供一种分布式系统的事务处理装置,应用于服务提供者应用,如图4所示,所述装置20包括:The present disclosure also provides a transaction processing device for a distributed system, which is applied to a service provider application. As shown in FIG. 4 , the device 20 includes:

获取模块201,用于从消息中间件获取请求消息,其中,所述请求消息中包括服务的方法元数据;an obtaining module 201, configured to obtain a request message from the message middleware, wherein the request message includes method metadata of the service;

第二存储模块202,用于根据所述服务的方法元数据构建事件对象并存储所述事件对象至处理事件列表中,其中,所述事件对象的初始状态为未处理;The second storage module 202 is configured to construct an event object according to the method metadata of the service and store the event object in the processing event list, wherein the initial state of the event object is unprocessed;

执行模块203,用于从所述处理事件列表中状态为未处理的事件对象中选择目标对象,并根据所述目标对象对应的目标服务的方法元数据,执行所述目标服务的方法,以为发起所述目标对象对应的请求消息的服务调用者应用提供所述目标服务。The execution module 203 is configured to select a target object from the event objects whose status is unprocessed in the processing event list, and execute the method of the target service according to the method metadata of the target service corresponding to the target object, in order to initiate The service caller application of the request message corresponding to the target object provides the target service.

可选地,所述获取模块包括:Optionally, the obtaining module includes:

从所述消息中间件中、与所述服务提供者应用的标识信息对应的消息队列中获取所述请求消息。The request message is acquired from a message queue corresponding to the identification information of the service provider application in the message middleware.

可选地,所述服务提供者应用初始化有处理锁;所述装置还包括:Optionally, the service provider application is initialized with a processing lock; the device further includes:

第二确定模块,用于在所述执行模块从所述处理事件列表中状态为未处理的事件对象中选择目标对象之前,确定所述处理锁的状态;a second determining module, configured to determine the state of the processing lock before the execution module selects a target object from the event objects whose status is unprocessed in the processing event list;

第三更新模块,用于在所述处理锁的状态为空闲状态时,将所述处理锁的状态更新为使用状态,并触发所述执行模块从所述处理事件列表中状态为未处理的事件对象中选择目标对象;A third update module, configured to update the state of the process lock to a use state when the state of the process lock is an idle state, and trigger the execution module to select the unprocessed event from the process event list Select the target object in the object;

所述装置还包括:The device also includes:

第四更新模块,用于在所述执行模块根据所述目标对象对应的目标服务的方法元数据,执行所述目标服务的方法之后,将所述处理锁的状态更新为空闲状态。The fourth update module is configured to update the state of the processing lock to an idle state after the execution module executes the method of the target service according to the method metadata of the target service corresponding to the target object.

关于上述实施例中的装置,其中各个模块执行操作的具体方式已经在有关该方法的实施例中进行了详细描述,此处将不做详细阐述说明。Regarding the apparatus in the above-mentioned embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be described in detail here.

图5是根据一示例性实施例示出的一种电子设备700的框图。如图5所示,该电子设备700可以包括:处理器701,存储器702。该电子设备700 还可以包括多媒体组件703,输入/输出(I/O)接口704,以及通信组件705 中的一者或多者。FIG. 5 is a block diagram of an electronic device 700 according to an exemplary embodiment. As shown in FIG. 5 , the electronic device 700 may include: a processor 701 and a memory 702 . The electronic device 700 may also include one or more of a multimedia component 703 , an input/output (I/O) interface 704 , and a communication component 705 .

其中,处理器701用于控制该电子设备700的整体操作,以完成上述的分布式系统的事务处理方法中的全部或部分步骤。存储器702用于存储各种类型的数据以支持在该电子设备700的操作,这些数据例如可以包括用于在该电子设备700上操作的任何应用程序或方法的指令,以及应用程序相关的数据,例如联系人数据、收发的消息、图片、音频、视频等等。该存储器702 可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,例如静态随机存取存储器(Static Random Access Memory,简称SRAM),电可擦除可编程只读存储器(Electrically Erasable Programmable Read-Only Memory,简称EEPROM),可擦除可编程只读存储器(Erasable Programmable Read-Only Memory,简称EPROM),可编程只读存储器(Programmable Read-Only Memory,简称PROM),只读存储器(Read-Only Memory,简称 ROM),磁存储器,快闪存储器,磁盘或光盘。多媒体组件703可以包括屏幕和音频组件。其中屏幕例如可以是触摸屏,音频组件用于输出和/或输入音频信号。例如,音频组件可以包括一个麦克风,麦克风用于接收外部音频信号。所接收的音频信号可以被进一步存储在存储器702或通过通信组件705 发送。音频组件还包括至少一个扬声器,用于输出音频信号。I/O接口704 为处理器701和其他接口模块之间提供接口,上述其他接口模块可以是键盘,鼠标,按钮等。这些按钮可以是虚拟按钮或者实体按钮。通信组件705用于该电子设备700与其他设备之间进行有线或无线通信。无线通信,例如Wi-Fi,蓝牙,近场通信(Near FieldCommunication,简称NFC),2G、3G、4G、 NB-IOT、eMTC、或其他5G等等,或它们中的一种或几种的组合,在此不做限定。因此相应的该通信组件705可以包括:Wi-Fi模块,蓝牙模块,NFC模块等等。Wherein, the processor 701 is used to control the overall operation of the electronic device 700 to complete all or part of the steps in the above-mentioned transaction processing method of the distributed system. The memory 702 is used to store various types of data to support operations on the electronic device 700, such data may include, for example, instructions for any application or method operating on the electronic device 700, and application-related data, Such as contact data, messages sent and received, pictures, audio, video, and so on. The memory 702 can be implemented by any type of volatile or nonvolatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, SRAM for short), electrically erasable programmable read-only memory ( Electrically Erasable Programmable Read-Only Memory (EEPROM for short), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), read-only Memory (Read-Only Memory, ROM for short), magnetic memory, flash memory, magnetic disk or optical disk. Multimedia components 703 may include screen and audio components. Wherein the screen can be, for example, a touch screen, and the audio component is used for outputting and/or inputting audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may be further stored in memory 702 or transmitted through communication component 705 . The audio assembly also includes at least one speaker for outputting audio signals. The I/O interface 704 provides an interface between the processor 701 and other interface modules, and the above-mentioned other interface modules may be a keyboard, a mouse, a button, and the like. These buttons can be virtual buttons or physical buttons. The communication component 705 is used for wired or wireless communication between the electronic device 700 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC for short), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or one or a combination of them , which is not limited here. Therefore, the corresponding communication component 705 may include: Wi-Fi module, Bluetooth module, NFC module and so on.

在一示例性实施例中,电子设备700可以被一个或多个应用专用集成电路(Application Specific Integrated Circuit,简称ASIC)、数字信号处理器 (DigitalSignal Processor,简称DSP)、数字信号处理设备(Digital Signal Processing Device,简称DSPD)、可编程逻辑器件(Programmable Logic Device,简称PLD)、现场可编程门阵列(Field Programmable Gate Array,简称FPGA)、控制器、微控制器、微处理器或其他电子元件实现,用于执行上述的分布式系统的事务处理方法。In an exemplary embodiment, the electronic device 700 may be implemented by one or more Application Specific Integrated Circuit (ASIC), Digital Signal Processor (DSP), Digital Signal Processing (Digital Signal) Processing Device (DSPD for short), Programmable Logic Device (PLD for short), Field Programmable Gate Array (FPGA for short), controller, microcontroller, microprocessor or other electronic components , which is used to execute the above-mentioned transaction processing method of the distributed system.

在另一示例性实施例中,还提供了一种包括程序指令的计算机可读存储介质,该程序指令被处理器执行时实现上述的分布式系统的事务处理方法的步骤。例如,该计算机可读存储介质可以为上述包括程序指令的存储器702,上述程序指令可由电子设备700的处理器701执行以完成上述的分布式系统的事务处理方法。In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned transaction processing method of a distributed system are implemented. For example, the computer-readable storage medium can be the above-mentioned memory 702 including program instructions, and the above-mentioned program instructions can be executed by the processor 701 of the electronic device 700 to complete the above-mentioned transaction processing method of the distributed system.

图6是根据一示例性实施例示出的一种电子设备1900的框图。例如,电子设备1900可以被提供为一服务器。参照图6,电子设备1900包括处理器1922,其数量可以为一个或多个,以及存储器1932,用于存储可由处理器1922执行的计算机程序。存储器1932中存储的计算机程序可以包括一个或一个以上的每一个对应于一组指令的模块。此外,处理器1922可以被配置为执行该计算机程序,以执行上述的分布式系统的事务处理方法。FIG. 6 is a block diagram of an electronic device 1900 according to an exemplary embodiment. For example, the electronic device 1900 may be provided as a server. 6 , the electronic device 1900 includes a processor 1922 , which may be one or more in number, and a memory 1932 for storing computer programs executable by the processor 1922 . A computer program stored in memory 1932 may include one or more modules, each corresponding to a set of instructions. In addition, the processor 1922 may be configured to execute the computer program to perform the above-described transaction processing method of the distributed system.

另外,电子设备1900还可以包括电源组件1926和通信组件1950,该电源组件1926可以被配置为执行电子设备1900的电源管理,该通信组件1950 可以被配置为实现电子设备1900的通信,例如,有线或无线通信。此外,该电子设备1900还可以包括输入/输出(I/O)接口1958。电子设备1900可以操作基于存储在存储器1932的操作系统,例如WindowsServerTM,Mac OS XTM,UnixTM,LinuxTM等等。In addition, the electronic device 1900 may also include a power supply component 1926, which may be configured to perform power management of the electronic device 1900, and a communication component 1950, which may be configured to enable communication of the electronic device 1900, eg, wired or wireless communication. Additionally, the electronic device 1900 may also include an input/output (I/O) interface 1958 . Electronic device 1900 may operate based on an operating system stored in memory 1932, such as Windows Server™, Mac OS X™, Unix™, Linux™, and the like.

在另一示例性实施例中,还提供了一种包括程序指令的计算机可读存储介质,该程序指令被处理器执行时实现上述的分布式系统的事务处理方法的步骤。例如,该计算机可读存储介质可以为上述包括程序指令的存储器1932,上述程序指令可由电子设备1900的处理器1922执行以完成上述的分布式系统的事务处理方法。In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned transaction processing method of a distributed system are implemented. For example, the computer-readable storage medium can be the above-mentioned memory 1932 including program instructions, and the above-mentioned program instructions can be executed by the processor 1922 of the electronic device 1900 to complete the above-mentioned transaction processing method of the distributed system.

在另一示例性实施例中,还提供一种计算机程序产品,该计算机程序产品包含能够由可编程的装置执行的计算机程序,该计算机程序具有当由该可编程的装置执行时用于执行上述的分布式系统的事务处理方法的代码部分。In another exemplary embodiment, there is also provided a computer program product comprising a computer program executable by a programmable apparatus, the computer program having, when executed by the programmable apparatus, for performing the above The code part of the transaction processing method of the distributed system.

以上结合附图详细描述了本公开的优选实施方式,但是,本公开并不限于上述实施方式中的具体细节,在本公开的技术构思范围内,可以对本公开的技术方案进行多种简单变型,这些简单变型均属于本公开的保护范围。例如。The preferred embodiments of the present disclosure have been described above in detail with reference to the accompanying drawings. However, the present disclosure is not limited to the specific details of the above-mentioned embodiments. Various simple modifications can be made to the technical solutions of the present disclosure within the scope of the technical concept of the present disclosure. These simple modifications all fall within the protection scope of the present disclosure. E.g.

另外需要说明的是,在上述具体实施方式中所描述的各个具体技术特征,在不矛盾的情况下,可以通过任何合适的方式进行组合。为了避免不必要的重复,本公开对各种可能的组合方式不再另行说明。In addition, it should be noted that each specific technical feature described in the above-mentioned specific implementation manner may be combined in any suitable manner under the circumstance that there is no contradiction. In order to avoid unnecessary repetition, various possible combinations are not described in the present disclosure.

此外,本公开的各种不同的实施方式之间也可以进行任意组合,只要其不违背本公开的思想,其同样应当视为本公开所公开的内容。In addition, the various embodiments of the present disclosure can also be arbitrarily combined, as long as they do not violate the spirit of the present disclosure, they should also be regarded as the contents disclosed in the present disclosure.

Claims (10)

1. A method for transaction processing in a distributed system, the method comprising:
intercepting a service calling request initiated by a service caller application, wherein the service calling request comprises a service required to be called;
if the service calling request has a preset consistency identification, constructing an event object according to method metadata of the service called by the request and storing the event object to a published event list, wherein the initial state of the event object is not published;
selecting a target object from the event objects with unpublished states in the published event list, and publishing a request message corresponding to the target object to message middleware, wherein the request message comprises method metadata of a target service corresponding to the target object, so that a service provider application providing the target service provides the target service based on the request message.
2. The method of claim 1, wherein publishing the request message corresponding to the target object to message middleware comprises:
and publishing the request message to a message queue corresponding to the identification information of the service provider application in message middleware so as to obtain the request message from the message queue by the service provider application.
3. The method of claim 1, wherein the service caller application initializes an issue lock; before the step of selecting a target object from the event objects whose states are not published in the published event list, the method further comprises:
determining a status of the issue lock;
if the state of the issue lock is an idle state, updating the state of the issue lock to a use state, and executing the step of selecting a target object from the event objects of which the states in the issue event list are not issued;
after the step of issuing the request message corresponding to the target object to the message middleware, the method further includes:
and updating the state of the issue lock into an idle state.
4. A transaction processing method for a distributed system, applied to a service provider application, the method comprising:
acquiring a request message from message middleware, wherein the request message comprises service method metadata;
constructing an event object according to the service method metadata and storing the event object in a processing event list, wherein the initial state of the event object is unprocessed;
and selecting a target object from the event objects with unprocessed states in the processing event list, and executing a method of the target service according to the method metadata of the target service corresponding to the target object so as to provide the target service for a service caller application initiating a request message corresponding to the target object.
5. The method of claim 4, wherein the obtaining the request message from the message middleware comprises:
and acquiring the request message from a message queue corresponding to the identification information of the service provider application in the message middleware.
6. A transaction processing apparatus for a distributed system, the apparatus comprising:
the system comprises an interception module, a service calling module and a service processing module, wherein the interception module is used for intercepting a service calling request initiated by a service caller application, and the service calling request comprises a service required to be called;
the first storage module is used for constructing an event object according to the method metadata of the service called by the request and storing the event object to a published event list under the condition that a preset consistency identifier exists in the service calling request, wherein the initial state of the event object is not published;
and the publishing module is used for selecting a target object from the event objects with unpublished states in the published event list and publishing a request message corresponding to the target object to message middleware, wherein the request message comprises method metadata of a target service corresponding to the target object, so that a service provider application providing the target service provides the target service based on the request message.
7. A transaction processing apparatus for a distributed system, the apparatus being adapted for use with a service provider application, the apparatus comprising:
an obtaining module, configured to obtain a request message from a message middleware, where the request message includes method metadata of a service;
the second storage module is used for constructing an event object according to the method metadata of the service and storing the event object in a processed event list, wherein the initial state of the event object is unprocessed;
and the execution module is used for selecting a target object from the event objects with unprocessed states in the processing event list, and executing the method of the target service according to the method metadata of the target service corresponding to the target object so as to provide the target service for the service caller application initiating the request message corresponding to the target object.
8. A transaction processing system for a distributed system, the system comprising:
a message publishing component coupled with a service caller application, the message publishing component to perform the steps of the method of any of claims 1-3;
the message middleware is used for storing the request message;
a service provider application for performing the steps of the method of claim 4 or 5.
9. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 5.
10. An electronic device, comprising:
a memory having a computer program stored thereon;
a processor for executing the computer program in the memory to carry out the steps of the method of any one of claims 1 to 5.
CN201911236917.0A 2019-12-05 2019-12-05 Transaction processing methods, devices, systems, media and equipment for distributed systems Active CN111258723B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201911236917.0A CN111258723B (en) 2019-12-05 2019-12-05 Transaction processing methods, devices, systems, media and equipment for distributed systems

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201911236917.0A CN111258723B (en) 2019-12-05 2019-12-05 Transaction processing methods, devices, systems, media and equipment for distributed systems

Publications (2)

Publication Number Publication Date
CN111258723A true CN111258723A (en) 2020-06-09
CN111258723B CN111258723B (en) 2024-03-19

Family

ID=70950952

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201911236917.0A Active CN111258723B (en) 2019-12-05 2019-12-05 Transaction processing methods, devices, systems, media and equipment for distributed systems

Country Status (1)

Country Link
CN (1) CN111258723B (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111708619A (en) * 2020-08-20 2020-09-25 上海冰鉴信息科技有限公司 Distributed transaction processing method and system based on message queue and database
CN113778475A (en) * 2020-06-18 2021-12-10 北京京东振世信息技术有限公司 Information processing method and device
CN114172821A (en) * 2022-02-08 2022-03-11 树根互联股份有限公司 Service state synchronization method and device and server
CN114253747A (en) * 2021-12-27 2022-03-29 北京宇信科技集团股份有限公司 Distributed message management system and method
CN115878352A (en) * 2023-03-08 2023-03-31 深圳市思为软件技术有限公司 Event delivery processing method and device based on pre-subscription

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6529932B1 (en) * 1998-04-01 2003-03-04 Microsoft Corporation Method and system for distributed transaction processing with asynchronous message delivery
CN104618433A (en) * 2014-12-26 2015-05-13 国家电网公司 ECA (Event-Condition-Action) rule based service combination method
CN104639539A (en) * 2015-01-27 2015-05-20 深圳市汇朗科技有限公司 Method and device for interface calling
WO2018103318A1 (en) * 2016-12-06 2018-06-14 上海壹账通金融科技有限公司 Distributed transaction handling method and system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6529932B1 (en) * 1998-04-01 2003-03-04 Microsoft Corporation Method and system for distributed transaction processing with asynchronous message delivery
CN104618433A (en) * 2014-12-26 2015-05-13 国家电网公司 ECA (Event-Condition-Action) rule based service combination method
CN104639539A (en) * 2015-01-27 2015-05-20 深圳市汇朗科技有限公司 Method and device for interface calling
WO2018103318A1 (en) * 2016-12-06 2018-06-14 上海壹账通金融科技有限公司 Distributed transaction handling method and system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
彭亮等: "ITXC:一种基于事务消息的分布式事务方案", no. 05, pages 63 - 66 *

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113778475A (en) * 2020-06-18 2021-12-10 北京京东振世信息技术有限公司 Information processing method and device
CN111708619A (en) * 2020-08-20 2020-09-25 上海冰鉴信息科技有限公司 Distributed transaction processing method and system based on message queue and database
US11354303B2 (en) 2020-08-20 2022-06-07 Shanghai Icekredit, Inc. Distributed transaction processing method and system based on message queue and database
CN114253747A (en) * 2021-12-27 2022-03-29 北京宇信科技集团股份有限公司 Distributed message management system and method
CN114253747B (en) * 2021-12-27 2023-04-28 北京宇信科技集团股份有限公司 Distributed message management system and method
CN114172821A (en) * 2022-02-08 2022-03-11 树根互联股份有限公司 Service state synchronization method and device and server
CN114172821B (en) * 2022-02-08 2022-05-24 树根互联股份有限公司 Service state synchronization method and device and server
CN115878352A (en) * 2023-03-08 2023-03-31 深圳市思为软件技术有限公司 Event delivery processing method and device based on pre-subscription

Also Published As

Publication number Publication date
CN111258723B (en) 2024-03-19

Similar Documents

Publication Publication Date Title
CN111258723B (en) Transaction processing methods, devices, systems, media and equipment for distributed systems
CN112424746B (en) In-situ triggered functions as a service within a service mesh
US11409719B2 (en) Co-locating microservice persistence containers within tenant-specific database
CN108123996B (en) Application management service instance
CN111819535B (en) Method and system for implementing asynchronous bidirectional binding between different frameworks
CN103038788B (en) Providing multiple network resources
CN107045454B (en) Cross-process distributed transaction control method and related system
CN111176858A (en) A data request processing method and device
CN109951546B (en) Transaction request processing method, device, equipment and medium based on intelligent contract
CN111414381A (en) Data processing method and device, electronic equipment and storage medium
CN112395107A (en) Tax control equipment control method and device, storage medium and electronic equipment
CN115210689A (en) System and method for a reactive messaging client for use in a microservice environment
CN114500630A (en) Method, apparatus, system, storage medium and electronic device for message push
CN110933188A (en) Remote service calling method, system, server and storage medium
CN112506590A (en) Interface calling method and device and electronic equipment
CN112819638A (en) Transaction weight judging method, device, equipment and computer readable medium
CN110321207A (en) Method for scheduling task, device, equipment and computer readable storage medium
US11411812B2 (en) Dynamic service creation for microservice-based integration service
CN111937013A (en) Electronic device management
KR20220061995A (en) Provides optimization of microservices architecture
CN113645260A (en) Service retry method, device, storage medium and electronic equipment
US9942346B2 (en) Caching mechanism for determining validity of cached data using web application business logic
CN118449989B (en) Methods, apparatus, devices, and computer-readable media for invoking business services
JP7140614B2 (en) Management system and management method
CN111008023A (en) Instance deployment method and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20250304

Address after: Room E162, Room 301 to 353, No.1 Kehua Street, Tianhe District, Guangzhou City, Guangdong Province, 510640 (Office only)

Patentee after: Guangzhou binju Technology Co.,Ltd.

Country or region after: China

Address before: Hunnan rookie street Shenyang city Liaoning province 110179 No. 2

Patentee before: NEUSOFT Corp.

Country or region before: China

TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20250408

Address after: No. 4838, Enterprise Development Service Center, Xiji Town, Tongzhou District, Beijing, 100000

Patentee after: Beijing Sparkling Enterprise Management Planning Co.,Ltd.

Country or region after: China

Address before: Room E162, Room 301 to 353, No.1 Kehua Street, Tianhe District, Guangzhou City, Guangdong Province, 510640 (Office only)

Patentee before: Guangzhou binju Technology Co.,Ltd.

Country or region before: China