WO2023273028A1 - Transaction processing method and related product - Google Patents

Transaction processing method and related product Download PDF

Info

Publication number
WO2023273028A1
WO2023273028A1 PCT/CN2021/125230 CN2021125230W WO2023273028A1 WO 2023273028 A1 WO2023273028 A1 WO 2023273028A1 CN 2021125230 W CN2021125230 W CN 2021125230W WO 2023273028 A1 WO2023273028 A1 WO 2023273028A1
Authority
WO
WIPO (PCT)
Prior art keywords
message
transaction
microservice
data source
transaction manager
Prior art date
Application number
PCT/CN2021/125230
Other languages
French (fr)
Chinese (zh)
Inventor
李海兵
Original Assignee
深圳市商汤科技有限公司
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 深圳市商汤科技有限公司 filed Critical 深圳市商汤科技有限公司
Publication of WO2023273028A1 publication Critical patent/WO2023273028A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/06Buying, selling or leasing transactions
    • G06Q30/0601Electronic shopping [e-shopping]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q30/00Commerce
    • G06Q30/06Buying, selling or leasing transactions
    • G06Q30/0601Electronic shopping [e-shopping]
    • G06Q30/0633Lists, e.g. purchase orders, compilation or processing
    • G06Q30/0635Processing of requisition or of purchase orders
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/547Messaging middleware
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue

Definitions

  • the present disclosure relates to the technical field of the Internet, in particular to a transaction processing method and related products.
  • microservice-based e-commerce platforms and other microservice-based products business splitting allows each microservice to be deployed and run independently, and the transactions involved in the same microservice may correspond to data update operations from different data sources. How to ensure the data consistency of transactions involved in microservices is an urgent problem to be solved.
  • Embodiments of the present disclosure provide a transaction processing method and related products.
  • the first aspect of an embodiment of the present disclosure provides a transaction processing method, including: creating a first microservice; at least two transactions corresponding to the first microservice, the at least two transactions including the first transaction and the second transaction, and the first data source corresponding to the first transaction is different from the second data source corresponding to the second transaction, then create a chained transaction manager; through the chained transaction manager, the The transaction corresponding to the first data source is processed with the transaction corresponding to the second data source.
  • the method further includes: if the first microservice corresponds to at least one transaction and the at least one transaction corresponds to the same target data source, creating a single data source A transaction manager; the at least one transaction is processed by the single data source transaction manager.
  • the creating a single data source transaction manager includes: when the target data source is a default data source, configuring the default transaction manager through annotations, the default A transaction manager implements transaction support of the default data source, and the single data source transaction manager includes the default transaction manager.
  • the creating a chained transaction manager includes: creating a transaction manager, and setting an attribute of the transaction manager as a chained transaction manager through annotations.
  • the method before creating the first microservice, further includes: receiving a service request initiated by the client; determining at least one microservice involved in the service request, and the at least one The microservice includes the first microservice.
  • the at least one microservice further includes a second microservice
  • the method further includes: creating the second microservice, creating a first message table or a first message set; A first message related to the service request is delivered to a first message queue, and the second microservice is used to obtain the first message from the first message queue; Whether there is a message identical to the identifier of the first message in the first message table or first message set; there is no identifier of the first message in the first message table or first message set In the case of the same message, process the first message through the second microservice;
  • the method further includes: when the first message queue does not receive the message for the first message returned by the second microservice If the message processing of the message succeeds in confirming the message, the second microservice is notified through the first message queue using a best effort notification policy.
  • the method further includes: after the first message is successfully processed, persisting the first message to the first in the message table or the first message set.
  • the method further includes: if there is a message with the same identifier as the first message in the first message table or first message set, discarding the first news.
  • the method further includes: defining the table name of the first message table or the first The collection name of the message collection.
  • the method further includes: defining an application listener through a service discovery mechanism, and the application listener is used to configure a packet scanning path of the first microservice.
  • the creating the first microservice includes: implementing dynamic configuration and registration of the first microservice through an automatic configuration mechanism.
  • the method is implemented based on automatically configured pluggable components.
  • a second aspect of an embodiment of the present disclosure provides a transaction processing device, including:
  • the first creation unit is configured to create the first microservice
  • the second creation unit is configured to correspond to at least two transactions in the first microservice, the at least two transactions include a first transaction and a second transaction, and the first data source corresponding to the first transaction and the If the second data source corresponding to the second transaction is different, create a chained transaction manager;
  • the transaction processing unit is configured to process the transaction corresponding to the first data source and the transaction corresponding to the second data source through the chain transaction manager.
  • a third aspect of the embodiments of the present disclosure provides a server, including a processor and a memory, the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to invoke the program instructions , execute the step instruction in the first aspect of the embodiment of the present disclosure.
  • a fourth aspect of the embodiments of the present disclosure provides a computer-readable storage medium, wherein the above-mentioned computer-readable storage medium is used to store a computer program, and the above-mentioned computer program enables the computer to execute the method described in the first aspect of the embodiments of the present disclosure. some or all of the steps.
  • a fifth aspect of the embodiments of the present disclosure provides a computer program product, wherein the computer program product includes a computer program, and when the computer program is executed by a computer, the computer executes the parts described in the first aspect of the embodiments of the present disclosure or all steps.
  • the computer program product may be a software installation package.
  • a sixth aspect of the embodiments of the present disclosure provides a computer program.
  • the computer program is executed by a processor, some or all of the steps described in the first aspect of the embodiments of the present disclosure are implemented.
  • the server creates a first microservice; the first microservice corresponds to at least two transactions, the at least two transactions include a first transaction and a second transaction, and the first transaction corresponds to If the first data source and the second data source corresponding to the second transaction are different, then create a chained transaction manager; through the chained transaction manager, the transaction corresponding to the first data source and the The transaction corresponding to the second data source is processed.
  • the embodiment of the present disclosure can process the transaction corresponding to the first data source and the transaction corresponding to the second data source through the chained transaction manager. Since the chained transaction manager can realize the transaction support of multiple data sources, the first transaction can be guaranteed Execute successfully or fail at the same time as the second transaction, so that the data consistency between the first transaction and the second transaction corresponding to the first microservice can be guaranteed.
  • FIG. 1 is an architecture diagram of a communication connection between a client and a server provided by an embodiment of the present disclosure
  • FIG. 2 is a schematic flowchart of a transaction processing method provided by an embodiment of the present disclosure
  • FIG. 3 is a schematic flowchart of another transaction processing method provided by an embodiment of the present disclosure.
  • FIG. 4 is a schematic flowchart of another transaction processing method provided by an embodiment of the present disclosure.
  • FIG. 5 is a schematic flowchart of another transaction processing method provided by an embodiment of the present disclosure.
  • FIG. 6 is a schematic structural diagram of a transaction processing device provided by an embodiment of the present disclosure.
  • Fig. 7 is a schematic structural diagram of a server provided by an embodiment of the present disclosure.
  • the electronic devices involved in the embodiments of the present disclosure may include devices with computing capabilities and communication capabilities, such as mobile phones, tablets, and personal computers.
  • a personal computer may also be called a user computer, and may include a desktop computer, a notebook computer, and the like.
  • the devices mentioned above are collectively referred to as electronic devices.
  • the client is a program that provides local services for the user, and the client can run on the electronic device.
  • the server involved in the embodiments of the present disclosure may be a server in a micro-server cluster, and the server may run on the server.
  • the server is for the client, and the content of the service includes providing services to the client (for example, online order service, online payment service, online query service, etc.), saving client data, and so on.
  • FIG. 1 is a structural diagram of a communication connection between a client and a server provided by an embodiment of the present disclosure.
  • the server 100 can communicate with at least one client 101 .
  • the client can establish a communication connection with the server directly, or establish a communication connection with the server through other devices.
  • the server can provide various types of services, and the client can initiate a service request to the server, and the service request can include an order request, payment request, query request, etc.
  • the server creates the first microservice; if the first microservice corresponds to at least two transactions, the at least two transactions include the first transaction and the second transaction, and the first data source corresponding to the first transaction and the second transaction corresponding to the second transaction If the data sources are different, a chain transaction manager is created; the transaction corresponding to the first data source and the transaction corresponding to the second data source are processed through the chain transaction manager.
  • the embodiment of the present disclosure can process the transaction corresponding to the first data source and the transaction corresponding to the second data source through the chained transaction manager.
  • the chained transaction manager can realize the transaction support of multiple data sources, the first transaction can be guaranteed Execute successfully or fail at the same time as the second transaction, so that the data consistency between the first transaction and the second transaction corresponding to the first microservice can be guaranteed, and the data consistency of all transactions involved in a microservice can be improved.
  • the server can provide many microservices, and the server can create microservices in response to business requests initiated by the client.
  • a business request initiated by a client may involve data aggregation or data update of multiple microservices.
  • the data update may include: update of product inventory data, update of product information in the shopping cart, update of order data, etc.; data aggregation may include: the user simultaneously displays the inventory on the product browsing interface Aggregation of information, product information, product discount information and other data.
  • Microservice a software development technique, is a variant of Service-Oriented Architecture (SOA), which constructs an application as a set of loosely coupled services.
  • SOA Service-Oriented Architecture
  • a microservice can implement a certain function.
  • Transaction refers to a program execution unit that accesses and possibly updates various data items in the database.
  • a microservice may correspond to one transaction, or at least two transactions.
  • the first microservice may be an order service
  • at least two transactions corresponding to the first microservice may include: a commodity order information saving transaction, an inventory message queue delivery transaction, and a shopping cart message queue delivery transaction.
  • a commodity order information saving transaction For example, after a user initiates a product purchase request on a mobile phone, an order service can be created.
  • the order service creates an order, and the order service stores the order data (for example, order number) in the first data source (for example, MySQL database), which is the order For the first transaction corresponding to the service, you can store the detailed data of the order (for example, the time of placing the order, the quantity of the ordered goods, the details of the purchased goods, the purchase amount, etc.) in the second data source (for example, the MongoDB database), which is the order For the second transaction corresponding to the service, the order service can also deliver a message to the message queue of the inventory service (for example, Kafka message queue), so that the inventory minus the quantity of purchased goods (for example, subtract 1 from the inventory data), and deliver another A message to the cart service's message queue (for example, a Kafka message queue) to ask the cart service to delete the item.
  • Data sources can include databases or database servers used by database applications.
  • the transactions involved in the same microservice may correspond to different data sources. If the transactions of different data sources are implemented separately, since multiple transactions involved in the same microservice are processed separately, it is difficult to ensure that the transactions involved in the same microservice data consistency.
  • the first data source corresponding to the first transaction is different from the second data source corresponding to the second transaction, and the type of the first data source may be different from the type of the second data source.
  • the first data source corresponding to the first transaction refers to the first data source that the first transaction needs to access
  • the second data source corresponding to the second transaction refers to the second data source that the second transaction needs to access.
  • Chained transaction manager is a kind of transaction manager, which can define a transaction chain, and multiple transactions are submitted sequentially in the chained transaction manager.
  • the first microservice corresponds to three transactions: commodity order information storage transaction, inventory message queue delivery transaction, and shopping cart message queue delivery transaction, and the commodity order information storage transaction, inventory message queue delivery transaction, and shopping cart message queue delivery transaction can be submitted in sequence affairs.
  • the chained transaction manager can support transaction processing of multiple types of data sources, and ensure that the three transactions corresponding to the first microservice are executed successfully or fail at the same time, thereby ensuring the data consistency of the three transactions corresponding to the first microservice.
  • the data consistency in the embodiments of the present disclosure may include strong data consistency or weak data consistency.
  • Data weak consistency can also be called data final consistency.
  • a user places an order for a product on an e-commerce platform. After the order service creates an order, if the order service is executed successfully, the inventory service will decrease the inventory by 1, and the shopping cart service will delete the product in the user's shopping cart. If the order is successfully executed, the inventory is reduced by 1, and the product in the user's shopping cart is deleted, the three are consistent, and the data consistency is considered.
  • the final consistency does not require that the three must be completed at the same time, only that they are consistent in the end. Can. Strong data consistency requires that all three must be completed at the same time. If the order service is executed successfully and the inventory has not changed, or the product in the user's shopping cart has not been deleted, the data is considered inconsistent and data consistency is not satisfied.
  • FIG. 2 is a schematic flowchart of a transaction processing method provided by an embodiment of the present disclosure. The method is applied to the server shown in FIG. 1, and as shown in FIG. 2, the transaction processing method may include the following steps.
  • the server creates a first microservice.
  • the server can create the first microservice at the request of the user, or can create the microservice by itself.
  • the server can create the first microservice, namely the order service; when the client initiates a payment request to the server, the server can create the first microservice, namely the payment service .
  • the server can actively create the first microservice, that is, the query service.
  • the server creates a chained transaction manager.
  • a microservice may correspond to at least one transaction.
  • the data sources corresponding to the at least two transactions may be the same or different.
  • a chained transaction manager may be created, and the at least two transactions are processed through the chained transaction manager.
  • the order service may correspond to an order information saving transaction, an inventory message queue delivery transaction, and a shopping cart message queue delivery transaction.
  • the data source corresponding to the order information saving transaction can be a MySQL database
  • the data source corresponding to the inventory message queue delivery transaction can be a Kafka (kafka) message queue
  • the data source corresponding to the shopping cart message queue delivery transaction can be kafka.
  • Transaction generally refers to something to be done or done. In computer terms, it refers to a program execution unit (unit) that accesses and possibly updates various data items in a database. Transactions are usually caused by the execution of user programs written in advanced database manipulation languages or programming languages (such as SQL, C++ or Java), and are defined by statements (or function calls) such as begin transaction and end transaction. A transaction consists of all operations performed between the begin transaction and the end transaction.
  • the server may create a chained transaction manager when at least two transactions corresponding to the first microservice have transactions with different data sources.
  • the chained transaction manager can connect at least two transactions in series. After connecting the above two transactions, the chained transaction manager can process them in a unified manner.
  • the above at least two transactions either fail at the same time or succeed at the same time, thus ensuring that the first micro
  • the data consistency of the above at least two transactions corresponding to the service may be created.
  • the server creates a chained transaction manager, which may include the following steps: the server creates a transaction manager, and sets the property of the transaction manager as a chained transaction manager through annotations.
  • annotations can be understood as special tags in the code, and these tags can be read during compilation, class loading, and runtime, and corresponding processing is performed.
  • software developers can embed supplementary information in source code without changing the original code and logic.
  • it may be determined whether to set the property of the transaction manager according to all the data sources involved in the first microservice corresponding to at least two transactions.
  • the default transaction manager can only implement transactions of one default data source If it is supported, it is necessary to reset the property of the transaction manager to be a chained transaction manager, so that the chained transaction manager can realize the above-mentioned transaction support of at least two different data sources. If all the data sources involved in at least two transactions of the first microservice are the same data source, since the transaction annotation is set as the default transaction manager by default, there is no need to reset the properties of the transaction manager.
  • the embodiments of the present disclosure can enable transactions through annotations and set transaction manager types.
  • the transaction annotation may be @transactional annotation.
  • @Transactional annotation can be added at the place where transaction management is required.
  • the @Transactional annotation can be applied to interface definitions and interface methods, class definitions, and public methods of classes.
  • the @Transactional annotation can be added to the service layer.
  • the server processes the transaction corresponding to the first data source and the transaction corresponding to the second data source through the chained transaction manager.
  • the chained transaction manager may sequentially process the transaction corresponding to the first data source and the transaction corresponding to the second data source. Specifically, the chained transaction manager may process the first transaction and the second transaction in sequence.
  • the chained transaction manager can realize the transaction support of multiple data sources. If the above-mentioned at least two transactions correspond to two different data sources: the first data source and the second data source, the created chained transaction manager can realize the second The transaction support of a data source and a second data source; if the above-mentioned at least two transactions correspond to three different data sources: the first data source, the second data source and the third data source, then the created chain transaction manager can Implement transaction support for the first data source, the second data source, and the third data source, and so on.
  • the embodiment of the present disclosure can process the transaction corresponding to the first data source and the transaction corresponding to the second data source through the chained transaction manager. Since the chained transaction manager can realize the transaction support of multiple data sources, the first transaction can be guaranteed Execute successfully or fail at the same time as the second transaction, so that the data consistency of the first transaction and the second transaction corresponding to the first microservice can be guaranteed, and the data consistency of all transactions involved in a microservice can be guaranteed.
  • FIG. 3 is a schematic flowchart of another transaction processing method provided by an embodiment of the present disclosure. Fig. 3 is further optimized on the basis of Fig. 2. As shown in Fig. 3, the transaction processing method may include the following steps.
  • the server creates a first microservice.
  • the server when the first microservice corresponds to at least two transactions, the at least two transactions include the first transaction and the second transaction, and the first data source corresponding to the first transaction is different from the second data source corresponding to the second transaction , the server creates a chained transaction manager.
  • the server processes the transaction corresponding to the first data source and the transaction corresponding to the second data source through the chained transaction manager.
  • steps 301 to 303 may refer to steps 201 to 203 shown in FIG. 2 , which will not be repeated here.
  • the server creates a single data source transaction manager.
  • a single data source transaction manager can implement transaction support for one data source. If at least one transaction corresponds to the same target data source as the default data source, the server configures the default transaction manager through annotations, and the default transaction manager can implement the transaction support of the default data source. If at least one transaction corresponds to the same target data source that is not the default data source, the server sets the property of the transaction manager through the transaction annotation as the target transaction manager that supports the target data source, and the target transaction manager can implement the transaction of the target data source support.
  • the server creates a single data source transaction manager, which may specifically include the following steps: when the target data source is the default data source, configure the default transaction manager by means of annotations, the A default transaction manager implements transaction support of the default data source, and the single data source transaction manager includes the default transaction manager.
  • the target data source is associated with the default data source
  • transactions can be enabled through annotations, and the transaction manager type can be determined as the default transaction manager.
  • the default transaction manager can be configured directly through annotations, and the default transaction manager can implement the transactions of the default data source Yes, the default transaction manager is a single data source transaction manager.
  • the server processes at least one transaction through the single data source transaction manager.
  • the single data source transaction manager can process multiple transactions of the same data source at the same time, and multiple transactions can be carried out at the same time. Compared with the transaction serial processing of the chained transaction manager, the single data source The transaction manager is more efficient in transaction processing.
  • the transaction in the embodiments of the present disclosure may be a data update transaction.
  • FIG. 4 is a schematic flowchart of another transaction processing method provided by an embodiment of the present disclosure.
  • FIG. 4 is further optimized on the basis of FIG. 2 .
  • the transaction processing method may include the following steps.
  • the server receives a service request initiated by the user.
  • the service request may include an order request, a payment request, a query request, etc., and the type of the service request is not limited in this embodiment.
  • the server determines at least one microservice involved in the service request, where the at least one microservice includes the first microservice.
  • different service requests involve different microservices.
  • an order request may involve order service, inventory service, shopping cart service, etc., and more microservices are involved in the order request; query requests may only involve query services, and fewer microservices are involved in query requests.
  • the correspondence between business requests and the number and types of microservices can be pre-stored on the server side, and different business requests can correspond to different numbers of microservices and different types of microservices.
  • the embodiment of the present disclosure can decide which microservices to create and the number of microservices to create according to the number and type of microservices involved in the business request initiated by the user, neither occupying redundant microservice resources nor creating fewer microservices Microservices prevent business requests from being processed, and microservices can be created flexibly to better implement business requests initiated by clients.
  • the server creates the first microservice.
  • the server when the first microservice corresponds to at least two transactions, the at least two transactions include the first transaction and the second transaction, and the first data source corresponding to the first transaction is different from the second data source corresponding to the second transaction , the server creates a chained transaction manager.
  • the server processes the transaction corresponding to the first data source and the transaction corresponding to the second data source through the chained transaction manager.
  • steps 403 to 405 may refer to steps 201 to 203 shown in FIG. 2 , which will not be repeated here.
  • FIG. 5 is a schematic flowchart of another transaction processing method provided by an embodiment of the present disclosure.
  • Fig. 5 is further optimized on the basis of Fig. 4.
  • the transaction processing method may include the following steps.
  • the server receives a service request initiated by the user.
  • the server determines at least two microservices involved in the service request, and the at least two microservices include a first microservice and a second microservice.
  • the server creates a first microservice and a second microservice, and creates a first message table or a first message set.
  • the at least two microservices may be created at the same time, or the at least two microservices may be created separately.
  • the first message table or the first message set can be created in the data source corresponding to the second microservice, and the second microservice can process the first message. After the processing is successful, the first message can be persisted to the in the first message table.
  • Different files can be defined in different databases to store messages. For example, a message table can be created in a MySQL database to store messages, and a message collection can be created in a MongoDB database to store messages.
  • the server creates the first microservice, which may specifically include the following steps: implementing dynamic configuration and registration of the first microservice through an automatic configuration mechanism.
  • microservices can be dynamically created according to the activation status and attribute values of annotations, and the created effective microservices can be registered in the container, so as to realize dynamic configuration and registration of microservices.
  • the configuration file of the resource file for example, properties or yml configuration
  • the startup class of the microservice is configured in the configuration file, use Enable annotation
  • the Enable annotation starts automatic configuration, configures and registers related microservices according to the property value of the Enable annotation, and realizes the creation of microservices. Since the enabling status and attribute values of the Enable annotation can be set by developers, microservices can be dynamically created according to project needs. If the startup class of the microservice configured in the configuration file does not use the Enable annotation, the microservice can be created according to the default configuration.
  • the container in this embodiment of the disclosure may be a Spring container.
  • the server delivers the first message related to the service request to the first message queue, and the second microservice is used to obtain the first message from the first message queue.
  • the message queue is a container for storing messages during message transmission.
  • Messages can be as simple as containing only text strings, or more complex as possibly containing embedded objects.
  • a topic (topic) for consumption by the second microservice (consumer) can be created for the first message queue.
  • the second microservice can pull the first message corresponding to the second microservice topic from the first message queue.
  • the first The message queue can also actively push the first message to the second microservice.
  • another topic for consumption by the third microservice (consumer) can also be created for the first message queue.
  • the message queue has an asynchronous decoupling function.
  • the message queue is used for message transmission, which can greatly improve the throughput of the interface, and at the same time achieve the purpose of traffic peak shaving.
  • Asynchronous The transaction of the first microservice and the transaction of the second microservice do not need to be executed synchronously. Through the message queue, after the first microservice delivers the first message to the first message queue, it can also deliver other messages to For other message queues, there is no need to wait for the second microservice to process the first message, which can greatly improve the throughput of the interface.
  • Decoupling Assume that the first microservice and the second microservice are two classes respectively. If the first microservice directly calls a method of the second microservice, then the first microservice will have a dependency (that is, coupling) on the second microservice. If the code of the second microservice changes in the future, it may affect the first microservice. If a message queue is used, both the first microservice and the second microservice depend on the message queue, and there is no direct dependence between the first microservice and the second microservice, and the coupling is correspondingly reduced.
  • the first message related to the service request may be generated by the first microservice, and the server may generate the first message through the first microservice.
  • the first microservice is the order service
  • the second microservice is the inventory service
  • the first message related to the business request can be generated by the order service
  • the first message can include the order number, Commodity details (for example, the quantity of the commodity, the model of the commodity, etc.) and the like.
  • the second microservice obtains the first message, it may subtract the quantity of the commodity in the commodity detail from the stock quantity of the corresponding commodity model in the commodity detail according to the commodity detail included in the first message.
  • the at least two microservices may include a first microservice, a second microservice and a third microservice.
  • the server may generate a third message through the first microservice, and deliver the third message to the second message queue, and the third microservice is used to obtain the third message from the second message queue.
  • a topic for consumption by the third microservice can be created for the second message queue, the third microservice can pull the third message from the second message queue, and the second message queue can also actively send the third microservice Push the third message.
  • the third message may be generated by the first microservice, and the server may generate the third message through the first microservice.
  • the third message may include an order number. After the third microservice obtains the third message, it can remove the commodity corresponding to the order number from the shopping cart according to the order number included in the third message.
  • the server determines whether there is a message with the same identifier as the first message in the first message table or the first message set according to the identifier of the first message.
  • step 506 the following steps may also be performed:
  • the server notifies the second microservice through the first message queue using a best effort notification policy.
  • the second microservice may obtain a processing result of processing success or processing failure. If the processing is successful, as long as the second microservice does not fail, the second microservice will return a message processing success confirmation message for the first message to the first message queue. If the second microservice fails, such as the service hangs up or the network fails, the second microservice cannot send the processing result to the first message queue, and the server can notify the second microservice through the first message queue using the best effort notification strategy. Service, to ensure the final consistency of data for transactions corresponding to multiple microservices, thereby ensuring the final consistency of multiple data source transactions. If the processing fails, the second microservice will return a message processing failure message for the first message to the first message queue. The microservice processes the first message until receiving a message processing success confirmation message for the first message returned by the second microservice.
  • a best-effort notification policy is a policy that uses best efforts to notify.
  • the first message queue can periodically notify the second microservice to let the second microservice return the processing result for the first message until the first message queue receives the processing result for the first message returned by the second microservice until.
  • the first message queue can notify the second microservice with a notification policy with a gradually increasing period, and let the second microservice return the processing result for the first message until the first message queue receives the response to the second microservice. until the processing result of the first message.
  • the second microservice can actively pull the first message from the first message queue for processing, and return the processing result to the first message queue.
  • the server can notify the first microservice through the first message queue, and the first microservice is used to communicate with The second microservice synchronizes data, thereby ensuring the consistency of transaction data of multiple microservices.
  • the server when the first microservice corresponds to at least two transactions, the at least two transactions include the first transaction and the second transaction, and the first data source corresponding to the first transaction is different from the second data source corresponding to the second transaction , the server creates a chained transaction manager.
  • the server processes the transaction corresponding to the first data source and the transaction corresponding to the second data source through the chained transaction manager.
  • steps 508 to 509 reference may be made to steps 202 to 203, which will not be repeated here.
  • the method shown in FIG. 5 may further include the following steps: after the first message is successfully processed, the server persists the first message to the first message table or in the first message collection.
  • the service data of the service request may include data required to execute the service request.
  • the data required for the order request may include: order data (for example, order number), order detail data (for example, order time, quantity of ordered goods, details of purchased goods , purchase amount, etc.).
  • Data persistence is a collective term for converting an in-memory data model to a storage model, and converting a storage model to an in-memory data model.
  • the first message may be stored in the first message table or first message set.
  • the method shown in Figure 5 may also include the following steps:
  • the server discards the first message.
  • the server can create a first message table in the data source corresponding to the second microservice.
  • the first message table is used to store messages.
  • Each message can correspond to an identifier.
  • This identifier can be a global Unique identifier (globally unique identifier, GUID). Since business requests can correspond to multiple microservices, these multiple microservices can be executed in multiple devices on the network, and each message can be marked with a global identifier among these multiple microservices to distinguish different messages.
  • the second microservice may be inventory service or shopping cart service.
  • the identifier of each message is unique. In order to prevent the same message from being executed multiple times, it may be determined according to the identifier of the message whether it will be executed multiple times. If the identifiers of the first message and the second message in the first message table are the same, it indicates that the first message is put into the first message table for the second time, and the first message is directly discarded. If the identifiers of the first message and the second message are different, it indicates that the first message is put into the first message table for the first time, and the server processes the first message through the second microservice. After the first message is successfully processed, The server persistently stores the first message in the first message table through the second microservice.
  • the embodiment of the present disclosure can realize the idempotency check of the transaction message through the message table and the identifier of the message, so as to ensure the idempotence of the transaction message.
  • step 503 the server defines the table name of the first message table or the set name of the first message set through an expression language.
  • the expression language may be Spring Expression Language (Spring Expression Language, SpEL).
  • SpEL expressions can realize the automatic configuration of table names or collection names, and can flexibly define table names or collection names.
  • the above method may further include: defining an application listener through a service discovery mechanism (Service Provider Interface, SPI), and the application listener is used to configure a packet scanning path of the first microservice.
  • SPI Service Provider Interface
  • SPI is a service discovery mechanism provided inside the Java development toolkit. SPI searches for files in the META-INF/services folder under the ClassPath path, and automatically loads the classes defined in the files.
  • the SPI may define an application listener, and the application listener is used to configure the packet scanning path of the first microservice. It does not require users to add package scanning paths to the startup class, reducing the difficulty of user development.
  • the methods in the embodiments of the present disclosure can be implemented by pluggable components based on automatic configuration.
  • This component can be used in the development of the Spring project, and can be used in the e-commerce platform based on micro-service development and other micro-service development products.
  • the software product of the embodiments of the present disclosure may be a pluggable component.
  • the Spring Boot Starter component can be quickly introduced in any Spring project, using the default configuration, or simply configuring it in the project's configuration file (for example, Properties or yml) as needed. The introduction of the component will not have any impact on its own project. Only when the microservice startup class uses the enable (Enable) annotation to enable the automatic configuration (AutoConfigure) support of this message transaction component will the configuration and registration of related services be performed.
  • the component development process may include the following steps:
  • Kafka (kafka) message producer Service class for transaction message encapsulation and delivery. At the same time, it can dynamically manage the registration of the Service to the Spring container according to whether the business microservice introduces kafka dependencies, and can support it according to the kafka version. Transaction and whether to open the transaction to decide whether to add its message delivery operation to the transaction;
  • the use of components in the project may include the following steps:
  • the user creates a business microservice project and adds components
  • the components of the disclosed embodiment can realize the transaction support of MySQL, MongoDB and Kafka multi-type data sources, and can dynamically create a single data source transaction manager and a chained transaction manager according to the dependencies referenced by the project and the transaction opening state; transaction message Persistent table names or collections can be dynamically defined, making the configuration of microservices more flexible.
  • Each microservice can use the same database, and distinguish the persistent transaction messages of different microservices through different table names and collection names; it can be used through SPI
  • the mechanism defines the application listener to realize the Spring package scanning of microservices, and does not require the user to add the package scanning path of this component on the startup class; the component can dynamically create a Service according to the enablement of the user's Enable annotation and the attribute value, and will effectively Service is registered to the Spring container, and invalid redundant services will not be registered; previous versions of Kafka and MongoDB do not support transactions, and Kafka transactions need to be manually enabled through configuration or coding. Based on this component, users do not need to make repeated judgments.
  • the electronic device includes hardware structures and/or software modules corresponding to each function.
  • the present disclosure can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed by hardware or computer software drives hardware depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each particular application, but such implementation should not be considered beyond the scope of the present disclosure.
  • the embodiments of the present disclosure may divide the functional units of the server and the electronic device according to the above method examples.
  • each functional unit may be divided corresponding to each function, or two or more functions may be integrated into one processing unit.
  • the above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units. It should be noted that the division of the units in the embodiment of the present disclosure is schematic, and is only a logical function division, and there may be another division manner in actual implementation.
  • FIG. 6 is a schematic structural diagram of a transaction processing device provided by an embodiment of the present disclosure.
  • the transaction processing device 600 is applied to the server. 602 and transaction processing unit 603, wherein:
  • the first creation unit 601 is configured to create a first microservice
  • the second creating unit 602 is configured to correspond to at least two transactions in the first microservice, the at least two transactions include a first transaction and a second transaction, and the first data source and the first transaction correspond to the first transaction If the second data source corresponding to the above second transaction is different, create a chained transaction manager;
  • the transaction processing unit 603 is configured to process the transaction corresponding to the first data source and the transaction corresponding to the second data source through the chained transaction manager.
  • the second creating unit 602 is further configured to create a single data source transaction manager when the first microservice corresponds to at least one transaction and the at least one transaction corresponds to the same target data source;
  • the transaction processing unit 603 is further configured to process the at least one transaction through the single data source transaction manager.
  • the second creating unit 602 is configured to configure a default transaction manager through annotations when the target data source is a default data source, and the default transaction manager implements the default data source
  • the transaction support of the single data source transaction manager includes the default transaction manager.
  • the second creation unit 602 is configured to create a transaction manager, and set the attribute of the transaction manager as a chained transaction manager through annotations.
  • the transaction processing apparatus 600 may further include a receiving unit 604 and a determining unit 605 .
  • the receiving unit 604 is configured to receive a service request initiated by a client
  • the determining unit 605 is configured to determine at least one microservice involved in the service request, where the at least one microservice includes the first microservice;
  • the first creating unit 601 is configured to create a first microservice after the determining unit 605 determines at least one microservice involved in the service request.
  • the at least one microservice further includes a second microservice
  • the transaction processing apparatus 600 may further include a delivery unit 606 , a judging unit 609 and a message processing unit 610 .
  • the first creating unit 601 is further configured to create the second microservice after the determining unit 605 determines at least one microservice involved in the service request, and create a first message table or a first message set;
  • the delivery unit 606 is configured to deliver the first message related to the service request to a first message queue, the second microservice is configured to obtain the first message from the first message queue; and;
  • the judging unit 609 is configured to judge whether there is a message with the same identifier as the first message in the first message table or first message set according to the identifier of the first message;
  • the message processing unit 610 is configured to process the first message through the second microservice when the determination result of the determination unit 609 is negative.
  • the transaction processing device 600 may also include a notification unit 607;
  • the notification unit 607 is configured to use best effort through the first message queue when the first message queue does not receive the message processing success confirmation message for the first message returned by the second microservice
  • the notification policy notifies the second microservice.
  • the transaction processing apparatus 600 may further include a persistence unit 608 .
  • the persisting unit 608 is configured to persist the first message in the first message table or first message set after the first message is successfully processed.
  • the message processing unit 610 is further configured to discard the first message when the judging result of the judging unit 609 is yes.
  • the transaction processing device 600 may also include a first definition unit
  • the definition unit is configured to define the table name of the first message table or the set name of the first message set through an expression language after the first creation unit 601 creates the first message table or the first message set .
  • the transaction processing apparatus 600 may also include a second definition unit
  • the second definition unit is configured to define an application listener through a service discovery mechanism SPI, and the application listener is used to configure a packet scanning path of the first microservice.
  • the first creating unit 601 is configured to implement dynamic configuration and registration of the first microservice through an automatic configuration mechanism.
  • the receiving unit 604 in the embodiment of the present disclosure may be the input and output device of the server, the first creation unit 601, the second creation unit 602, the transaction processing unit 603, the determination unit 605, the delivery unit 606, the notification unit 607, the persistent The unit 608, the judging unit 609, the message processing unit 610, the first defining unit and the second defining unit may be processors of the server.
  • the transaction corresponding to the first data source and the transaction corresponding to the second data source can be processed through the chained transaction manager.
  • the first transaction and the second transaction execute successfully or fail at the same time, so that the data consistency of the first transaction and the second transaction corresponding to the first microservice can be guaranteed.
  • FIG. 7 is a schematic structural diagram of a server provided by an embodiment of the present disclosure.
  • the server 700 includes a processor 701 and a memory 702. connect.
  • the communication bus 703 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (Extended Industry Standard Architecture, EISA) bus or the like.
  • the communication bus 703 can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is used in FIG. 7 , but it does not mean that there is only one bus or one type of bus.
  • the memory 702 is used to store computer programs, the computer programs include program instructions, and the processor 701 is configured to call the program instructions, and the above programs are included to execute the methods in FIGS. 2 to 5 .
  • Processor 701 may be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (Application-Specific Integrated Circuit, ASIC), or one or more integrated circuits used to control the execution of the programs of the above solutions.
  • CPU central processing unit
  • ASIC Application-Specific Integrated Circuit
  • the memory 702 may be a read-only memory (Read-Only Memory, ROM) or other types of static storage devices that can store static information and instructions, and a random access memory (Random Access Memory, RAM) or other types that can store information and instructions It can also be an electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), a read-only disc (Compact Disc Read-Only Memory, CD-ROM) or other optical disc storage, optical disc storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or can be used to carry or store desired program code in the form of instructions or data structures and can be programmed by a computer Any other medium accessed, but not limited to.
  • the memory can exist independently and be connected to the processor through the bus. Memory can also be integrated with the processor.
  • the server 700 may further include an input and output device 704, and the input and output device 704 may include an input and output device such as a radio frequency circuit and an antenna.
  • the input and output device 704 may include an input and output device such as a radio frequency circuit and an antenna.
  • the transaction corresponding to the first data source and the transaction corresponding to the second data source can be processed through the chained transaction manager.
  • the first transaction and the second transaction execute successfully or fail at the same time, so that the data consistency of the first transaction and the second transaction corresponding to the first microservice can be guaranteed.
  • An embodiment of the present disclosure also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program for electronic data exchange, and the computer program enables the computer to perform any transaction as described in the above-mentioned method embodiments Some or all steps of a processing method.
  • Embodiments of the present disclosure further provide a computer program, which implements some or all steps of any transaction processing method described in the foregoing method embodiments in the embodiments of the present disclosure when the computer program is executed by a processor.
  • the disclosed device can be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of the units is only a logical function division. In actual implementation, there may be other division methods.
  • multiple units or components can be combined or can be Integrate into another system, or some features may be ignored, or not implemented.
  • the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical or other forms.
  • the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in each embodiment of the disclosure may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units can be implemented not only in the form of hardware, but also in the form of software program modules.
  • the integrated units may be stored in a computer-readable memory if implemented in the form of a software program module and sold or used as an independent product. Based on such an understanding, the essence of the technical solution of the present disclosure or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory.
  • a computer device which may be a personal computer, server or network device, etc.
  • the aforementioned memory includes various media capable of storing program codes such as U disk, ROM, RAM, mobile hard disk, magnetic disk or optical disk.

Landscapes

  • Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Development Economics (AREA)
  • Software Systems (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • General Engineering & Computer Science (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

A transaction processing method and a related product. The transaction processing method comprises: creating a first microservice by a server (201); creating a chained transaction manager when the first microservice corresponds to at least two transactions, when the at least two transactions comprise a first transaction and a second transaction, and when a first data source corresponding to the first transaction is different from a second data source corresponding to the second transaction (202); and processing, by the chained transaction manager, the transaction corresponding to the first data source and the transaction corresponding to the second data source (203). The method can ensure data consistency of the transactions involved in the microservice.

Description

事务处理方法及相关产品Transaction processing methods and related products
相关申请的交叉引用Cross References to Related Applications
本公开基于申请号为202110726140.7、申请日为2021年06月29日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此以引入方式并入本公开。This disclosure is based on a Chinese patent application with application number 202110726140.7 and a filing date of June 29, 2021, and claims the priority of this Chinese patent application. The entire content of this Chinese patent application is hereby incorporated into this disclosure by reference.
技术领域technical field
本公开涉及互联网技术领域,具体涉及一种事务处理方法及相关产品。The present disclosure relates to the technical field of the Internet, in particular to a transaction processing method and related products.
背景技术Background technique
在微服务化开发的电商平台以及其他微服务化开发的产品中,业务拆分使得各个微服务独立部署和运行,同一个微服务涉及的事务可能对应不同的数据源的数据更新操作。如何保证微服务涉及的事务的数据一致性是亟需解决的问题。In microservice-based e-commerce platforms and other microservice-based products, business splitting allows each microservice to be deployed and run independently, and the transactions involved in the same microservice may correspond to data update operations from different data sources. How to ensure the data consistency of transactions involved in microservices is an urgent problem to be solved.
发明内容Contents of the invention
本公开实施例提供一种事务处理方法及相关产品。Embodiments of the present disclosure provide a transaction processing method and related products.
本公开实施例的第一方面提供了一种事务处理方法,包括:创建第一微服务;在所述第一微服务对应至少两个事务、所述至少两个事务包括第一事务和第二事务、并且所述第一事务对应的第一数据源和所述第二事务对应的第二数据源不同的情况下,则创建链式事务管理器;通过所述链式事务管理器对所述第一数据源对应的事务和所述第二数据源对应的事务进行处理。The first aspect of an embodiment of the present disclosure provides a transaction processing method, including: creating a first microservice; at least two transactions corresponding to the first microservice, the at least two transactions including the first transaction and the second transaction, and the first data source corresponding to the first transaction is different from the second data source corresponding to the second transaction, then create a chained transaction manager; through the chained transaction manager, the The transaction corresponding to the first data source is processed with the transaction corresponding to the second data source.
在本公开的一些可选实施例中,所述方法还包括:在所述第一微服务对应至少一个事务、并且所述至少一个事务对应相同的目标数据源的情况下,则创建单数据源事务管理器;通过所述单数据源事务管理器对所述至少一个事务进行处理。In some optional embodiments of the present disclosure, the method further includes: if the first microservice corresponds to at least one transaction and the at least one transaction corresponds to the same target data source, creating a single data source A transaction manager; the at least one transaction is processed by the single data source transaction manager.
在本公开的一些可选实施例中,所述创建单数据源事务管理器,包括:在所述目标数据源是默认数据源的情况下,通过注解的方式配置默认事务管理器,所述默认事务管理器实现所述默认数据源的事务支持,所述单数据源事务管理器包括所述默认事务管理器。In some optional embodiments of the present disclosure, the creating a single data source transaction manager includes: when the target data source is a default data source, configuring the default transaction manager through annotations, the default A transaction manager implements transaction support of the default data source, and the single data source transaction manager includes the default transaction manager.
在本公开的一些可选实施例中,所述创建链式事务管理器,包括:创建事务管理器,通过注解的方式设置所述事务管理器的属性为链式事务管理器。In some optional embodiments of the present disclosure, the creating a chained transaction manager includes: creating a transaction manager, and setting an attribute of the transaction manager as a chained transaction manager through annotations.
在本公开的一些可选实施例中,所述创建第一微服务之前,所述方法还包括:接收 用户端发起的业务请求;确定所述业务请求涉及的至少一个微服务,所述至少一个微服务包括所述第一微服务。In some optional embodiments of the present disclosure, before creating the first microservice, the method further includes: receiving a service request initiated by the client; determining at least one microservice involved in the service request, and the at least one The microservice includes the first microservice.
在本公开的一些可选实施例中,所述至少一个微服务还包括第二微服务,所述方法还包括:创建所述第二微服务,创建第一消息表或第一消息集合;将与所述业务请求相关的第一消息投递到第一消息队列,所述第二微服务用于从所述第一消息队列获得所述第一消息;根据所述第一消息的标识符判断所述第一消息表或第一消息集合中是否存在与所述第一消息的标识符相同的消息;在所述第一消息表或第一消息集合中不存在与所述第一消息的标识符相同的消息的情况下,通过所述第二微服务处理所述第一消息;In some optional embodiments of the present disclosure, the at least one microservice further includes a second microservice, and the method further includes: creating the second microservice, creating a first message table or a first message set; A first message related to the service request is delivered to a first message queue, and the second microservice is used to obtain the first message from the first message queue; Whether there is a message identical to the identifier of the first message in the first message table or first message set; there is no identifier of the first message in the first message table or first message set In the case of the same message, process the first message through the second microservice;
在本公开的一些可选实施例中,所述处理所述第一消息之后,所述方法还包括:在所述第一消息队列没有接收到所述第二微服务返回的针对所述第一消息的消息处理成功确认消息的情况下,则通过所述第一消息队列采用最大努力通知策略通知所述第二微服务。In some optional embodiments of the present disclosure, after the processing of the first message, the method further includes: when the first message queue does not receive the message for the first message returned by the second microservice If the message processing of the message succeeds in confirming the message, the second microservice is notified through the first message queue using a best effort notification policy.
在本公开的一些可选实施例中,所述处理所述第一消息之后,所述方法还包括:在所述第一消息处理成功后,将所述第一消息持久化到所述第一消息表或第一消息集合中。In some optional embodiments of the present disclosure, after processing the first message, the method further includes: after the first message is successfully processed, persisting the first message to the first in the message table or the first message set.
在本公开的一些可选实施例中,所述方法还包括:在所述第一消息表或第一消息集合中存在与所述第一消息的标识符相同的消息的情况下,丢弃所述第一消息。In some optional embodiments of the present disclosure, the method further includes: if there is a message with the same identifier as the first message in the first message table or first message set, discarding the first news.
在本公开的一些可选实施例中,所述创建第一消息表或第一消息集合之后,所述方法还包括:通过表达式语言定义所述第一消息表的表名或所述第一消息集合的集合名。In some optional embodiments of the present disclosure, after creating the first message table or the first message set, the method further includes: defining the table name of the first message table or the first The collection name of the message collection.
在本公开的一些可选实施例中,所述方法还包括:通过服务发现机制定义应用监听器,所述应用监听器用于配置所述第一微服务的包扫描的路径。In some optional embodiments of the present disclosure, the method further includes: defining an application listener through a service discovery mechanism, and the application listener is used to configure a packet scanning path of the first microservice.
在本公开的一些可选实施例中,所述创建第一微服务,包括:通过自动配置机制实现所述第一微服务的动态配置和注册。In some optional embodiments of the present disclosure, the creating the first microservice includes: implementing dynamic configuration and registration of the first microservice through an automatic configuration mechanism.
在本公开的一些可选实施例中,所述方法基于自动配置的可插拔组件实现。In some optional embodiments of the present disclosure, the method is implemented based on automatically configured pluggable components.
本公开实施例的第二方面提供了一种事务处理装置,包括:A second aspect of an embodiment of the present disclosure provides a transaction processing device, including:
第一创建单元,配置为创建第一微服务;The first creation unit is configured to create the first microservice;
第二创建单元,配置为在所述第一微服务对应至少两个事务、所述至少两个事务包括第一事务和第二事务、并且所述第一事务对应的第一数据源和所述第二事务对应的第二数据源不同的情况下,创建链式事务管理器;The second creation unit is configured to correspond to at least two transactions in the first microservice, the at least two transactions include a first transaction and a second transaction, and the first data source corresponding to the first transaction and the If the second data source corresponding to the second transaction is different, create a chained transaction manager;
事务处理单元,配置为通过所述链式事务管理器对所述第一数据源对应的事务和所述第二数据源对应的事务进行处理。The transaction processing unit is configured to process the transaction corresponding to the first data source and the transaction corresponding to the second data source through the chain transaction manager.
本公开实施例的第三方面提供了一种服务器,包括处理器和存储器,所述存储器用于存储计算机程序,所述计算机程序包括程序指令,所述处理器被配置用于调用所述程序指令,执行如本公开实施例第一方面中的步骤指令。A third aspect of the embodiments of the present disclosure provides a server, including a processor and a memory, the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to invoke the program instructions , execute the step instruction in the first aspect of the embodiment of the present disclosure.
本公开实施例的第四方面提供了一种计算机可读存储介质,其中,上述计算机可读存储介质用于存储计算机程序,上述计算机程序使得计算机执行如本公开实施例第一方 面中所描述的部分或全部步骤。A fourth aspect of the embodiments of the present disclosure provides a computer-readable storage medium, wherein the above-mentioned computer-readable storage medium is used to store a computer program, and the above-mentioned computer program enables the computer to execute the method described in the first aspect of the embodiments of the present disclosure. some or all of the steps.
本公开实施例的第五方面提供了一种计算机程序产品,其中,上述计算机程序产品包括计算机程序,上述计算机程序被计算机执行时使得上述计算机执行如本公开实施例第一方面中所描述的部分或全部步骤。该计算机程序产品可以为一个软件安装包。A fifth aspect of the embodiments of the present disclosure provides a computer program product, wherein the computer program product includes a computer program, and when the computer program is executed by a computer, the computer executes the parts described in the first aspect of the embodiments of the present disclosure or all steps. The computer program product may be a software installation package.
本公开实施例的第六方面提供了一种计算机程序,所述计算机程序被处理器执行时实现本公开实施例上述第一方面中所描述的部分或全部步骤。A sixth aspect of the embodiments of the present disclosure provides a computer program. When the computer program is executed by a processor, some or all of the steps described in the first aspect of the embodiments of the present disclosure are implemented.
本公开实施例中,服务端创建第一微服务;在所述第一微服务对应至少两个事务、所述至少两个事务包括第一事务和第二事务、并且所述第一事务对应的第一数据源和所述第二事务对应的第二数据源不同的情况下,则创建链式事务管理器;通过所述链式事务管理器对所述第一数据源对应的事务和所述第二数据源对应的事务进行处理。本公开实施例可以通过链式事务管理器对第一数据源对应的事务和第二数据源对应的事务进行处理,由于链式事务管理器可以实现多种数据源的事务支持,保证第一事务和第二事务同时执行成功或者同时失败,从而可以保证第一微服务对应的第一事务和第二事务的数据一致性。In the embodiment of the present disclosure, the server creates a first microservice; the first microservice corresponds to at least two transactions, the at least two transactions include a first transaction and a second transaction, and the first transaction corresponds to If the first data source and the second data source corresponding to the second transaction are different, then create a chained transaction manager; through the chained transaction manager, the transaction corresponding to the first data source and the The transaction corresponding to the second data source is processed. The embodiment of the present disclosure can process the transaction corresponding to the first data source and the transaction corresponding to the second data source through the chained transaction manager. Since the chained transaction manager can realize the transaction support of multiple data sources, the first transaction can be guaranteed Execute successfully or fail at the same time as the second transaction, so that the data consistency between the first transaction and the second transaction corresponding to the first microservice can be guaranteed.
附图说明Description of drawings
为了更清楚地说明本公开实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本公开的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only These are some embodiments of the present disclosure. For those skilled in the art, other drawings can also be obtained according to these drawings without creative work.
图1是本公开实施例提供的一种用户端和服务端的通信连接架构图;FIG. 1 is an architecture diagram of a communication connection between a client and a server provided by an embodiment of the present disclosure;
图2是本公开实施例提供的一种事务处理方法的流程示意图;FIG. 2 is a schematic flowchart of a transaction processing method provided by an embodiment of the present disclosure;
图3是本公开实施例提供的另一种事务处理方法的流程示意图;FIG. 3 is a schematic flowchart of another transaction processing method provided by an embodiment of the present disclosure;
图4是本公开实施例提供的另一种事务处理方法的流程示意图;FIG. 4 is a schematic flowchart of another transaction processing method provided by an embodiment of the present disclosure;
图5是本公开实施例提供的另一种事务处理方法的流程示意图;FIG. 5 is a schematic flowchart of another transaction processing method provided by an embodiment of the present disclosure;
图6是本公开实施例提供的一种事务处理装置的结构示意图;FIG. 6 is a schematic structural diagram of a transaction processing device provided by an embodiment of the present disclosure;
图7是本公开实施例提供的一种服务器的结构示意图。Fig. 7 is a schematic structural diagram of a server provided by an embodiment of the present disclosure.
具体实施方式detailed description
下面将结合本公开实施例中的附图,对本公开实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本公开一部分实施例,而不是全部的实施例。基于本公开中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本公开保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present disclosure with reference to the accompanying drawings in the embodiments of the present disclosure. Apparently, the described embodiments are only some of the embodiments of the present disclosure, not all of them. Based on the embodiments in the present disclosure, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present disclosure.
本公开的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别不同对象,而不是用于描述特定顺序。此外,术语“包括”和“具有”以及它们任何变 形,意图在于覆盖不排他的包含。例如包含了一系列步骤或单元的过程、方法、系统、产品或设备没有限定于已列出的步骤或单元,而是可选地还包括没有列出的步骤或单元,或可选地还包括对于这些过程、方法、产品或设备固有的其他步骤或单元。The terms "first", "second" and the like in the specification and claims of the present disclosure and the above drawings are used to distinguish different objects, rather than to describe a specific order. Furthermore, the terms "comprising" and "having", as well as any variations thereof, are intended to cover a non-exclusive inclusion. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally also includes unlisted steps or units, or optionally further includes For other steps or units inherent in these processes, methods, products or devices.
在本公开中提及“实施例”意味着,结合实施例描述的特定特征、结构或特性可以包含在本公开的至少一个实施例中。在说明书中的各个位置出现该短语并不一定均是指相同的实施例,也不是与其它实施例互斥的独立的或备选的实施例。本领域技术人员显式地和隐式地理解的是,本公开所描述的实施例可以与其它实施例相结合。Reference in the present disclosure to an "embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the present disclosure. The occurrences of this phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is understood explicitly and implicitly by those skilled in the art that the embodiments described in this disclosure can be combined with other embodiments.
本公开实施例所涉及到的电子设备可以包括具有运算能力和通信能力的设备,比如,手机、平板、个人电脑等。个人电脑也可以称为用户电脑,可以包括台式电脑、笔记本电脑等。为方便描述,上面提到的设备统称为电子设备。用户端是为用户提供本地服务的程序,用户端可以运行在电子设备上。The electronic devices involved in the embodiments of the present disclosure may include devices with computing capabilities and communication capabilities, such as mobile phones, tablets, and personal computers. A personal computer may also be called a user computer, and may include a desktop computer, a notebook computer, and the like. For convenience of description, the devices mentioned above are collectively referred to as electronic devices. The client is a program that provides local services for the user, and the client can run on the electronic device.
本公开实施例所涉及到的服务器可以是微服务器集群中的服务器,服务端可以运行在服务器上。服务端是为用户端服务的,服务的内容包括向用户端提供服务(比如,在线下单服务、在线支付服务、在线查询服务等),保存用户端数据等。The server involved in the embodiments of the present disclosure may be a server in a micro-server cluster, and the server may run on the server. The server is for the client, and the content of the service includes providing services to the client (for example, online order service, online payment service, online query service, etc.), saving client data, and so on.
请参阅图1,图1是本公开实施例提供的一种用户端和服务端的通信连接架构图。如图1所示,服务端100可以与至少一个用户端101进行通信连接。用户端可以直接与服务端建立通信连接,也可以通过其他设备与服务端建立通信连接。服务端可以提供多种类型的服务,用户端可以向服务端发起业务请求,业务请求可以包括下单请求、支付请求、查询请求等。服务端创建第一微服务;若第一微服务对应至少两个事务,至少两个事务包括第一事务和第二事务,并且第一事务对应的第一数据源和第二事务对应的第二数据源不同,则创建链式事务管理器(chain transaction manager);通过链式事务管理器对第一数据源对应的事务和第二数据源对应的事务进行处理。本公开实施例可以通过链式事务管理器对第一数据源对应的事务和第二数据源对应的事务进行处理,由于链式事务管理器可以实现多种数据源的事务支持,保证第一事务和第二事务同时执行成功或者同时失败,从而可以保证第一微服务对应的第一事务和第二事务的数据一致性,提高一个微服务涉及的所有事务的数据一致性。Please refer to FIG. 1 . FIG. 1 is a structural diagram of a communication connection between a client and a server provided by an embodiment of the present disclosure. As shown in FIG. 1 , the server 100 can communicate with at least one client 101 . The client can establish a communication connection with the server directly, or establish a communication connection with the server through other devices. The server can provide various types of services, and the client can initiate a service request to the server, and the service request can include an order request, payment request, query request, etc. The server creates the first microservice; if the first microservice corresponds to at least two transactions, the at least two transactions include the first transaction and the second transaction, and the first data source corresponding to the first transaction and the second transaction corresponding to the second transaction If the data sources are different, a chain transaction manager is created; the transaction corresponding to the first data source and the transaction corresponding to the second data source are processed through the chain transaction manager. The embodiment of the present disclosure can process the transaction corresponding to the first data source and the transaction corresponding to the second data source through the chained transaction manager. Since the chained transaction manager can realize the transaction support of multiple data sources, the first transaction can be guaranteed Execute successfully or fail at the same time as the second transaction, so that the data consistency between the first transaction and the second transaction corresponding to the first microservice can be guaranteed, and the data consistency of all transactions involved in a microservice can be improved.
服务端可以提供很多个微服务,服务端可以响应用户端发起的业务请求创建微服务。用户端发起的一次业务请求可能涉及多个微服务的数据聚合或者数据更新。比如,用户在手机上发起一个商品购买请求,数据更新可以包括:商品库存数据的更新、购物车的商品信息的更新、订单数据的更新等;数据聚合可以包括:用户在商品浏览界面同时显示库存信息、商品信息、商品优惠信息等数据的聚合。The server can provide many microservices, and the server can create microservices in response to business requests initiated by the client. A business request initiated by a client may involve data aggregation or data update of multiple microservices. For example, when a user initiates a product purchase request on a mobile phone, the data update may include: update of product inventory data, update of product information in the shopping cart, update of order data, etc.; data aggregation may include: the user simultaneously displays the inventory on the product browsing interface Aggregation of information, product information, product discount information and other data.
微服务,是一种软件开发技术,是面向服务的架构(Service-Oriented Architecture,SOA)的一种变体,将应用程序构造为一组松散耦合的服务。一个微服务可以实现某一个功能。Microservice, a software development technique, is a variant of Service-Oriented Architecture (SOA), which constructs an application as a set of loosely coupled services. A microservice can implement a certain function.
事务,是指访问并可能更新数据库中各种数据项的一个程序执行单元。一个微服务可能对应一个事务,也可能对应至少两个事务。Transaction refers to a program execution unit that accesses and possibly updates various data items in the database. A microservice may correspond to one transaction, or at least two transactions.
在一个示例中,第一微服务可以是订单服务,第一微服务对应至少两个事务可以包括:商品订单信息保存事务、库存消息队列投递事务和购物车消息队列投递事务。比如,用户在手机上发起一个商品购买请求后,可以创建订单服务,订单服务创建订单,订单服务将订单数据(比如,订单编号)存放在第一数据源(比如,MySQL数据库),即为订单服务对应的第一事务,可以将订单的明细数据(比如,下单时间、下单商品的数量、购买商品明细、购买金额等)存放在第二数据源(比如,MongoDB数据库),即为订单服务对应的第二事务,订单服务还可以投递一个消息给库存服务的消息队列(比如,卡夫卡消息队列),让库存减去购买的商品数量(比如,将库存数据减1),投递另一个消息给购物车服务的消息队列(比如,卡夫卡消息队列),让购物车服务去删除该商品。数据源可以包括数据库应用程序所使用的数据库或者数据库服务器。In an example, the first microservice may be an order service, and at least two transactions corresponding to the first microservice may include: a commodity order information saving transaction, an inventory message queue delivery transaction, and a shopping cart message queue delivery transaction. For example, after a user initiates a product purchase request on a mobile phone, an order service can be created. The order service creates an order, and the order service stores the order data (for example, order number) in the first data source (for example, MySQL database), which is the order For the first transaction corresponding to the service, you can store the detailed data of the order (for example, the time of placing the order, the quantity of the ordered goods, the details of the purchased goods, the purchase amount, etc.) in the second data source (for example, the MongoDB database), which is the order For the second transaction corresponding to the service, the order service can also deliver a message to the message queue of the inventory service (for example, Kafka message queue), so that the inventory minus the quantity of purchased goods (for example, subtract 1 from the inventory data), and deliver another A message to the cart service's message queue (for example, a Kafka message queue) to ask the cart service to delete the item. Data sources can include databases or database servers used by database applications.
同一个微服务涉及的事务可能对应不同的数据源,如果对于不同数据源的事务是分别实现的,由于同一个微服务涉及的多个事务是分开处理的,难以保证同一个微服务涉及的事务的数据一致性。The transactions involved in the same microservice may correspond to different data sources. If the transactions of different data sources are implemented separately, since multiple transactions involved in the same microservice are processed separately, it is difficult to ensure that the transactions involved in the same microservice data consistency.
第一事务对应的第一数据源和第二事务对应的第二数据源不同,可以是第一数据源的类型与第二数据源的类型不同。第一事务对应的第一数据源指的是第一事务需要访问的第一数据源,第二事务对应的第二数据源指的是第二事务需要访问的第二数据源。The first data source corresponding to the first transaction is different from the second data source corresponding to the second transaction, and the type of the first data source may be different from the type of the second data source. The first data source corresponding to the first transaction refers to the first data source that the first transaction needs to access, and the second data source corresponding to the second transaction refers to the second data source that the second transaction needs to access.
链式事务管理器,是事物管理器的一种,可以定义一个事务链,多个事务在链式事务管理器中依次提交。比如,第一微服务对应三个事务:商品订单信息保存事务、库存消息队列投递事务和购物车消息队列投递事务,可以依次提交商品订单信息保存事务、库存消息队列投递事务和购物车消息队列投递事务。链式事务管理器可以支持多种类型数据源的事务处理,保证第一微服务对应的三个事务同时执行成功或者同时失败,从而可以保证第一微服务对应的三个事务的数据一致性。Chained transaction manager is a kind of transaction manager, which can define a transaction chain, and multiple transactions are submitted sequentially in the chained transaction manager. For example, the first microservice corresponds to three transactions: commodity order information storage transaction, inventory message queue delivery transaction, and shopping cart message queue delivery transaction, and the commodity order information storage transaction, inventory message queue delivery transaction, and shopping cart message queue delivery transaction can be submitted in sequence affairs. The chained transaction manager can support transaction processing of multiple types of data sources, and ensure that the three transactions corresponding to the first microservice are executed successfully or fail at the same time, thereby ensuring the data consistency of the three transactions corresponding to the first microservice.
本公开实施例的数据一致性可以包括数据强一致性或数据弱一致性。数据弱一致性,也可以称为数据最终一致性。对于电商平台而言,保证数据的最终一致性即可。比如,用户在电商平台下单了一件商品,订单服务创建了订单后,如果订单服务执行成功,则库存服务将库存减1,购物车服务删除该用户的购物车内该商品,则这订单执行成功、库存减1、删除该用户的购物车内该商品这三者是一致的,则认为数据一致性,最终一致性并不要求这三者必须同时完成,只需要最终是一致的即可。而数据强一致性则要求这三者必须同时完成。如果订单服务执行成功,库存没有发生变化,或者没有删除该用户的购物车内该商品,则认为数据不一致,不满足数据一致性。The data consistency in the embodiments of the present disclosure may include strong data consistency or weak data consistency. Data weak consistency can also be called data final consistency. For e-commerce platforms, it is enough to ensure the final consistency of data. For example, a user places an order for a product on an e-commerce platform. After the order service creates an order, if the order service is executed successfully, the inventory service will decrease the inventory by 1, and the shopping cart service will delete the product in the user's shopping cart. If the order is successfully executed, the inventory is reduced by 1, and the product in the user's shopping cart is deleted, the three are consistent, and the data consistency is considered. The final consistency does not require that the three must be completed at the same time, only that they are consistent in the end. Can. Strong data consistency requires that all three must be completed at the same time. If the order service is executed successfully and the inventory has not changed, or the product in the user's shopping cart has not been deleted, the data is considered inconsistent and data consistency is not satisfied.
请参阅图2,图2是本公开实施例提供的一种事务处理方法的流程示意图。该方法应用于图1所示的服务端,如图2所示,该事务处理方法可以包括如下步骤。Please refer to FIG. 2 . FIG. 2 is a schematic flowchart of a transaction processing method provided by an embodiment of the present disclosure. The method is applied to the server shown in FIG. 1, and as shown in FIG. 2, the transaction processing method may include the following steps.
201,服务端创建第一微服务。201. The server creates a first microservice.
本公开实施例中,服务端可以在用户端的请求下创建第一微服务,也可以自己创建微服务。比如,当用户端向服务端发起下单请求时,服务端可以创建第一微服务,即订单服务;当用户端向服务端发起支付请求时,服务端可以创建第一微服务,即支付服务。 又比如,服务端需要查询数据库中的数据时,服务端可以主动创建第一微服务,即查询服务。In the embodiment of the present disclosure, the server can create the first microservice at the request of the user, or can create the microservice by itself. For example, when the client initiates an order request to the server, the server can create the first microservice, namely the order service; when the client initiates a payment request to the server, the server can create the first microservice, namely the payment service . For another example, when the server needs to query data in the database, the server can actively create the first microservice, that is, the query service.
202,在第一微服务对应至少两个事务、至少两个事务包括第一事务和第二事务、并且第一事务对应的第一数据源和第二事务对应的第二数据源不同的情况下,服务端创建链式事务管理器。202. When the first microservice corresponds to at least two transactions, the at least two transactions include the first transaction and the second transaction, and the first data source corresponding to the first transaction is different from the second data source corresponding to the second transaction , the server creates a chained transaction manager.
本公开实施例中,一个微服务可以对应至少一个事务。当一个微服务对应至少两个事务时,该至少两个事务对应的数据源可以相同,也可以不同。当该至少两个事务对应的数据源不同时,可以创建链式事务管理器,通过链式事务管理器对该至少两个事务进行处理。In the embodiment of the present disclosure, a microservice may correspond to at least one transaction. When one microservice corresponds to at least two transactions, the data sources corresponding to the at least two transactions may be the same or different. When the data sources corresponding to the at least two transactions are different, a chained transaction manager may be created, and the at least two transactions are processed through the chained transaction manager.
举例来说,若第一微服务包括订单服务,则该订单服务可以对应订单信息保存事务、库存消息队列投递事务和购物车消息队列投递事务。订单信息保存事务对应的数据源可以是MySQL数据库,库存消息队列投递事务对应的数据源可以是卡夫卡(kafka)消息队列,购物车消息队列投递事务对应的数据源可以是kafka。For example, if the first microservice includes an order service, the order service may correspond to an order information saving transaction, an inventory message queue delivery transaction, and a shopping cart message queue delivery transaction. The data source corresponding to the order information saving transaction can be a MySQL database, the data source corresponding to the inventory message queue delivery transaction can be a Kafka (kafka) message queue, and the data source corresponding to the shopping cart message queue delivery transaction can be kafka.
事务(Transaction),一般是指要做的或所做的事情。在计算机术语中是指访问并可能更新数据库中各种数据项的一个程序执行单元(unit)。事务通常由高级数据库操纵语言或编程语言(如SQL,C++或Java)书写的用户程序的执行所引起,并用形如begin transaction和end transaction语句(或函数调用)来界定。事务由事务开始(begin transaction)和事务结束(end transaction)之间执行的全体操作组成。Transaction (Transaction) generally refers to something to be done or done. In computer terms, it refers to a program execution unit (unit) that accesses and possibly updates various data items in a database. Transactions are usually caused by the execution of user programs written in advanced database manipulation languages or programming languages (such as SQL, C++ or Java), and are defined by statements (or function calls) such as begin transaction and end transaction. A transaction consists of all operations performed between the begin transaction and the end transaction.
服务端可以在第一微服务对应的至少两个事务中存在数据源不同的事务的情况下,创建链式事务管理器。链式事务管理器可以串联至少两个事务,把上述至少两个事务串起来后,链式事务管理器可以统一处理,上述至少两个事务要么同时失败,要么同时成功,从而可以保证第一微服务对应的上述至少两个事务的数据一致性。The server may create a chained transaction manager when at least two transactions corresponding to the first microservice have transactions with different data sources. The chained transaction manager can connect at least two transactions in series. After connecting the above two transactions, the chained transaction manager can process them in a unified manner. The above at least two transactions either fail at the same time or succeed at the same time, thus ensuring that the first micro The data consistency of the above at least two transactions corresponding to the service.
在一些可选实施例中,步骤202中,服务端创建链式事务管理器,可以包括如下步骤:服务端创建事务管理器,通过注解的方式设置事务管理器的属性为链式事务管理器。In some optional embodiments, in step 202, the server creates a chained transaction manager, which may include the following steps: the server creates a transaction manager, and sets the property of the transaction manager as a chained transaction manager through annotations.
本公开实施例中,注解可以理解为代码里的特殊标记,这些标记可以在编译、类加载、运行时被读取,并执行相应的处理。通过注解,软件开发人员可以在不改变原有代码和逻辑的情况下在源代码中嵌入补充信息。通过注解的方式可以根据第一微服务对应至少两个事务涉及的所有的数据源来决定是否设置事务管理器的属性。若第一微服务对应至少两个事务涉及的所有的数据源包括至少两个不同的数据源,由于事务注解默认设置为默认事务管理器,默认事务管理器只能实现默认的一个数据源的事务支持,则需要重新设置事务管理器的属性为链式事务管理器,使得该链式事务管理器能够实现上述至少两个不同的数据源的事务支持。若第一微服务对应至少两个事务涉及的所有的数据源均为同一个数据源,由于事务注解默认设置为默认事务管理器,则无需重新设置事务管理器的属性。本公开实施例可以通过注解启用事务,并设置事务管理器类型。In the embodiments of the present disclosure, annotations can be understood as special tags in the code, and these tags can be read during compilation, class loading, and runtime, and corresponding processing is performed. Through annotations, software developers can embed supplementary information in source code without changing the original code and logic. By way of annotation, it may be determined whether to set the property of the transaction manager according to all the data sources involved in the first microservice corresponding to at least two transactions. If the first microservice corresponds to at least two transactions involving all data sources including at least two different data sources, since the transaction annotation is set to the default transaction manager by default, the default transaction manager can only implement transactions of one default data source If it is supported, it is necessary to reset the property of the transaction manager to be a chained transaction manager, so that the chained transaction manager can realize the above-mentioned transaction support of at least two different data sources. If all the data sources involved in at least two transactions of the first microservice are the same data source, since the transaction annotation is set as the default transaction manager by default, there is no need to reset the properties of the transaction manager. The embodiments of the present disclosure can enable transactions through annotations and set transaction manager types.
示例性的,在代码中,事务注解可以是@transactional注解。本公开实施例可以在需要事务管理的地方加@Transactional注解。@Transactional注解可以被应用于接口定义和 接口方法、类定义和类的public方法上。@Transactional注解可以加在service层。Exemplarily, in the code, the transaction annotation may be @transactional annotation. In the embodiment of the present disclosure, @Transactional annotation can be added at the place where transaction management is required. The @Transactional annotation can be applied to interface definitions and interface methods, class definitions, and public methods of classes. The @Transactional annotation can be added to the service layer.
203,服务端通过链式事务管理器对第一数据源对应的事务和第二数据源对应的事务进行处理。203. The server processes the transaction corresponding to the first data source and the transaction corresponding to the second data source through the chained transaction manager.
本公开实施例中,链式事务管理器可以依次对第一数据源对应的事务和第二数据源对应的事务进行处理。具体的,链式事务管理器可以依次对第一事务和第二事务进行处理。In the embodiment of the present disclosure, the chained transaction manager may sequentially process the transaction corresponding to the first data source and the transaction corresponding to the second data source. Specifically, the chained transaction manager may process the first transaction and the second transaction in sequence.
链式事务管理器可以实现多种数据源的事务支持,如果上述至少两个事务对应两个不同的数据源:第一数据源和第二数据源,则创建的链式事务管理器可以实现第一数据源和第二数据源的事务支持;如果上述至少两个事务对应三个不同的数据源:第一数据源、第二数据源和第三数据源,则创建的链式事务管理器可以实现第一数据源、第二数据源和第三数据源的事务支持,以此类推。The chained transaction manager can realize the transaction support of multiple data sources. If the above-mentioned at least two transactions correspond to two different data sources: the first data source and the second data source, the created chained transaction manager can realize the second The transaction support of a data source and a second data source; if the above-mentioned at least two transactions correspond to three different data sources: the first data source, the second data source and the third data source, then the created chain transaction manager can Implement transaction support for the first data source, the second data source, and the third data source, and so on.
本公开实施例可以通过链式事务管理器对第一数据源对应的事务和第二数据源对应的事务进行处理,由于链式事务管理器可以实现多种数据源的事务支持,保证第一事务和第二事务同时执行成功或者同时失败,从而可以保证第一微服务对应的第一事务和第二事务的数据一致性,保证有一个微服务涉及的所有事务的数据一致性。The embodiment of the present disclosure can process the transaction corresponding to the first data source and the transaction corresponding to the second data source through the chained transaction manager. Since the chained transaction manager can realize the transaction support of multiple data sources, the first transaction can be guaranteed Execute successfully or fail at the same time as the second transaction, so that the data consistency of the first transaction and the second transaction corresponding to the first microservice can be guaranteed, and the data consistency of all transactions involved in a microservice can be guaranteed.
请参阅图3,图3是本公开实施例提供的另一种事务处理方法的流程示意图。图3是在图2的基础上进一步优化得到的,如图3所示,该事务处理方法可以包括如下步骤。Please refer to FIG. 3 . FIG. 3 is a schematic flowchart of another transaction processing method provided by an embodiment of the present disclosure. Fig. 3 is further optimized on the basis of Fig. 2. As shown in Fig. 3, the transaction processing method may include the following steps.
301,服务端创建第一微服务。301. The server creates a first microservice.
302,在第一微服务对应至少两个事务、至少两个事务包括第一事务和第二事务、并且第一事务对应的第一数据源和第二事务对应的第二数据源不同的情况下,服务端创建链式事务管理器。302, when the first microservice corresponds to at least two transactions, the at least two transactions include the first transaction and the second transaction, and the first data source corresponding to the first transaction is different from the second data source corresponding to the second transaction , the server creates a chained transaction manager.
303,服务端通过链式事务管理器对第一数据源对应的事务和第二数据源对应的事务进行处理。303. The server processes the transaction corresponding to the first data source and the transaction corresponding to the second data source through the chained transaction manager.
其中,步骤301至303的具体实施可以参加图2所示的步骤201至203,此处不再赘述。Wherein, the specific implementation of steps 301 to 303 may refer to steps 201 to 203 shown in FIG. 2 , which will not be repeated here.
304,在第一微服务对应至少一个事务、并且至少一个事务对应相同的目标数据源的情况下,服务端创建单数据源事务管理器。304. In the case that the first microservice corresponds to at least one transaction, and at least one transaction corresponds to the same target data source, the server creates a single data source transaction manager.
单数据源事务管理器,可以实现一个数据源的事务支持。如果至少一个事务对应相同的目标数据源是默认数据源,则服务端通过注解的方式配置默认事务管理器,该默认事务管理器可以实现默认数据源的事务支持。如果至少一个事务对应相同的目标数据源不是默认数据源,则服务端通过事务注解设置事务管理器的属性为支持目标数据源的目标事务管理器,该目标事务管理器可以实现目标数据源的事务支持。A single data source transaction manager can implement transaction support for one data source. If at least one transaction corresponds to the same target data source as the default data source, the server configures the default transaction manager through annotations, and the default transaction manager can implement the transaction support of the default data source. If at least one transaction corresponds to the same target data source that is not the default data source, the server sets the property of the transaction manager through the transaction annotation as the target transaction manager that supports the target data source, and the target transaction manager can implement the transaction of the target data source support.
可选的,步骤304中,服务端创建单数据源事务管理器,具体可以包括如下步骤:在所述目标数据源是默认数据源的情况下,通过注解的方式配置默认事务管理器,所述默认事务管理器实现所述默认数据源的事务支持,所述单数据源事务管理器包括所述默认事务管理器。本公开实施例可以在目标数据源关联的是默认数据源的情况下,通过注 解启用事务,并确定事务管理器类型为默认事务管理器。Optionally, in step 304, the server creates a single data source transaction manager, which may specifically include the following steps: when the target data source is the default data source, configure the default transaction manager by means of annotations, the A default transaction manager implements transaction support of the default data source, and the single data source transaction manager includes the default transaction manager. In the embodiment of the present disclosure, when the target data source is associated with the default data source, transactions can be enabled through annotations, and the transaction manager type can be determined as the default transaction manager.
本公开实施例中,如果目标数据源关联的是默认数据源,则无需重新设置事务管理器的属性,直接通过注解的方式配置默认事务管理器,该默认事务管理器可以实现默认数据源的事务支持,该默认事务管理器属于单数据源事务管理器。In the embodiment of the present disclosure, if the target data source is associated with the default data source, there is no need to reset the properties of the transaction manager, and the default transaction manager can be configured directly through annotations, and the default transaction manager can implement the transactions of the default data source Yes, the default transaction manager is a single data source transaction manager.
305,服务端通过单数据源事务管理器对至少一个事务进行处理。305. The server processes at least one transaction through the single data source transaction manager.
本公开实施例中,单数据源事务管理器可以对同一个数据源的多个事务同时进行处理,多个事务可以同时进行,与链式事务管理器的事务串行处理相比,单数据源事务管理器的事务处理效率更高。本公开实施例的事务可以是数据更新的事务。In the embodiment of the present disclosure, the single data source transaction manager can process multiple transactions of the same data source at the same time, and multiple transactions can be carried out at the same time. Compared with the transaction serial processing of the chained transaction manager, the single data source The transaction manager is more efficient in transaction processing. The transaction in the embodiments of the present disclosure may be a data update transaction.
请参阅图4,图4是本公开实施例提供的另一种事务处理方法的流程示意图。图4是在图2的基础上进一步优化得到的,如图4所示,该事务处理方法可以包括如下步骤。Please refer to FIG. 4 . FIG. 4 is a schematic flowchart of another transaction processing method provided by an embodiment of the present disclosure. FIG. 4 is further optimized on the basis of FIG. 2 . As shown in FIG. 4 , the transaction processing method may include the following steps.
401,服务端接收用户端发起的业务请求。401. The server receives a service request initiated by the user.
本公开实施例中,业务请求可以包括下单请求、支付请求、查询请求等,本实施例中对业务请求的类型不做限定。In the embodiment of the present disclosure, the service request may include an order request, a payment request, a query request, etc., and the type of the service request is not limited in this embodiment.
402,服务端确定业务请求涉及的至少一个微服务,该至少一个微服务包括第一微服务。402. The server determines at least one microservice involved in the service request, where the at least one microservice includes the first microservice.
本公开实施例中,不同的业务请求涉及的微服务不同。比如,下单请求可能涉及订单服务、库存服务、购物车服务等,下单请求涉及的微服务较多;查询请求可能仅涉及查询服务,查询请求涉及的微服务较少。业务请求与微服务数量和微服务类型的对应关系可以预先存储在服务端,不同的业务请求可以对应不同数量的微服务和不同类型的微服务。In the embodiments of the present disclosure, different service requests involve different microservices. For example, an order request may involve order service, inventory service, shopping cart service, etc., and more microservices are involved in the order request; query requests may only involve query services, and fewer microservices are involved in query requests. The correspondence between business requests and the number and types of microservices can be pre-stored on the server side, and different business requests can correspond to different numbers of microservices and different types of microservices.
本公开实施例可以根据用户的发起的业务请求所涉及的微服务的数量和类型来决定创建哪些微服务以及创建的微服务的数量,既不会占用多余的微服务资源,也不会少创建微服务导致业务请求无法被处理,可以灵活的创建微服务,更好的实现用户端发起的业务请求。The embodiment of the present disclosure can decide which microservices to create and the number of microservices to create according to the number and type of microservices involved in the business request initiated by the user, neither occupying redundant microservice resources nor creating fewer microservices Microservices prevent business requests from being processed, and microservices can be created flexibly to better implement business requests initiated by clients.
403,服务端创建第一微服务。403. The server creates the first microservice.
404,在第一微服务对应至少两个事务、至少两个事务包括第一事务和第二事务、并且第一事务对应的第一数据源和第二事务对应的第二数据源不同的情况下,服务端创建链式事务管理器。404, when the first microservice corresponds to at least two transactions, the at least two transactions include the first transaction and the second transaction, and the first data source corresponding to the first transaction is different from the second data source corresponding to the second transaction , the server creates a chained transaction manager.
405,服务端通过链式事务管理器对第一数据源对应的事务和第二数据源对应的事务进行处理。405. The server processes the transaction corresponding to the first data source and the transaction corresponding to the second data source through the chained transaction manager.
其中,步骤403至405的具体实施可以参加图2所示的步骤201至203,此处不再赘述。Wherein, the specific implementation of steps 403 to 405 may refer to steps 201 to 203 shown in FIG. 2 , which will not be repeated here.
请参阅图5,图5是本公开实施例提供的另一种事务处理方法的流程示意图。图5是在图4的基础上进一步优化得到的,如图5所示,该事务处理方法可以包括如下步骤。Please refer to FIG. 5 . FIG. 5 is a schematic flowchart of another transaction processing method provided by an embodiment of the present disclosure. Fig. 5 is further optimized on the basis of Fig. 4. As shown in Fig. 5, the transaction processing method may include the following steps.
501,服务端接收用户端发起的业务请求。501. The server receives a service request initiated by the user.
502,服务端确定业务请求涉及的至少两个微服务,该至少两个微服务包括第一微 服务和第二微服务。502. The server determines at least two microservices involved in the service request, and the at least two microservices include a first microservice and a second microservice.
503,服务端创建第一微服务和第二微服务,创建第一消息表或第一消息集合。503. The server creates a first microservice and a second microservice, and creates a first message table or a first message set.
本公开实施例中,如果一个业务请求涉及至少两个微服务,可以同时创建该至少两个微服务,也可以分别创建该至少两个微服务。第一消息表或第一消息集合可以在第二微服务对应的数据源中创建,第二微服务可以对第一消息进行处理,处理成功后,可以将所述第一消息持久化到所述第一消息表中。在不同的数据库中可以定义不同的文件来存放消息。比如,在MySQL数据库可以创建消息表来存放消息,在MongoDB数据库可以创建消息集合来存放消息。In the embodiment of the present disclosure, if a service request involves at least two microservices, the at least two microservices may be created at the same time, or the at least two microservices may be created separately. The first message table or the first message set can be created in the data source corresponding to the second microservice, and the second microservice can process the first message. After the processing is successful, the first message can be persisted to the in the first message table. Different files can be defined in different databases to store messages. For example, a message table can be created in a MySQL database to store messages, and a message collection can be created in a MongoDB database to store messages.
可选的,步骤502中,服务端创建第一微服务,具体可以包括如下步骤:通过自动配置机制实现所述第一微服务的动态配置和注册。Optionally, in step 502, the server creates the first microservice, which may specifically include the following steps: implementing dynamic configuration and registration of the first microservice through an automatic configuration mechanism.
本公开实施例中,可以根据注解的启用情况和属性值来动态的创建微服务,将创建的有效的微服务注册到容器中,从而实现微服务的动态配置和注册。示例性的,在创建一个微服务的时候,可以通过预先设置的组件去读取资源文件的配置文件(比如,properties或者是yml的配置),如果配置文件中配置了该微服务的启动类使用Enable注解,该Enable注解启动自动配置,根据该Enable注解的属性值进行相关的微服务的配置和注册,实现微服务的创建。由于Enable注解的启用情况和属性值可以由开发人员进行设定,则可以根据项目需要动态的创建微服务。如果配置文件中配置了该微服务的启动类不使用Enable注解,则可以根据默认配置来创建微服务。本公开实施例的容器可以是Spring容器。In the embodiment of the present disclosure, microservices can be dynamically created according to the activation status and attribute values of annotations, and the created effective microservices can be registered in the container, so as to realize dynamic configuration and registration of microservices. Exemplarily, when creating a microservice, the configuration file of the resource file (for example, properties or yml configuration) can be read through the pre-set components. If the startup class of the microservice is configured in the configuration file, use Enable annotation, the Enable annotation starts automatic configuration, configures and registers related microservices according to the property value of the Enable annotation, and realizes the creation of microservices. Since the enabling status and attribute values of the Enable annotation can be set by developers, microservices can be dynamically created according to project needs. If the startup class of the microservice configured in the configuration file does not use the Enable annotation, the microservice can be created according to the default configuration. The container in this embodiment of the disclosure may be a Spring container.
504,服务端将与业务请求相关的第一消息投递到第一消息队列,第二微服务用于从第一消息队列获得第一消息。504. The server delivers the first message related to the service request to the first message queue, and the second microservice is used to obtain the first message from the first message queue.
本公开实施例中,消息队列,是在消息的传输过程中保存消息的容器。消息可以非常简单,比如只包含文本字符串,也可以更复杂,比如可能包含嵌入对象。可以为第一消息队列创建一个用于第二微服务(消费者)消费的主题(topic),第二微服务可以从第一消息队列拉取对应第二微服务topic的第一消息,第一消息队列也可以主动向第二微服务推送第一消息。同样的,也可以为第一消息队列创建另一个用于第三微服务(消费者)消费的主题。In the embodiments of the present disclosure, the message queue is a container for storing messages during message transmission. Messages can be as simple as containing only text strings, or more complex as possibly containing embedded objects. A topic (topic) for consumption by the second microservice (consumer) can be created for the first message queue. The second microservice can pull the first message corresponding to the second microservice topic from the first message queue. The first The message queue can also actively push the first message to the second microservice. Similarly, another topic for consumption by the third microservice (consumer) can also be created for the first message queue.
消息队列具有异步解耦功能,本公开实施例中使用消息队列进行消息传输,可以极大的提升接口的吞吐量,同时达到流量削峰的目的。The message queue has an asynchronous decoupling function. In the embodiment of the present disclosure, the message queue is used for message transmission, which can greatly improve the throughput of the interface, and at the same time achieve the purpose of traffic peak shaving.
异步:第一微服务的事务和第二微服务的事务不需要同步执行,通过消息队列的方式,第一微服务将第一消息投递到第一消息队列后,还可以将其他的消息投递到其他的消息队列,无需等待第二微服务对第一消息的处理结果,可以极大的提升接口的吞吐量。Asynchronous: The transaction of the first microservice and the transaction of the second microservice do not need to be executed synchronously. Through the message queue, after the first microservice delivers the first message to the first message queue, it can also deliver other messages to For other message queues, there is no need to wait for the second microservice to process the first message, which can greatly improve the throughput of the interface.
解耦:假设第一微服务和第二微服务分别是两个类。如果让第一微服务直接调用第二微服务的某个方法,那么第一微服务对于第二微服务就会产生依赖(也就是耦合)。将来如果第二微服务的代码发生变化,可能会影响到第一微服务。如果采用消息队列,第一微服务和第二微服务都依赖于消息队列,第一微服务和第二微服务之间不直接依 赖,耦合也就相应降低了。Decoupling: Assume that the first microservice and the second microservice are two classes respectively. If the first microservice directly calls a method of the second microservice, then the first microservice will have a dependency (that is, coupling) on the second microservice. If the code of the second microservice changes in the future, it may affect the first microservice. If a message queue is used, both the first microservice and the second microservice depend on the message queue, and there is no direct dependence between the first microservice and the second microservice, and the coupling is correspondingly reduced.
其中,与业务请求相关的第一消息可以是第一微服务生成的,服务端可以通过第一微服务生成第一消息。比如,若业务请求是下单请求,第一微服务是订单服务,第二微服务是库存服务,与业务请求相关的第一消息可以是订单服务生成的,该第一消息可以包含订单编号、商品明细(比如,可以商品数量、商品型号等)等。第二微服务获得第一消息后,可以根据第一消息包含的商品明细将该商品明细中的对应的商品型号的库存数量减去该商品明细中的商品数量。Wherein, the first message related to the service request may be generated by the first microservice, and the server may generate the first message through the first microservice. For example, if the business request is an order request, the first microservice is the order service, and the second microservice is the inventory service, the first message related to the business request can be generated by the order service, and the first message can include the order number, Commodity details (for example, the quantity of the commodity, the model of the commodity, etc.) and the like. After the second microservice obtains the first message, it may subtract the quantity of the commodity in the commodity detail from the stock quantity of the corresponding commodity model in the commodity detail according to the commodity detail included in the first message.
可选的,该至少两个微服务可以包括第一微服务、第二微服务和第三微服务。服务端可以通过第一微服务生成第三消息,将该第三消息投递到第二消息队列,第三微服务用于从第二消息队列获得第三消息。Optionally, the at least two microservices may include a first microservice, a second microservice and a third microservice. The server may generate a third message through the first microservice, and deliver the third message to the second message queue, and the third microservice is used to obtain the third message from the second message queue.
可以为第二消息队列创建一个用于第三微服务(消费者)消费的主题,第三微服务可以从第二消息队列拉取第三消息,第二消息队列也可以主动向第三微服务推送第三消息。A topic for consumption by the third microservice (consumer) can be created for the second message queue, the third microservice can pull the third message from the second message queue, and the second message queue can also actively send the third microservice Push the third message.
第三消息可以是第一微服务生成的,服务端可以通过第一微服务生成第三消息。比如,若业务请求是下单请求,第一微服务是订单服务,第二微服务是库存服务,第三微服务是购物车服务,该第三消息可以包含订单编号。第三微服务获得第三消息后,可以根据第三消息包含的订单编号将购物车中与该订单编号对应的商品从该购物车中去除。The third message may be generated by the first microservice, and the server may generate the third message through the first microservice. For example, if the business request is an order request, the first microservice is an order service, the second microservice is an inventory service, and the third microservice is a shopping cart service, the third message may include an order number. After the third microservice obtains the third message, it can remove the commodity corresponding to the order number from the shopping cart according to the order number included in the third message.
505,服务端根据第一消息的标识符判断第一消息表或第一消息集合中是否存在与第一消息的标识符相同的消息。505. The server determines whether there is a message with the same identifier as the first message in the first message table or the first message set according to the identifier of the first message.
506,在第一消息表或第一消息集合中不存在与第一消息的标识符相同的消息,服务端通过第二微服务处理第一消息。506. There is no message with the same identifier as the first message in the first message table or the first message set, and the server processes the first message through the second microservice.
可选的,在执行步骤506之后,还可以执行如下步骤:Optionally, after performing step 506, the following steps may also be performed:
507,在第一消息队列没有接收到第二微服务返回的针对第一消息的消息处理成功确认消息的情况下,服务端通过第一消息队列采用最大努力通知策略通知第二微服务。507. In the case that the first message queue does not receive the message processing success confirmation message for the first message returned by the second microservice, the server notifies the second microservice through the first message queue using a best effort notification policy.
本公开实施例中,第二微服务处理第一消息后,可以得到处理成功或者处理失败的处理结果。如果处理成功后,只要第二微服务不出现故障,第二微服务会向第一消息队列返回针对第一消息的消息处理成功确认消息。如果第二微服务出故障,比如服务挂掉或者网络故障,第二微服务则无法将处理结果发给第一消息队列,则服务端可以通过第一消息队列采用最大努力通知策略通知第二微服务,保证多个微服务对应的事务的数据最终一致性,从而保证多数据源事务的最终一致性。如果处理失败,第二微服务会向第一消息队列返回针对第一消息的消息处理失败消息,此时服务端也可以通过第一消息队列采用最大努力通知策略通知第二微服务,让第二微服务处理该第一消息,直到接收到第二微服务返回的针对第一消息的消息处理成功确认消息为止。In the embodiment of the present disclosure, after the second microservice processes the first message, it may obtain a processing result of processing success or processing failure. If the processing is successful, as long as the second microservice does not fail, the second microservice will return a message processing success confirmation message for the first message to the first message queue. If the second microservice fails, such as the service hangs up or the network fails, the second microservice cannot send the processing result to the first message queue, and the server can notify the second microservice through the first message queue using the best effort notification strategy. Service, to ensure the final consistency of data for transactions corresponding to multiple microservices, thereby ensuring the final consistency of multiple data source transactions. If the processing fails, the second microservice will return a message processing failure message for the first message to the first message queue. The microservice processes the first message until receiving a message processing success confirmation message for the first message returned by the second microservice.
最大努力通知策略,是尽最大的努力来通知的策略。比如,第一消息队列可以周期性的通知第二微服务,让第二微服务返回针对第一消息的处理结果,直到第一消息队列接收到第二微服务返回的针对第一消息的处理结果为止。又比如,第一消息队列可以采 用周期逐渐增大的通知策略通知第二微服务,让第二微服务返回针对第一消息的处理结果,直到第一消息队列接收到第二微服务返回的针对第一消息的处理结果为止。又比如,第二微服务在服务挂掉重启后或者网络恢复重启后,可以主动从第一消息队列拉取该第一消息进行处理,并将处理结果返回给第一消息队列。A best-effort notification policy is a policy that uses best efforts to notify. For example, the first message queue can periodically notify the second microservice to let the second microservice return the processing result for the first message until the first message queue receives the processing result for the first message returned by the second microservice until. For another example, the first message queue can notify the second microservice with a notification policy with a gradually increasing period, and let the second microservice return the processing result for the first message until the first message queue receives the response to the second microservice. until the processing result of the first message. For another example, after the service hangs and restarts or the network resumes and restarts, the second microservice can actively pull the first message from the first message queue for processing, and return the processing result to the first message queue.
可选的,在第一消息队列接收到第二微服务返回的针对第一消息的处理结果的情况下,则服务端可以通过第一消息队列通知第一微服务,第一微服务用于与第二微服务同步数据,从而保证多个微服务的事务数据的一致性。Optionally, when the first message queue receives the processing result for the first message returned by the second microservice, the server can notify the first microservice through the first message queue, and the first microservice is used to communicate with The second microservice synchronizes data, thereby ensuring the consistency of transaction data of multiple microservices.
508,在第一微服务对应至少两个事务、至少两个事务包括第一事务和第二事务、并且第一事务对应的第一数据源和第二事务对应的第二数据源不同的情况下,服务端创建链式事务管理器。508, when the first microservice corresponds to at least two transactions, the at least two transactions include the first transaction and the second transaction, and the first data source corresponding to the first transaction is different from the second data source corresponding to the second transaction , the server creates a chained transaction manager.
509,服务端通过链式事务管理器对第一数据源对应的事务和第二数据源对应的事务进行处理。509, the server processes the transaction corresponding to the first data source and the transaction corresponding to the second data source through the chained transaction manager.
其中,步骤508至509的具体实施可以参见步骤202至203,此处不再赘述。Wherein, for the specific implementation of steps 508 to 509, reference may be made to steps 202 to 203, which will not be repeated here.
可选的,在执行步骤506之后,在图5所示的方法还可以包括如下步骤:在所述第一消息处理成功后,服务端将所述第一消息持久化到所述第一消息表或第一消息集合中。Optionally, after step 506 is performed, the method shown in FIG. 5 may further include the following steps: after the first message is successfully processed, the server persists the first message to the first message table or in the first message collection.
本公开实施例中,业务请求的业务数据可以包括执行业务请求所需的数据。例如,如果业务请求是下单请求,则下单请求所需的数据可以包括:订单数据(比如,订单编号)、订单的明细数据(比如,下单时间、下单商品的数量、购买商品明细、购买金额等)。In the embodiment of the present disclosure, the service data of the service request may include data required to execute the service request. For example, if the business request is an order request, the data required for the order request may include: order data (for example, order number), order detail data (for example, order time, quantity of ordered goods, details of purchased goods , purchase amount, etc.).
数据持久化,是将内存中的数据模型转换为存储模型,以及将存储模型转换为内存中的数据模型的统称。比如,将所述第一消息持久化到所述第一消息表或第一消息集合,可以将第一消息存放到第一消息表或第一消息集合中。Data persistence is a collective term for converting an in-memory data model to a storage model, and converting a storage model to an in-memory data model. For example, to persist the first message in the first message table or first message set, the first message may be stored in the first message table or first message set.
可选的,图5所示的方法还可以包括如下步骤:Optionally, the method shown in Figure 5 may also include the following steps:
在所述第一消息表或第一消息集合中存在与所述第一消息的标识符相同的消息的情况下,服务端丢弃所述第一消息。If there is a message with the same identifier as the first message in the first message table or first message set, the server discards the first message.
本公开实施例中,服务端可以在第二微服务对应的数据源中创建第一消息表,第一消息表用于存放消息,每个消息都可以对应一个标识符,这个标识符可以是全局唯一标识符(globally unique identifier,GUID)。由于业务请求可以对应多个微服务,这多个微服务可以在网络的多个设备中执行,在这多个微服务之间可以将每个消息打上一个全局标识符,可以区分不同的消息。示例性的,第二微服务可以是库存服务或购物车服务。In the embodiment of the present disclosure, the server can create a first message table in the data source corresponding to the second microservice. The first message table is used to store messages. Each message can correspond to an identifier. This identifier can be a global Unique identifier (globally unique identifier, GUID). Since business requests can correspond to multiple microservices, these multiple microservices can be executed in multiple devices on the network, and each message can be marked with a global identifier among these multiple microservices to distinguish different messages. Exemplarily, the second microservice may be inventory service or shopping cart service.
本公开实施例中,每个消息的标识符都是唯一的,为了避免同一个消息被执行多次,可以根据消息的标识符来判断是否会被执行多次。如果第一消息和第一消息表中的第二消息的标识符相同,则表明第一消息是第二次被放入第一消息表,直接丢弃该第一消息。如果第一消息和第二消息的标识符不同,则表明第一消息是第一次被放入第一消息表,服务端通过第二微服务处理第一消息,在第一消息处理成功后,服务端通过第二微服务 将所述第一消息持久存储到所述第一消息表。本公开实施例可以通过消息表和消息的标识符实现事务消息的幂等性校验,从而保证事务消息的幂等性。In the embodiment of the present disclosure, the identifier of each message is unique. In order to prevent the same message from being executed multiple times, it may be determined according to the identifier of the message whether it will be executed multiple times. If the identifiers of the first message and the second message in the first message table are the same, it indicates that the first message is put into the first message table for the second time, and the first message is directly discarded. If the identifiers of the first message and the second message are different, it indicates that the first message is put into the first message table for the first time, and the server processes the first message through the second microservice. After the first message is successfully processed, The server persistently stores the first message in the first message table through the second microservice. The embodiment of the present disclosure can realize the idempotency check of the transaction message through the message table and the identifier of the message, so as to ensure the idempotence of the transaction message.
可选的,在执行步骤503之后,还可以执行如下步骤:服务端通过表达式语言定义所述第一消息表的表名或所述第一消息集合的集合名。Optionally, after step 503 is performed, the following step may also be performed: the server defines the table name of the first message table or the set name of the first message set through an expression language.
本公开实施例中,表达式语言可以是Spring表达式语言(Spring Expression Language,SpEL)。SpEL表达式可以实现表名或集合名的自动配置,可以灵活的定义表名或集合名。In the embodiment of the present disclosure, the expression language may be Spring Expression Language (Spring Expression Language, SpEL). SpEL expressions can realize the automatic configuration of table names or collection names, and can flexibly define table names or collection names.
可选的,上述方法还可以包括:通过服务发现机制(Service Provider Interface,SPI)定义应用监听器,所述应用监听器用于配置所述第一微服务的包扫描的路径。Optionally, the above method may further include: defining an application listener through a service discovery mechanism (Service Provider Interface, SPI), and the application listener is used to configure a packet scanning path of the first microservice.
本公开实施例中,SPI是Java开发工具包内部提供的一种服务发现机制,SPI通过在ClassPath路径下的META-INF/services文件夹查找文件,自动加载文件里所定义的类。SPI可以定义应用监听器,应用监听器用于配置所述第一微服务的包扫描的路径。不需要用户在启动类上添加包扫描路径,降低用户开发难度。In the embodiment of the present disclosure, SPI is a service discovery mechanism provided inside the Java development toolkit. SPI searches for files in the META-INF/services folder under the ClassPath path, and automatically loads the classes defined in the files. The SPI may define an application listener, and the application listener is used to configure the packet scanning path of the first microservice. It does not require users to add package scanning paths to the startup class, reducing the difficulty of user development.
本公开实施例的方法可以通过基于自动配置的可插拔组件来实现。该组件可以用在Spring项目的开发中,可以用在基于微服务化开发的电商平台以及其他微服务化开发的产品中。The methods in the embodiments of the present disclosure can be implemented by pluggable components based on automatic configuration. This component can be used in the development of the Spring project, and can be used in the e-commerce platform based on micro-service development and other micro-service development products.
在一些可选实施例中,本公开实施例的软件产品可以是一个可插拔的组件。比如,Spring Boot Starter组件,可以在任何Spring项目中快速引入,可以使用默认的配置,也可按需在项目的配置文件(比如,Properties或yml)中进行简单的配置。组件的引入不会对自身的项目产生任何影响,仅当微服务启动类使用使能(Enable)注解启用此消息事务组件的自动配置(AutoConfigure)支持时才会进行相关服务的配置和注册。In some optional embodiments, the software product of the embodiments of the present disclosure may be a pluggable component. For example, the Spring Boot Starter component can be quickly introduced in any Spring project, using the default configuration, or simply configuring it in the project's configuration file (for example, Properties or yml) as needed. The introduction of the component will not have any impact on its own project. Only when the microservice startup class uses the enable (Enable) annotation to enable the automatic configuration (AutoConfigure) support of this message transaction component will the configuration and registration of related services be performed.
其中,组件的开发流程可以包括如下步骤:Among them, the component development process may include the following steps:
1、创建Spring Boot Starter项目,引入相关依赖(比如,maven依赖);1. Create a Spring Boot Starter project and introduce related dependencies (for example, maven dependencies);
2、创建事务消息实体类,映射到MySQL数据表和MongoDB集合,通过SpEL表达式动态定义表名或集合名;2. Create transaction message entity classes, map to MySQL data tables and MongoDB collections, and dynamically define table names or collection names through SpEL expressions;
3、开发操作MySQL数据表和MongoDB集合的服务(Service),同时MongoDB的Service可以动态的根据其版本是否支持事务来决定是否将其更新操作添加到事务中;3. Develop and operate the service (Service) of MySQL data tables and MongoDB collections. At the same time, MongoDB's Service can dynamically decide whether to add its update operation to the transaction according to whether its version supports transactions;
4、定义用于自动配置是否启用的Enable注解,并添加消息持久化方式的属性,用于判断使用MySQL数据库还是MongoDB数据库存储事务消息,同时决定将要注册到Spring容器中的是处理MySQL消息表的Service还是MongoDB消息集合的Service;4. Define the Enable annotation for whether automatic configuration is enabled, and add the attribute of the message persistence method to determine whether to use the MySQL database or the MongoDB database to store transaction messages, and at the same time decide to register in the Spring container to process the MySQL message table Service is also the Service of MongoDB message collection;
5、通过服务发现机制(service provider interface,SPI)机制定义应用监听器,用于配置Spring包扫描的路径;5. Define the application listener through the service provider interface (SPI) mechanism to configure the path for Spring package scanning;
6、定义MySQL,MongoDB以及Kafka等多种数据源的事务管理器及其是否创建的条件,并创建以上数据源各种组合的链式事务管理器;6. Define transaction managers for multiple data sources such as MySQL, MongoDB, and Kafka and the conditions for creating them, and create chained transaction managers for various combinations of the above data sources;
7、定义卡夫卡(kafka)消息生产者Service类用于事务消息封装和投递,同时可以根据业务微服务是否引入kafka依赖来动态管理Service的到Spring容器的注册,并可 以根据kafka版本是否支持事务以及是否开启事务来决定是否将其消息投递操作添加到事务中;7. Define the Kafka (kafka) message producer Service class for transaction message encapsulation and delivery. At the same time, it can dynamically manage the registration of the Service to the Spring container according to whether the business microservice introduces kafka dependencies, and can support it according to the kafka version. Transaction and whether to open the transaction to decide whether to add its message delivery operation to the transaction;
8、通过kafka的事务支持实现消息的准确投递,通过其消息消费确认或提交机制、kafka消息持久化特性以及消息偏移量来保证事务的最终一致性。8. Realize the accurate delivery of messages through kafka's transaction support, and ensure the final consistency of transactions through its message consumption confirmation or submission mechanism, kafka message persistence characteristics and message offset.
其中,组件在项目中使用可以包括如下步骤:Among them, the use of components in the project may include the following steps:
1、用户创建业务微服务项目,添加组件;1. The user creates a business microservice project and adds components;
2、在配置文件中配置事务消息持久化的表名或集合名的默认名(比如,默认名是transfer message),配置默认的事务管理器(比如,默认为MySQL);2. Configure the default name of the table name or collection name for transaction message persistence in the configuration file (for example, the default name is transfer message), and configure the default transaction manager (for example, MySQL by default);
3、在启动类上加注解,用于自动配置和注册消息持久化服务;3. Add annotations to the startup class for automatic configuration and registration of message persistence services;
4、执行本地事务,如果数据源关联的是默认的事务管理器,不涉及多种数据源,直接使用注解,不用设置属性;如果数据源关联的是其他事务管理器,则注解必须设置属性为组件已提供的链式事务管理器;4. Execute local transactions. If the data source is associated with the default transaction manager and does not involve multiple data sources, use the annotation directly without setting attributes; if the data source is associated with other transaction managers, the annotation must set the attribute as The chained transaction manager provided by the component;
5、业务微服务如果需要使用卡夫卡,由于组件默认不会引入卡夫卡,则需要在微服务中添加卡夫卡相关的依赖,通过自动装配的方式注入卡夫卡消息投递者到业务服务中,用于卡夫卡消息的投递;5. If the business microservice needs to use Kafka, since the components will not import Kafka by default, you need to add Kafka-related dependencies in the microservice, and inject the Kafka message deliverer into the business through automatic assembly In the service, it is used for delivery of Kafka messages;
6、创建另一个消费者业务微服务,同样的引入相关依赖,然后创建一个卡夫卡消息监听器用于处理事务消息。基于此组件自动装配的用于消息持久化及幂等校验的服务(MessageService)可以实现事务消息的幂等性判断。6. Create another consumer business microservice, similarly introduce related dependencies, and then create a Kafka message listener for processing transaction messages. The service (MessageService) for message persistence and idempotence verification automatically assembled based on this component can realize the idempotence judgment of transaction messages.
本公开实施例的组件可以实现MySQL,MongoDB以及Kafka多类型数据源的事务支持,并可以根据项目所引用的依赖和事务开启状态动态创建单数据源事务管理器和链式事务管理器;事务消息持久化的表名或集合可以名动态定义,使得微服务的配置更灵活,各个微服务可以使用同一个数据库,通过不同的表名和集合名来区别不同微服务的持久化事务消息;可以通过SPI机制定义应用监听器实现微服务的Spring包扫描,不需要用户在启动类上添加此组件的包扫描路径;组件可以根据用户Enable注解的启用情况和属性值来动态的创建Service,并将有效的Service注册到Spring容器,不会对无效冗余的Service进行注册;Kafka和MongoDB的前期版本不支持事务,且Kafka的事务需要通过配置或编码的方式手动开启,基于此组件用户无需重复判断,组件会根据数据源对事务的支持和开启状态动态管理事务;集成多类型数据源事务支持和多实例数据源事务一致性的实现,不需要为两种场景开发不同的组件;跨服务多数据源事务一致性是基于Kafka消息队列的最大努力通知实现的最终一致性,相比于刚性事务和补偿型事务在吞吐量上都有很大提升,同时可以满足高并发场景下的流量削峰,保证服务稳定性;基于自动配置的可随意插拔组件,业务微服务添加此组件依赖后不会产生影响,不需要额外配置,仅当用户主动启用此组件的自动配置时相关功能才会启用,且组件的自动配置机制和默认配置可以满足绝大部分需求,基本不需要用户做额外的配置。The components of the disclosed embodiment can realize the transaction support of MySQL, MongoDB and Kafka multi-type data sources, and can dynamically create a single data source transaction manager and a chained transaction manager according to the dependencies referenced by the project and the transaction opening state; transaction message Persistent table names or collections can be dynamically defined, making the configuration of microservices more flexible. Each microservice can use the same database, and distinguish the persistent transaction messages of different microservices through different table names and collection names; it can be used through SPI The mechanism defines the application listener to realize the Spring package scanning of microservices, and does not require the user to add the package scanning path of this component on the startup class; the component can dynamically create a Service according to the enablement of the user's Enable annotation and the attribute value, and will effectively Service is registered to the Spring container, and invalid redundant services will not be registered; previous versions of Kafka and MongoDB do not support transactions, and Kafka transactions need to be manually enabled through configuration or coding. Based on this component, users do not need to make repeated judgments. It will dynamically manage transactions according to the data source's support for transactions and the opening status; integrate multi-type data source transaction support and the realization of multi-instance data source transaction consistency, and do not need to develop different components for the two scenarios; cross-service multi-data source transactions Consistency is the final consistency based on the best effort notification of the Kafka message queue. Compared with rigid transactions and compensating transactions, the throughput is greatly improved, and it can meet the traffic peak shaving in high concurrency scenarios and guarantee service Stability; based on automatic configuration of pluggable components, business microservices will not be affected after adding this component dependency, and no additional configuration is required. Only when the user actively enables the automatic configuration of this component will the relevant functions be enabled, and the component The automatic configuration mechanism and default configuration can meet most of the needs, and basically do not require users to do additional configuration.
上述主要从方法侧执行过程的角度对本公开实施例的方案进行了介绍。可以理解的是,电子设备为了实现上述功能,其包含了执行各个功能相应的硬件结构和/或软件模块。 本领域技术人员应该很容易意识到,结合本文中所提供的实施例描述的各示例的单元及算法步骤,本公开能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用使用不同方法来实现所描述的功能,但是这种实现不应认为超出本公开的范围。The foregoing mainly introduces the solutions of the embodiments of the present disclosure from the perspective of executing the process on the method side. It can be understood that, in order to realize the above functions, the electronic device includes hardware structures and/or software modules corresponding to each function. Those skilled in the art should easily realize that, in combination with the units and algorithm steps of the examples described in the embodiments provided herein, the present disclosure can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed by hardware or computer software drives hardware depends on the specific application and design constraints of the technical solution. Skilled artisans may implement the described functionality using different methods for each particular application, but such implementation should not be considered beyond the scope of the present disclosure.
本公开实施例可以根据上述方法示例对服务器和电子设备进行功能单元的划分,例如,可以对应各个功能划分各个功能单元,也可以将两个或两个以上的功能集成在一个处理单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。需要说明的是,本公开实施例中对单元的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式。The embodiments of the present disclosure may divide the functional units of the server and the electronic device according to the above method examples. For example, each functional unit may be divided corresponding to each function, or two or more functions may be integrated into one processing unit. The above-mentioned integrated units can be implemented in the form of hardware or in the form of software functional units. It should be noted that the division of the units in the embodiment of the present disclosure is schematic, and is only a logical function division, and there may be another division manner in actual implementation.
请参阅图6,图6是本公开实施例提供的一种事务处理装置的结构示意图,该事务处理装置600应用于服务端,该事务处理装置600可以包括第一创建单元601、第二创建单元602和事务处理单元603,其中:Please refer to FIG. 6. FIG. 6 is a schematic structural diagram of a transaction processing device provided by an embodiment of the present disclosure. The transaction processing device 600 is applied to the server. 602 and transaction processing unit 603, wherein:
第一创建单元601,配置为创建第一微服务;The first creation unit 601 is configured to create a first microservice;
第二创建单元602,配置为在所述第一微服务对应至少两个事务、所述至少两个事务包括第一事务和第二事务、并且所述第一事务对应的第一数据源和所述第二事务对应的第二数据源不同的情况下,创建链式事务管理器;The second creating unit 602 is configured to correspond to at least two transactions in the first microservice, the at least two transactions include a first transaction and a second transaction, and the first data source and the first transaction correspond to the first transaction If the second data source corresponding to the above second transaction is different, create a chained transaction manager;
事务处理单元603,配置为通过所述链式事务管理器对所述第一数据源对应的事务和所述第二数据源对应的事务进行处理。The transaction processing unit 603 is configured to process the transaction corresponding to the first data source and the transaction corresponding to the second data source through the chained transaction manager.
可选的,第二创建单元602,还配置为在所述第一微服务对应至少一个事务、并且所述至少一个事务对应相同的目标数据源的情况下,创建单数据源事务管理器;Optionally, the second creating unit 602 is further configured to create a single data source transaction manager when the first microservice corresponds to at least one transaction and the at least one transaction corresponds to the same target data source;
事务处理单元603,还配置为通过所述单数据源事务管理器对所述至少一个事务进行处理。The transaction processing unit 603 is further configured to process the at least one transaction through the single data source transaction manager.
可选的,所述第二创建单元602,配置为在所述目标数据源是默认数据源的情况下,通过注解的方式配置默认事务管理器,所述默认事务管理器实现所述默认数据源的事务支持,所述单数据源事务管理器包括所述默认事务管理器。Optionally, the second creating unit 602 is configured to configure a default transaction manager through annotations when the target data source is a default data source, and the default transaction manager implements the default data source The transaction support of the single data source transaction manager includes the default transaction manager.
可选的,所述第二创建单元602,配置为创建事务管理器,通过注解的方式设置所述事务管理器的属性为链式事务管理器。Optionally, the second creation unit 602 is configured to create a transaction manager, and set the attribute of the transaction manager as a chained transaction manager through annotations.
可选的,该事务处理装置600还可以包括接收单元604和确定单元605。Optionally, the transaction processing apparatus 600 may further include a receiving unit 604 and a determining unit 605 .
所述接收单元604,配置为接收用户端发起的业务请求;The receiving unit 604 is configured to receive a service request initiated by a client;
所述确定单元605,配置为确定所述业务请求涉及的至少一个微服务,所述至少一个微服务包括所述第一微服务;The determining unit 605 is configured to determine at least one microservice involved in the service request, where the at least one microservice includes the first microservice;
所述第一创建单元601,配置为在所述确定单元605确定所述业务请求涉及的至少一个微服务之后,创建第一微服务。The first creating unit 601 is configured to create a first microservice after the determining unit 605 determines at least one microservice involved in the service request.
可选的,所述至少一个微服务还包括第二微服务,该事务处理装置600还可以包括投递单元606、判断单元609和消息处理单元610。Optionally, the at least one microservice further includes a second microservice, and the transaction processing apparatus 600 may further include a delivery unit 606 , a judging unit 609 and a message processing unit 610 .
所述第一创建单元601,还配置为在所述确定单元605确定所述业务请求涉及的至少一个微服务之后,创建所述第二微服务,创建第一消息表或第一消息集合;The first creating unit 601 is further configured to create the second microservice after the determining unit 605 determines at least one microservice involved in the service request, and create a first message table or a first message set;
投递单元606,配置为将与所述业务请求相关的第一消息投递到第一消息队列,所述第二微服务配置为从所述第一消息队列获得所述第一消息以及;The delivery unit 606 is configured to deliver the first message related to the service request to a first message queue, the second microservice is configured to obtain the first message from the first message queue; and;
所述判断单元609,配置为根据所述第一消息的标识符判断所述第一消息表或第一消息集合中是否存在与所述第一消息的标识符相同的消息;The judging unit 609 is configured to judge whether there is a message with the same identifier as the first message in the first message table or first message set according to the identifier of the first message;
所述消息处理单元610,配置为在所述判断单元609判断结果为否的情况下,通过所述第二微服务处理所述第一消息。The message processing unit 610 is configured to process the first message through the second microservice when the determination result of the determination unit 609 is negative.
该事务处理装置600还可以包括通知单元607;The transaction processing device 600 may also include a notification unit 607;
通知单元607,配置为在所述第一消息队列没有接收到所述第二微服务返回的针对所述第一消息的消息处理成功确认消息的情况下,通过所述第一消息队列采用最大努力通知策略通知所述第二微服务。The notification unit 607 is configured to use best effort through the first message queue when the first message queue does not receive the message processing success confirmation message for the first message returned by the second microservice The notification policy notifies the second microservice.
可选的,该事务处理装置600还可以包括持久化单元608。Optionally, the transaction processing apparatus 600 may further include a persistence unit 608 .
所述持久化单元608,配置为在所述第一消息处理成功后,将所述第一消息持久化到所述第一消息表或第一消息集合中。The persisting unit 608 is configured to persist the first message in the first message table or first message set after the first message is successfully processed.
可选的,所述消息处理单元610,还配置为在所述判断单元609判断结果为是的情况下,丢弃所述第一消息。Optionally, the message processing unit 610 is further configured to discard the first message when the judging result of the judging unit 609 is yes.
可选的,该事务处理装置600还可以包括第一定义单元;Optionally, the transaction processing device 600 may also include a first definition unit;
所述定义单元,配置为所述第一创建单元601创建第一消息表或第一消息集合之后,通过表达式语言定义所述第一消息表的表名或所述第一消息集合的集合名。The definition unit is configured to define the table name of the first message table or the set name of the first message set through an expression language after the first creation unit 601 creates the first message table or the first message set .
可选的,该事务处理装置600还可以包括第二定义单元;Optionally, the transaction processing apparatus 600 may also include a second definition unit;
所述第二定义单元,配置为通过服务发现机制SPI定义应用监听器,所述应用监听器用于配置所述第一微服务的包扫描的路径。The second definition unit is configured to define an application listener through a service discovery mechanism SPI, and the application listener is used to configure a packet scanning path of the first microservice.
可选的,所述第一创建单元601,配置为通过自动配置机制实现所述第一微服务的动态配置和注册。Optionally, the first creating unit 601 is configured to implement dynamic configuration and registration of the first microservice through an automatic configuration mechanism.
其中,本公开实施例中的接收单元604可以是服务器的输入输出装置,第一创建单元601、第二创建单元602、事务处理单元603、确定单元605、投递单元606、通知单元607、持久化单元608、判断单元609、消息处理单元610、第一定义单元和第二定义单元可以是服务器的处理器。Among them, the receiving unit 604 in the embodiment of the present disclosure may be the input and output device of the server, the first creation unit 601, the second creation unit 602, the transaction processing unit 603, the determination unit 605, the delivery unit 606, the notification unit 607, the persistent The unit 608, the judging unit 609, the message processing unit 610, the first defining unit and the second defining unit may be processors of the server.
本公开实施例中,可以通过链式事务管理器对第一数据源对应的事务和第二数据源对应的事务进行处理,由于链式事务管理器可以实现多种数据源的事务支持,保证第一事务和第二事务同时执行成功或者同时失败,从而可以保证第一微服务对应的第一事务和第二事务的数据一致性。In the embodiment of the present disclosure, the transaction corresponding to the first data source and the transaction corresponding to the second data source can be processed through the chained transaction manager. The first transaction and the second transaction execute successfully or fail at the same time, so that the data consistency of the first transaction and the second transaction corresponding to the first microservice can be guaranteed.
请参阅图7,图7是本公开实施例提供的一种服务器的结构示意图,如图7所示,该服务器700包括处理器701和存储器702,处理器701、存储器702可以通过通信总线703相互连接。通信总线703可以是外设部件互连标准(Peripheral Component  Interconnect,PCI)总线或扩展工业标准结构(Extended Industry Standard Architecture,EISA)总线等。通信总线703可以分为地址总线、数据总线、控制总线等。为便于表示,图7中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。存储器702用于存储计算机程序,计算机程序包括程序指令,处理器701被配置用于调用程序指令,上述程序包括用于执行图2~图5中的方法。Please refer to FIG. 7. FIG. 7 is a schematic structural diagram of a server provided by an embodiment of the present disclosure. As shown in FIG. 7, the server 700 includes a processor 701 and a memory 702. connect. The communication bus 703 may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (Extended Industry Standard Architecture, EISA) bus or the like. The communication bus 703 can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one thick line is used in FIG. 7 , but it does not mean that there is only one bus or one type of bus. The memory 702 is used to store computer programs, the computer programs include program instructions, and the processor 701 is configured to call the program instructions, and the above programs are included to execute the methods in FIGS. 2 to 5 .
处理器701可以是通用中央处理器(CPU),微处理器,特定应用集成电路(Application-Specific Integrated Circuit,ASIC),或一个或多个用于控制以上方案程序执行的集成电路。 Processor 701 may be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (Application-Specific Integrated Circuit, ASIC), or one or more integrated circuits used to control the execution of the programs of the above solutions.
存储器702可以是只读存储器(Read-Only Memory,ROM)或可存储静态信息和指令的其他类型的静态存储设备,随机存取存储器(Random Access Memory,RAM)或者可存储信息和指令的其他类型的动态存储设备,也可以是电可擦可编程只读存储器(Electrically Erasable Programmable Read-Only Memory,EEPROM)、只读光盘(Compact Disc Read-Only Memory,CD-ROM)或其他光盘存储、光碟存储(包括压缩光碟、激光碟、光碟、数字通用光碟、蓝光光碟等)、磁盘存储介质或者其他磁存储设备、或者能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质,但不限于此。存储器可以是独立存在,通过总线与处理器相连接。存储器也可以和处理器集成在一起。The memory 702 may be a read-only memory (Read-Only Memory, ROM) or other types of static storage devices that can store static information and instructions, and a random access memory (Random Access Memory, RAM) or other types that can store information and instructions It can also be an electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, EEPROM), a read-only disc (Compact Disc Read-Only Memory, CD-ROM) or other optical disc storage, optical disc storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media or other magnetic storage devices, or can be used to carry or store desired program code in the form of instructions or data structures and can be programmed by a computer Any other medium accessed, but not limited to. The memory can exist independently and be connected to the processor through the bus. Memory can also be integrated with the processor.
可选地,该服务器700还可以包括输入输出装置704,输入输出装置704可以包括射频电路、天线等输入输出装置。Optionally, the server 700 may further include an input and output device 704, and the input and output device 704 may include an input and output device such as a radio frequency circuit and an antenna.
本公开实施例中,可以通过链式事务管理器对第一数据源对应的事务和第二数据源对应的事务进行处理,由于链式事务管理器可以实现多种数据源的事务支持,保证第一事务和第二事务同时执行成功或者同时失败,从而可以保证第一微服务对应的第一事务和第二事务的数据一致性。In the embodiment of the present disclosure, the transaction corresponding to the first data source and the transaction corresponding to the second data source can be processed through the chained transaction manager. The first transaction and the second transaction execute successfully or fail at the same time, so that the data consistency of the first transaction and the second transaction corresponding to the first microservice can be guaranteed.
本公开实施例还提供一种计算机可读存储介质,其中,该计算机可读存储介质存储用于电子数据交换的计算机程序,该计算机程序使得计算机执行如上述方法实施例中记载的任何一种事务处理方法的部分或全部步骤。An embodiment of the present disclosure also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program for electronic data exchange, and the computer program enables the computer to perform any transaction as described in the above-mentioned method embodiments Some or all steps of a processing method.
本公开实施例还提供一种计算机程序,所述计算机程序被处理器执行时实现本公开实施例上述方法实施例中记载的任何一种事务处理方法的部分或全部步骤。Embodiments of the present disclosure further provide a computer program, which implements some or all steps of any transaction processing method described in the foregoing method embodiments in the embodiments of the present disclosure when the computer program is executed by a processor.
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本公开并不受所描述的动作顺序的限制,因为依据本公开,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定是本公开所必须的。It should be noted that for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations, but those skilled in the art should know that the present disclosure is not limited by the described action sequence. Because of this disclosure, certain steps may be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification belong to preferred embodiments, and the actions and modules involved are not necessarily required by the present disclosure.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。In the foregoing embodiments, the descriptions of each embodiment have their own emphases, and for parts not described in detail in a certain embodiment, reference may be made to relevant descriptions of other embodiments.
在本公开所提供的几个实施例中,应该理解到,所揭露的装置,可通过其它的方式 实现。例如,以上所描述的装置实施例仅仅是示意性的,例如所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性或其它的形式。In the several embodiments provided in the present disclosure, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or can be Integrate into another system, or some features may be ignored, or not implemented. In another point, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection of devices or units may be in electrical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed to multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
另外,在公开明各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件程序模块的形式实现。In addition, each functional unit in each embodiment of the disclosure may be integrated into one processing unit, each unit may exist separately physically, or two or more units may be integrated into one unit. The above-mentioned integrated units can be implemented not only in the form of hardware, but also in the form of software program modules.
所述集成的单元如果以软件程序模块的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储器中。基于这样的理解,本公开的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储器中,包括若干指令用以使得一台计算机设备(可为个人计算机、服务器或者网络设备等)执行本公开各个实施例所述方法的全部或部分步骤。而前述的存储器包括:U盘、ROM、RAM、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。The integrated units may be stored in a computer-readable memory if implemented in the form of a software program module and sold or used as an independent product. Based on such an understanding, the essence of the technical solution of the present disclosure or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a memory. Several instructions are included to make a computer device (which may be a personal computer, server or network device, etc.) execute all or part of the steps of the methods described in the various embodiments of the present disclosure. The aforementioned memory includes various media capable of storing program codes such as U disk, ROM, RAM, mobile hard disk, magnetic disk or optical disk.
本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,该程序可以存储于一计算机可读存储器中,存储器可以包括:闪存盘、只读存储器、随机存取器、磁盘或光盘等。Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above-mentioned embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable memory, and the memory can include: a flash disk , read-only memory, random access device, magnetic disk or optical disk, etc.
以上对本公开实施例进行了详细介绍,本文中应用了具体个例对本公开的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本公开的方法及其核心思想;同时,对于本领域的一般技术人员,依据本公开的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本公开的限制。The embodiments of the present disclosure have been introduced in detail above, and the principles and implementation methods of the present disclosure have been explained by using specific examples in this article. The descriptions of the above embodiments are only used to help understand the methods and core ideas of the present disclosure; at the same time, for Those skilled in the art may have changes in specific implementation methods and application scopes based on the idea of the present disclosure. In summary, the contents of this specification should not be construed as limiting the present disclosure.

Claims (28)

  1. 一种事务处理方法,包括:A transaction processing method comprising:
    创建第一微服务;Create the first microservice;
    在所述第一微服务对应至少两个事务、所述至少两个事务包括第一事务和第二事务、并且所述第一事务对应的第一数据源和所述第二事务对应的第二数据源不同的情况下,则创建链式事务管理器;The first microservice corresponds to at least two transactions, the at least two transactions include a first transaction and a second transaction, and the first data source corresponding to the first transaction and the second transaction corresponding to the second transaction If the data sources are different, create a chained transaction manager;
    通过所述链式事务管理器对所述第一数据源对应的事务和所述第二数据源对应的事务进行处理。The transaction corresponding to the first data source and the transaction corresponding to the second data source are processed by the chained transaction manager.
  2. 根据权利要求1所述的方法,其中,所述方法还包括:The method according to claim 1, wherein the method further comprises:
    在所述第一微服务对应至少一个事务、并且所述至少一个事务对应相同的目标数据源的情况下,则创建单数据源事务管理器;In the case where the first microservice corresponds to at least one transaction and the at least one transaction corresponds to the same target data source, then create a single data source transaction manager;
    通过所述单数据源事务管理器对所述至少一个事务进行处理。The at least one transaction is processed by the single data source transaction manager.
  3. 根据权利要求2所述的方法,其中,所述创建单数据源事务管理器,包括:The method according to claim 2, wherein said creating a single data source transaction manager comprises:
    在所述目标数据源是默认数据源的情况下,通过注解的方式配置默认事务管理器,所述默认事务管理器实现所述默认数据源的事务支持,所述单数据源事务管理器包括所述默认事务管理器。In the case where the target data source is a default data source, the default transaction manager is configured through annotations, the default transaction manager realizes the transaction support of the default data source, and the single data source transaction manager includes all Describes the default transaction manager.
  4. 根据权利要求1所述的方法,其中,所述创建链式事务管理器,包括:The method according to claim 1, wherein said creating a chained transaction manager comprises:
    创建事务管理器,通过注解的方式设置所述事务管理器的属性为链式事务管理器。Create a transaction manager, and set the property of the transaction manager as a chained transaction manager through annotations.
  5. 根据权利要求1至4任一项所述的方法,其中,所述创建第一微服务之前,所述方法还包括:The method according to any one of claims 1 to 4, wherein, before creating the first microservice, the method further comprises:
    接收用户端发起的业务请求;Receive the service request initiated by the client;
    确定所述业务请求涉及的至少一个微服务,所述至少一个微服务包括所述第一微服务。Determine at least one microservice involved in the service request, where the at least one microservice includes the first microservice.
  6. 根据权利要求5所述的方法,其中,所述至少一个微服务还包括第二微服务,所述方法还包括:The method according to claim 5, wherein said at least one microservice further comprises a second microservice, said method further comprising:
    创建所述第二微服务,创建第一消息表或第一消息集合;Create the second microservice, create a first message table or a first message set;
    将与所述业务请求相关的第一消息投递到第一消息队列,所述第二微服务用于从所述第一消息队列获得所述第一消息;posting a first message related to the service request to a first message queue, and the second microservice is used to obtain the first message from the first message queue;
    根据所述第一消息的标识符判断所述第一消息表或第一消息集合中是否存在与所述第一消息的标识符相同的消息;judging according to the identifier of the first message whether there is a message identical to the identifier of the first message in the first message table or the first message set;
    在所述第一消息表或第一消息集合中不存在与所述第一消息的标识符相同的消息的情况下,通过所述第二微服务处理所述第一消息。If there is no message with the same identifier as the first message in the first message table or first message set, the first message is processed through the second microservice.
  7. 根据权利要求6所述的方法,其中,所述处理所述第一消息之后,所述方法还包括:The method according to claim 6, wherein after the processing of the first message, the method further comprises:
    在所述第一消息队列没有接收到所述第二微服务返回的针对所述第一消息的消息处理成功确认消息的情况下,则通过所述第一消息队列采用最大努力通知策略通知所述第二微服务。In the case that the first message queue does not receive the message processing success confirmation message for the first message returned by the second microservice, the first message queue uses the best effort notification strategy to notify the The second microservice.
  8. 根据权利要求6所述的方法,其中,所述处理所述第一消息之后,所述方法还包括:The method according to claim 6, wherein after the processing of the first message, the method further comprises:
    在所述第一消息处理成功后,将所述第一消息持久化到所述第一消息表或第一消息集合中。After the first message is successfully processed, the first message is persisted in the first message table or first message set.
  9. 根据权利要求6所述的方法,其中,所述方法还包括:The method according to claim 6, wherein the method further comprises:
    在所述第一消息表或第一消息集合中存在与所述第一消息的标识符相同的消息的情况下,丢弃所述第一消息。If there is a message with the same identifier as the first message in the first message table or first message set, the first message is discarded.
  10. 根据权利要求6所述的方法,其中,所述创建第一消息表或第一消息集合之后,所述方法还包括:The method according to claim 6, wherein, after creating the first message table or the first message set, the method further comprises:
    通过表达式语言定义所述第一消息表的表名或所述第一消息集合的集合名。The table name of the first message table or the set name of the first message set is defined by an expression language.
  11. 根据权利要求1所述的方法,其中,所述方法还包括:The method according to claim 1, wherein the method further comprises:
    通过服务发现机制定义应用监听器,所述应用监听器用于配置所述第一微服务的包扫描的路径。An application listener is defined through a service discovery mechanism, and the application listener is used to configure a packet scanning path of the first microservice.
  12. 根据权利要求1所述的方法,其中,所述创建第一微服务,包括:The method according to claim 1, wherein said creating the first microservice comprises:
    通过自动配置机制实现所述第一微服务的动态配置和注册。The dynamic configuration and registration of the first microservice is realized through an automatic configuration mechanism.
  13. 根据权利要求1至11任一项所述的方法,其中,所述方法基于自动配置的可插拔组件实现。The method according to any one of claims 1 to 11, wherein the method is implemented based on automatically configured pluggable components.
  14. 一种事务处理装置,包括:A transaction processing device comprising:
    第一创建单元,配置为创建第一微服务;The first creation unit is configured to create the first microservice;
    第二创建单元,配置为在所述第一微服务对应至少两个事务、所述至少两个事务包括第一事务和第二事务、并且所述第一事务对应的第一数据源和所述第二事务对应的第二数据源不同的情况下,创建链式事务管理器;The second creation unit is configured to correspond to at least two transactions in the first microservice, the at least two transactions include a first transaction and a second transaction, and the first data source corresponding to the first transaction and the If the second data source corresponding to the second transaction is different, create a chained transaction manager;
    事务处理单元,配置为通过所述链式事务管理器对所述第一数据源对应的事务和所述第二数据源对应的事务进行处理。The transaction processing unit is configured to process the transaction corresponding to the first data source and the transaction corresponding to the second data source through the chain transaction manager.
  15. 根据权利要求14所述的装置,其中,所述第二创建单元,还配置为在所述第一微服务对应至少一个事务、并且所述至少一个事务对应相同的目标数据源的情况下,则创建单数据源事务管理器;The device according to claim 14, wherein the second creation unit is further configured to: in the case where the first microservice corresponds to at least one transaction and the at least one transaction corresponds to the same target data source, then Create a single data source transaction manager;
    所述事务处理单元,还配置为通过所述单数据源事务管理器对所述至少一个事务进行处理。The transaction processing unit is further configured to process the at least one transaction through the single data source transaction manager.
  16. 根据权利要求15所述的装置,其中,所述第二创建单元,配置为在所述目标数据源是默认数据源的情况下,通过注解的方式配置默认事务管理器,所述默认事务管理器实现所述默认数据源的事务支持,所述单数据源事务管理器包括所述默认事务管理器。The device according to claim 15, wherein the second creation unit is configured to configure a default transaction manager through annotations when the target data source is a default data source, and the default transaction manager The transaction support of the default data source is realized, and the single data source transaction manager includes the default transaction manager.
  17. 根据权利要求14所述的装置,其中,所述第二创建单元,配置为创建事务管理器,通过注解的方式设置所述事务管理器的属性为链式事务管理器。The device according to claim 14, wherein the second creation unit is configured to create a transaction manager, and set the property of the transaction manager as a chained transaction manager through annotation.
  18. 根据权利要求14至17任一项所述的装置,其中,所述装置还包括接收单元和确定单元;其中,The device according to any one of claims 14 to 17, wherein the device further comprises a receiving unit and a determining unit; wherein,
    所述接收单元,配置为接收用户端发起的业务请求;The receiving unit is configured to receive a service request initiated by a client;
    所述确定单元,配置为确定所述业务请求涉及的至少一个微服务,所述至少一个微服务包括所述第一微服务。The determining unit is configured to determine at least one microservice involved in the service request, and the at least one microservice includes the first microservice.
  19. 根据权利要求18所述的装置,其中,所述至少一个微服务还包括第二微服务,所述装置还包括投递单元、判断单元和消息处理单元;其中,The device according to claim 18, wherein the at least one microservice further includes a second microservice, and the device further includes a delivery unit, a judging unit, and a message processing unit; wherein,
    所述第一创建单元,还配置为创建所述第二微服务,创建第一消息表或第一消息集合;The first creating unit is further configured to create the second microservice, create a first message table or a first message set;
    所述投递单元,配置为将与所述业务请求相关的第一消息投递到第一消息队列,所述第二微服务用于从所述第一消息队列获得所述第一消息;The delivery unit is configured to deliver a first message related to the service request to a first message queue, and the second microservice is used to obtain the first message from the first message queue;
    所述判断单元,配置为根据所述第一消息的标识符判断所述第一消息表或第一消息集合中是否存在与所述第一消息的标识符相同的消息;The judging unit is configured to judge whether there is a message with the same identifier as the first message in the first message table or the first message set according to the identifier of the first message;
    所述消息处理单元,配置为在所述第一消息表或第一消息集合中不存在与所述第一消息的标识符相同的消息的情况下,通过所述第二微服务处理所述第一消息。The message processing unit is configured to process the second message through the second microservice when there is no message with the same identifier as the first message in the first message table or the first message set. a message.
  20. 根据权利要求19所述的装置,其中,所述装置还包括通知单元,配置为所述消息处理单元处理所述第一消息之后,在所述第一消息队列没有接收到所述第二微服务返回的针对所述第一消息的消息处理成功确认消息的情况下,则通过所述第一消息队列采用最大努力通知策略通知所述第二微服务。The device according to claim 19, wherein the device further comprises a notification unit configured to receive the second microservice in the first message queue after the message processing unit processes the first message In the case of the returned message processing success confirmation message for the first message, the second microservice is notified through the first message queue using a best-effort notification policy.
  21. 根据权利要求19所述的装置,其中,所述装置还包括持久化单元,配置为在所述第一消息处理成功后,将所述第一消息持久化到所述第一消息表或第一消息集合中。The device according to claim 19, wherein the device further comprises a persistence unit configured to persist the first message to the first message table or the first message table after the first message is successfully processed. in the message collection.
  22. 根据权利要求19所述的装置,其中,所述消息处理单元,还配置为在所述第一消息表或第一消息集合中存在与所述第一消息的标识符相同的消息的情况下,丢弃所述第一消息。The device according to claim 19, wherein the message processing unit is further configured to, when a message with the same identifier as the first message exists in the first message table or the first message set, The first message is discarded.
  23. 根据权利要求19所述的装置,其中,所述装置还包括第一定义单元,配置为所述第一创建单元创建第一消息表或第一消息集合之后,通过表达式语言定义所述第一消息表的表名或所述第一消息集合的集合名。The device according to claim 19, wherein the device further comprises a first definition unit configured to define the first The table name of the message table or the set name of the first message set.
  24. 根据权利要求14所述的装置,其中,所述装置还包括第二定义单元,配置为通过服务发现机制定义应用监听器,所述应用监听器用于配置所述第一微服务的包扫描的路径。The device according to claim 14, wherein the device further comprises a second definition unit configured to define an application listener through a service discovery mechanism, and the application listener is used to configure the packet scanning path of the first microservice .
  25. 根据权利要求14所述的装置,其中,所述第一创建单元,配置为通过自动配置机制实现所述第一微服务的动态配置和注册。The device according to claim 14, wherein the first creating unit is configured to implement dynamic configuration and registration of the first microservice through an automatic configuration mechanism.
  26. 一种服务器,包括处理器和存储器,所述存储器用于存储计算机程序,所述计 算机程序包括程序指令,所述处理器被配置用于调用所述程序指令,执行如权利要求1至13任一项所述的方法。A server, comprising a processor and a memory, the memory is used to store a computer program, the computer program includes program instructions, the processor is configured to invoke the program instructions, and execute any one of claims 1 to 13 method described in the item.
  27. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序包括程序指令,所述程序指令当被处理器执行时使所述处理器执行如权利要求1至13任一项所述的方法。A computer-readable storage medium, the computer-readable storage medium stores a computer program, the computer program includes program instructions, and the program instructions, when executed by a processor, cause the processor to perform the any one of the methods described.
  28. 一种计算机程序,所述计算机程序被处理器执行时实现如权利要求1至13任意一项所述的事务处理方法。A computer program, which implements the transaction processing method according to any one of claims 1 to 13 when the computer program is executed by a processor.
PCT/CN2021/125230 2021-06-29 2021-10-21 Transaction processing method and related product WO2023273028A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110726140.7A CN113360299B (en) 2021-06-29 2021-06-29 Transaction processing method and related product
CN202110726140.7 2021-06-29

Publications (1)

Publication Number Publication Date
WO2023273028A1 true WO2023273028A1 (en) 2023-01-05

Family

ID=77536998

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/125230 WO2023273028A1 (en) 2021-06-29 2021-10-21 Transaction processing method and related product

Country Status (2)

Country Link
CN (1) CN113360299B (en)
WO (1) WO2023273028A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113360299B (en) * 2021-06-29 2022-11-29 深圳市商汤科技有限公司 Transaction processing method and related product

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107045454A (en) * 2016-02-06 2017-08-15 华为技术有限公司 Striding course distributed transaction control method and related system
CN111198751A (en) * 2018-11-20 2020-05-26 北京京东尚科信息技术有限公司 Service processing method and device
CN112162988A (en) * 2020-09-16 2021-01-01 中电信用服务有限公司 Distributed transaction processing method and device and electronic equipment
CN112527472A (en) * 2020-11-18 2021-03-19 北京邮电大学 Distributed transaction processing system and method based on microservice
CN113032421A (en) * 2021-04-29 2021-06-25 电子科技大学 MongoDB-based distributed transaction processing system and method
CN113360299A (en) * 2021-06-29 2021-09-07 深圳市商汤科技有限公司 Transaction processing method and related product

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10361966B2 (en) * 2016-11-14 2019-07-23 At&T Intellectual Property I, L.P. System and method for actor oriented architecture for digital service transactions based on common data structures
US10565177B2 (en) * 2016-11-14 2020-02-18 At&T Intellectual Property I, L.P. Software defined entities for digital service transactions
CN109213568A (en) * 2018-08-16 2019-01-15 北京京东尚科信息技术有限公司 A kind of block chain network service platform and its dispositions method, storage medium
US11921701B2 (en) * 2019-02-12 2024-03-05 Ebay Inc. Global distributed transactions across microservices
CN111182529B (en) * 2019-11-26 2022-11-29 腾讯云计算(北京)有限责任公司 Police application processing method and device, electronic equipment and storage medium
CN111813583B (en) * 2020-07-28 2023-06-20 厦门市易联众易惠科技有限公司 Transaction management method, device, equipment and storage medium under micro-service architecture

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107045454A (en) * 2016-02-06 2017-08-15 华为技术有限公司 Striding course distributed transaction control method and related system
CN111198751A (en) * 2018-11-20 2020-05-26 北京京东尚科信息技术有限公司 Service processing method and device
CN112162988A (en) * 2020-09-16 2021-01-01 中电信用服务有限公司 Distributed transaction processing method and device and electronic equipment
CN112527472A (en) * 2020-11-18 2021-03-19 北京邮电大学 Distributed transaction processing system and method based on microservice
CN113032421A (en) * 2021-04-29 2021-06-25 电子科技大学 MongoDB-based distributed transaction processing system and method
CN113360299A (en) * 2021-06-29 2021-09-07 深圳市商汤科技有限公司 Transaction processing method and related product

Also Published As

Publication number Publication date
CN113360299A (en) 2021-09-07
CN113360299B (en) 2022-11-29

Similar Documents

Publication Publication Date Title
US9928038B2 (en) Dynamically building locale objects or subsections of locale objects based on historical data
WO2019136800A1 (en) Service processing method, apparatus and device, and computer-readable storage medium
KR20140038989A (en) Automated user interface object transformation and code generation
JP2009087340A (en) Method and system for generating screen element of wireless application or data object
CN111198751A (en) Service processing method and device
US20140282392A1 (en) Programming model for performant computing in documentoriented storage services
US20120144405A1 (en) Efficient Serialization of Mutable Objects
CN113448756B (en) Inter-process communication system and method and computing device
US11086651B2 (en) Workflow version management
CN111737609A (en) WEB system menu bar display method, terminal and storage medium
US8538980B1 (en) Accessing forms using a metadata registry
WO2023273028A1 (en) Transaction processing method and related product
US10078652B2 (en) Reducing latency in performing a task among distributed systems
US12014170B2 (en) Mini program batch processing method and apparatus, electronic device, and readable storage medium
US9141352B2 (en) Dynamically building locale objects at run-time
CN111427630B (en) Cold start optimization method and device, electronic equipment and storage medium
JP2013534347A (en) System and method for execution of high performance computing applications
US9298473B2 (en) System and method for a generic object access layer
US6876995B1 (en) Web store events
CN113448960A (en) Method and device for importing form file
US11017032B1 (en) Document recovery utilizing serialized data
CN109375927A (en) Method, system, server and the storage medium of window application starting are realized using Qt
US20090313628A1 (en) Dynamically batching remote object model commands
US20240169219A1 (en) Asynchronous rule compilation in a multi-tenant environment
CN116055463A (en) Method and device for realizing open interface

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21947955

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE