[go: up one dir, main page]

CN114281603B - Method and device for sending message corresponding to transaction - Google Patents

Method and device for sending message corresponding to transaction

Info

Publication number
CN114281603B
CN114281603B CN202111645363.7A CN202111645363A CN114281603B CN 114281603 B CN114281603 B CN 114281603B CN 202111645363 A CN202111645363 A CN 202111645363A CN 114281603 B CN114281603 B CN 114281603B
Authority
CN
China
Prior art keywords
transaction
message
commit
sub
target transaction
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111645363.7A
Other languages
Chinese (zh)
Other versions
CN114281603A (en
Inventor
朱峰
倪一鸣
白磊磊
尉苗苗
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Postal Savings Bank of China Ltd
Original Assignee
Postal Savings Bank of China Ltd
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 Postal Savings Bank of China Ltd filed Critical Postal Savings Bank of China Ltd
Priority to CN202111645363.7A priority Critical patent/CN114281603B/en
Publication of CN114281603A publication Critical patent/CN114281603A/en
Application granted granted Critical
Publication of CN114281603B publication Critical patent/CN114281603B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Computer And Data Communications (AREA)
  • Debugging And Monitoring (AREA)

Abstract

本发明公开了一种事务对应的消息的发送方法及装置。该发明包括:确定目标事务,并为目标事务配置对应的第一提交消息;将第一提交消息做持久化操作以将第一提交消息存储至本地数据库;监测目标事务的生命周期,并在确定目标事务提交完成的情况下,提取第一提交消息并将第一提交消息发送至消息中间件;在确定目标事务提交失败的情况下,控制目标事务对应的数据进行数据回滚操作,基于数据回滚操作删除本地数据库中与目标事务对应的第一提交消息。通过本发明,解决了相关技术中业务数据与对应的消息由于一些原因导致不一致的问题。

The present invention discloses a method and device for sending messages corresponding to transactions. The invention includes: determining a target transaction and configuring a corresponding first commit message for the target transaction; persisting the first commit message to store it in a local database; monitoring the lifecycle of the target transaction and, upon determining that the target transaction has been committed, extracting the first commit message and sending it to a message middleware; and, upon determining that the target transaction has failed to commit, controlling the data corresponding to the target transaction to perform a data rollback operation, and deleting the first commit message corresponding to the target transaction in the local database based on the data rollback operation. The present invention solves the problem of inconsistency between business data and corresponding messages due to some reasons in the related art.

Description

Method and device for sending message corresponding to transaction
Technical Field
The present invention relates to the field of control transactions, and in particular, to a method and an apparatus for sending a message corresponding to a transaction.
Background
In the related art, the problem that the consistency of the message and the service cannot be maintained exists, and the main reason is that the message transmission is a remote communication mode, the objective and unreliable characteristic exists in the message transmission, and the message is inconsistent at the moment due to message middleware downtime, current limiting or network fluctuation, and meanwhile, the service data persistence failure after the successful message transmission is caused due to the reasons of the inconsistency, so that the service operation failure and the successful message transmission are caused.
The existing method sends the message, whether the retransmission is successfully carried out or not according to the returned result of the message middleware, and the success rate of the message sending can be ensured, but the consideration for the consistency of the service operation and the message is lacking, and the service requirement cannot be met. The current simulation service operation steps are as follows, service operation data A, service transmission message B and service operation data C, if the service transmission message B is successfully transmitted according to the existing method, the whole service operation needs to be failed when the service operation data C fails, the service operation data A and the service transmission message B need to be rolled back, and the existing method cannot meet the use of the scene. The existing method can ensure successful message sending, but cannot ensure consistency between the message and the service.
Meanwhile, the existing method for the complex nested independent transaction scenario cannot be solved.
In view of the above problems in the related art, no effective solution has been proposed at present.
Disclosure of Invention
The invention mainly aims to provide a method and a device for sending a message corresponding to a transaction, which are used for solving the problem that service data and the corresponding message in the related art are inconsistent due to some reasons.
In order to achieve the above object, according to one aspect of the present invention, there is provided a method for transmitting a message corresponding to a transaction. The method comprises the steps of determining a target transaction, configuring a corresponding first commit message for the target transaction, wherein the first commit message is used for notifying at least one business system that the target transaction is completed, performing persistence operation on the first commit message to store the first commit message in a local database, monitoring the life cycle of the target transaction, extracting the first commit message and sending the first commit message to a message middleware under the condition that the completion of the target transaction commit is determined, wherein the message middleware is used for receiving the first commit message and forwarding the first commit message to at least one business system corresponding to the target transaction, controlling data corresponding to the target transaction to perform data rollback operation under the condition that the failure of the target transaction commit is determined, and deleting the first commit message corresponding to the target transaction in the local database based on the data rollback operation.
Further, after monitoring the lifecycle of the target transaction and, if it is determined that the commit of the target transaction is complete, extracting the first commit message and sending the first commit message to the message middleware, the method further includes periodically scanning a local database, and, if the first commit information corresponding to the scanned target transaction is still stored in the local database, extracting the first commit message until the first commit message is successfully forwarded to the message middleware.
Further, before the target transaction commit is determined to be completed, the first commit message is extracted and sent to the message middleware, the method further comprises the steps of determining whether to start a sub-transaction corresponding to the target transaction, configuring a second commit message corresponding to the sub-transaction and storing the second commit message in a message temporary storage area corresponding to the sub-transaction when the sub-transaction is determined to be started, wherein the sub-transaction is a data operation transaction based on the target transaction, the second commit message is used for representing the completion of the sub-transaction commit, monitoring the life cycle of the sub-transaction, and when an interception action corresponding to the sub-transaction before commit is acquired, persisting the second commit message to the local database, and when the sub-transaction commit is determined to be completed, extracting the second commit message and forwarding the second commit message to the message middleware.
Further, in the case that the sub-transaction is determined to be started, configuring a second commit message corresponding to the sub-transaction, and before storing the second commit message in a message buffer corresponding to the sub-transaction, the method further comprises suspending data corresponding to the target transaction and the first commit message.
Further, after extracting the second commit message and forwarding the second commit message to the message middleware in the case that it is determined that the commit of the sub-transaction is completed, the method includes periodically scanning a local database, extracting the second commit message and forwarding the second commit message to the message middleware in the case that the second commit information corresponding to the scanned sub-transaction is still stored in the local database.
Further, the lifecycle of the target transaction is monitored and the completion of the target transaction commit is determined, including determining whether an action before the target transaction commit and an action after the target transaction commit can be intercepted, and determining that the target transaction commit is complete if the action before the commit and the action after the commit are intercepted.
Further, under the condition that the sub-transaction commit failure is determined, the method comprises the steps of controlling data corresponding to the sub-transaction to carry out data rollback operation, and deleting a second commit message corresponding to the sub-transaction in the local database based on the data rollback operation.
In order to achieve the above object, according to another aspect of the present invention, there is provided a transmission apparatus of a message corresponding to a control transaction. The device comprises a configuration unit, a determination unit and a message middleware, wherein the configuration unit determines a target transaction and configures a corresponding first commit message for the target transaction, the first commit message is used for notifying at least one business system that the target transaction is completed, the persistence unit performs persistence operation on the first commit message to store the first commit message into a local database, the determination unit monitors the life cycle of the target transaction and extracts the first commit message and sends the first commit message to the message middleware under the condition that the target transaction is completed, the message middleware is used for receiving the first commit message and forwarding the first commit message to at least one business system corresponding to the target transaction, the deletion unit controls data corresponding to the target transaction to perform data rollback operation under the condition that the target transaction is determined to be failed in commit, and the first commit message corresponding to the target transaction in the local database is deleted based on the data rollback operation.
In order to achieve the above object, according to another aspect of the present application, there is provided a computer-readable storage medium including a stored program, wherein the program performs a method of transmitting a message corresponding to one of the above-described transactions.
In order to achieve the above object, according to another aspect of the present application, there is provided a processor for executing a program, wherein the program performs a method for transmitting a message corresponding to a transaction of any one of the above.
The method comprises the steps of determining a target transaction, configuring a corresponding first commit message for the target transaction, wherein the first commit message is used for notifying at least one business system that the target transaction is committed to be completed, performing persistence operation on the first commit message to store the first commit message into a local database, monitoring the life cycle of the target transaction, extracting the first commit message and sending the first commit message to a message middleware under the condition that the target transaction is committed to be completed, wherein the message middleware is used for receiving the first commit message and forwarding the first commit message to at least one business system corresponding to the target transaction, controlling data corresponding to the target transaction to perform data rollback operation under the condition that the target transaction is committed to fail, deleting the first commit message corresponding to the target transaction in the local database based on the data rollback operation, and further achieving the effect that business operation is consistent with the corresponding message due to some reasons, namely that the business operation fails and the business operation is successful.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description serve to explain the invention. In the drawings:
fig. 1 is a flowchart of a method for sending a message corresponding to a transaction according to an embodiment of the present invention;
FIG. 2 is a second flowchart of a method for sending a message corresponding to a transaction according to an embodiment of the present invention;
FIG. 3 is a timing diagram of a successful commit of a target transaction and a successful commit of a sub-transaction according to a method for sending a message corresponding to a transaction according to an embodiment of the present invention;
FIG. 4 is a timing diagram of a successful commit of a target transaction and a failed commit of a sub-transaction according to a method for sending a message corresponding to a transaction according to an embodiment of the present invention;
FIG. 5 is a timing diagram of a case where a target transaction commit fails and a sub-transaction commit is successful in a method for sending a message corresponding to a transaction according to an embodiment of the present invention;
fig. 6 is a schematic diagram of a sending device for a message corresponding to a control transaction according to an embodiment of the present invention.
Detailed Description
It should be noted that, without conflict, the embodiments of the present invention and features of the embodiments may be combined with each other. The invention will be described in detail below with reference to the drawings in connection with embodiments.
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and the claims of the present invention and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate in order to describe the embodiments of the invention herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
According to the embodiment of the invention, a method for sending a message corresponding to a transaction is provided.
Fig. 1 is a flowchart of a method for sending a message corresponding to a transaction according to an embodiment of the present invention. As shown in fig. 1, the invention comprises the following steps:
step S101, determining a target transaction, and configuring a corresponding first commit message for the target transaction, wherein the first commit message is used for notifying at least one business system that the target transaction has been committed to completion.
In the application, the corresponding commit message, that is, the first commit message corresponding to the target transaction is configured for the target transaction to be processed in advance, and when the target transaction is committed, the first commit message is used for notifying the business system that the target transaction is committed. For example, in a banking scenario, when the target transaction is a withdrawal, after the withdrawal is completed, the first commit message corresponding to the target transaction is used to notify a service system such as a sms system, an account system, etc., and the balance of the account of the user is changed.
Step S102, the first commit message is subjected to persistence operation to store the first commit message in a local database.
In the above-mentioned manner, in the present application, it is necessary to perform persistence processing on the first commit message, where the persistence-processed commit message is stored in the corresponding local database, and the business operation corresponding to the target transaction and the persistence-processed message data keep a transaction, and the message state that has just been written is to be sent.
Step S103, the life cycle of the target transaction is monitored, and under the condition that the completion of the target transaction commit is determined, a first commit message is extracted and sent to a message middleware, wherein the message middleware is used for receiving the first commit message and forwarding the first commit message to at least one business system corresponding to the target transaction.
In the above-mentioned aspect, the present application provides a concept of a message middleware, by monitoring a life cycle of a target transaction, modifying a message state to be successful in sending according to a receipt received, forwarding a submitted message of a local database to the message middleware according to the receipt that is successful in sending, wherein if a period of event is configured, if the receipt is not received, forwarding the message to the middleware at regular time is started and repeated until the message is successful, and if a successful termination condition is that a failure time of the message has elapsed, restarting the message is not continued. .
Step S104, under the condition that the target transaction commit failure is determined, controlling data corresponding to the target transaction to carry out data rollback operation, and deleting a first commit message corresponding to the target transaction in the local database based on the data rollback operation.
When the target transaction is failed to commit, the corresponding data is subjected to data rollback operation, and the first commit message corresponding to the target transaction in the local database is deleted based on the rollback operation, so that the occurrence of errors that the message is successfully sent under the condition that the transaction is failed to commit is avoided. For example, in an optional scenario, the target transaction is a withdrawal, and if the withdrawal operation fails, the corresponding commit message is deleted based on the rollback data, and the persisted data corresponding to the target transaction is also deleted.
By the method, the problem of consistency of the service data and the corresponding message sending is solved, the problem of coupling between the service data and the corresponding message consistency is solved, the consistency of the message sending and the service operation is not perceived in the service using process, the method is suitable for the condition of complex transaction in the service scene, the transaction characteristic ensures that the message is consistent with the service data, and the complex transaction scene in the service operation is supported.
In an alternative example, after monitoring the life cycle of the target transaction and, if it is determined that the commit of the target transaction is complete, extracting the first commit message and sending the first commit message to the message middleware, the method further includes periodically scanning a local database, and, if the first commit information corresponding to the scanned target transaction is still stored in the local database, extracting the first commit message until the first commit message is successfully forwarded to the message middleware.
Specifically, after the target transaction is submitted successfully, the corresponding submitted message is forwarded to the message middleware, but the message sending failure is caused by downtime, current limitation or network fluctuation of the message middleware, at this time, the phenomenon that the service life is inconsistent with the message sending occurs, and meanwhile, the phenomenon that the service operation is failed and the message sending is successful due to the fact that service data persistence failure after the message sending is successful occurs due to the inconsistency.
In an optional embodiment provided by the application, the local database is scanned periodically to determine whether the first commit message corresponding to the target transaction is still stored in the local database, if so, the first commit message corresponding to the target transaction is forwarded to the message middleware again, and the steps are repeated until the first commit message corresponding to the target transaction is not in the local database, preferably, the specific scanning period can be set according to different service requirements. For example, in a banking scenario, the target transaction is a withdrawal, after the withdrawal is successful, the local database is scanned every 10 seconds, whether the submitted information corresponding to the withdrawal still exists in the local database is judged, if so, the corresponding message is extracted and forwarded to the message middleware until the withdrawal is successful, and the scanning is ended.
In an alternative example, the method further comprises the steps of determining whether to start a sub-transaction corresponding to the target transaction or not, configuring a second commit message corresponding to the sub-transaction and storing the second commit message in a message temporary area corresponding to the sub-transaction if the sub-transaction is determined to be started, wherein the sub-transaction is a data operation transaction based on the target transaction, the second commit message is used for representing the completion of the sub-transaction commit, monitoring the life cycle of the sub-transaction, and persisting the second commit message to a local database when an interception action corresponding to the sub-transaction before commit is acquired, and extracting the second commit message and forwarding the second commit message to the message middleware if the sub-transaction is determined to be completed.
In the above-mentioned aspect, the present application provides a method for sending a message of a nested transaction, where under the condition of determining whether a sub-transaction corresponding to a target transaction is opened, a corresponding second commit message is configured for the sub-transaction, where the second commit message and the first commit message exist independently and do not interfere with each other, and at the same time, the second commit message is stored in a message temporary storage area corresponding to the sub-transaction, where the message temporary storage area is a memory area where a program operates, and is relatively independent.
And monitoring the life cycle of the sub-transaction, persisting the second commit information to a local database when the corresponding action before the sub-transaction is committed is intercepted, and sending the second commit message which is stored in the local database and is subjected to persistence operation to a message middleware after the sub-transaction is committed.
For example, in a banking scenario, the target transaction may be a withdrawal, the sub-transaction corresponding to the withdrawal is a log operation of the withdrawal, and the log operation is not affected and is relatively independent of the withdrawal operation no matter whether the withdrawal operation is successful or failed, a commit message is configured for the log, and the commit message is forwarded to the message middleware after the log is completed.
In an alternative example, in the case that the sub-transaction is determined to be started, the method further comprises suspending the data corresponding to the target transaction and the first commit message before configuring the corresponding second commit message for the sub-transaction and storing the second commit message in the message buffer corresponding to the sub-transaction.
After determining to open the sub-transaction, the data corresponding to the target transaction and the first commit message are suspended to provide an operation space for the operation of the sub-transaction.
In an alternative example, after extracting the second commit message and forwarding to the message middleware in the event that the commit of the sub-transaction is determined to be complete, the method includes periodically scanning a local database, extracting the second commit message and forwarding the second commit message to the message middleware in the event that the second commit information corresponding to the sub-transaction is scanned to remain stored in the local database.
Periodically scanning the local database to determine whether the second commit message corresponding to the sub-transaction is still stored in the local database, forwarding the second commit message corresponding to the sub-transaction to the message middleware again if the second commit message still exists, the steps are repeated until the second commit information corresponding to the sub-transaction is not in the local database, and preferably, a specific scanning period can be set according to different service requirements.
In an alternative example, the lifecycle of the target transaction is monitored and the completion of the target transaction commit is determined, including determining whether the actions before and after the target transaction commit can be intercepted, and determining that the target transaction commit is complete if the actions before and after the commit are intercepted.
In the embodiment provided by the application, whether the target transaction is submitted successfully is determined by intercepting the actions before and after the target transaction is submitted, if both actions are intercepted successfully, the target transaction is determined to be submitted successfully, if only the actions before the target transaction is intercepted and the actions after the target transaction is not submitted, the target transaction is submitted to fail, and if both actions are not intercepted successfully, the target transaction is determined to be submitted to fail.
It should be noted that, during the operation of the nested transaction, whether the sub-transaction is submitted to be completed or not is consistent with the judging method of the main transaction (target transaction).
In an alternative example, in the case that the sub-transaction commit failure is determined, the method comprises the steps of controlling data corresponding to the sub-transaction to perform data rollback operation, and deleting a second commit message corresponding to the sub-transaction in the local database based on the data rollback operation.
And when the sub-transaction fails to commit, the corresponding data is subjected to data rollback operation, and the second commit message corresponding to the sub-transaction in the local database is deleted.
By the method, independent transactions are started in the process of nesting transactions. The message sending user has no perception, namely, the consistency of service operation data and the message is not required to be concerned for a user, the use mode of the message is not different from the use mode of the conventional sending message, only whether the use mode of the consistency is required to be configured, the internal interception mode is adopted for carrying out the persistence and the sending of the message, and the service operation does not need to be concerned when the persistence is carried out and when the message is sent. The consistency of the message is to follow the current transaction of the business operation and keep the data consistent with the current transaction of the business operation. The method and the system meet the scene of complex business operation, and can accurately follow the business to meet the message consistency under the scene of opening independent business and the like. The application gives out how to keep the consistency of the sending of the message and the data of the business operation in detail, which is particularly important for some sensitive data, and supports complex business scenes such as how to ensure the consistency of the data under the condition of transaction nesting, meets the requirement of the transaction nesting, and supports the semantics of the transaction nesting.
In an alternative embodiment of the present application, as shown in fig. 2, fig. 2 is a flowchart of a method for sending a message corresponding to a service according to an embodiment of the present application, and according to this method, success of sending a commit message corresponding to a transaction to a message middleware can be guaranteed to the greatest extent. .
In an optional embodiment provided by the application, the operations of caching, persistence, sending to a commit message middleware, timing restarting and the like of commit messages are performed by adopting a section interception mechanism in combination with spring transaction management, timing scheduling and transaction processing.
There are following types of processing according to the complex scenario of a transaction:
1) Transaction-free wrapping, namely that the submitted message can not follow the business process at the moment and the business process does not have transaction per se, and the following two behaviors are configured according to the following steps:
a. and throwing out the abnormality, and not supporting the transmission mode.
B. and enabling the sub-transaction, persisting the commit message to the local database, and sending the commit message to the commit message middleware after the persistence is finished.
2) The situations where both the target transaction and the sub-transaction exist are discussed in terms of the success and failure of the target transaction and sub-transaction commit.
Fig. 3 is a timing diagram of a successful commit of a target transaction and a successful commit of a sub-transaction according to a method for sending commit messages corresponding to a transaction according to an embodiment of the present invention.
A. Both the target transaction and the sub-transaction are configured with commit messages.
B. after the target transaction sends the commit message, the commit message may enter the commit message store.
C. The target transaction is suspended after the sub-transaction is started, and the commit message buffer of the target transaction is also suspended.
D. the sub-transaction sends the commit message and then the commit message enters a commit message temporary area of the sub-transaction, and when the sub-transaction is committed, interception processing before and after the commit is processed, and persistence processing is carried out on the commit message of the commit message temporary area before the sub-transaction is committed.
E. The sub-transaction, after commit, sends a commit message of the commit message store to the commit message middleware.
F. The target transaction will recover after the sub-transaction completes and the target transaction commit message buffer is restored.
G. the interception processing before and after the target transaction is submitted is processed, and the commit message of the commit message temporary storage area is subjected to persistence processing before the target transaction is submitted.
H. the commit message of the commit message store is sent to the commit message middleware after the target transaction commits.
As shown in FIG. 3, the buffers of the target transaction and the sub-transaction are independent of each other, and commit messages are sent in a consistent manner along with the respective transaction lifecycles.
FIG. 4 is a timing diagram of a successful commit of a target transaction and a failed commit of a sub-transaction according to a method for sending commit messages corresponding to a transaction according to an embodiment of the present invention.
A. the sub-transaction is abnormal after sending the commit message, and the data corresponding to the sub-transaction is rolled back.
B. the commit message buffer of the sub-transaction is cleared when rolling back, at which time the commit message of the sub-transaction is not sent or persisted.
C. The target transaction is submitted normally, and the submitted message sent by the target transaction can be subjected to normal persistence and sent to the submitted message middleware, so that the consistency with the service data can be maintained.
FIG. 5 is a timing diagram of a case where a target transaction commit fails and a sub-transaction commit is successful according to a method for sending commit messages corresponding to transactions according to an embodiment of the present invention.
A. The sub-transaction successfully submits the transaction, and when the transaction is submitted, actions of intercepting the actions before and after the transaction is submitted and performing the persistence of a submitted message temporary area and sending the submitted message to the submitted message middleware are executed.
B. The target transaction recovers after the sub-transaction is successful and recovers the target transaction commit message buffer data.
C. And after the subsequent processing of the target transaction is abnormal, the data corresponding to the target transaction rolls back, the data of the temporary storage area of the submitted message is cleared after the rolling back, the submitted message of the target transaction is not sent, and the data are consistent.
The method for sending the information corresponding to the transaction comprises the steps of determining a target transaction, configuring a corresponding first commit message for the target transaction, wherein the first commit message is used for notifying at least one service system that the target transaction is completed, performing persistence operation on the first commit message to store the first commit message into a local database, monitoring the life cycle of the target transaction, extracting the first commit message and sending the first commit message to a message middleware under the condition that the target transaction is determined to be completed, wherein the message middleware is used for receiving the first commit message and forwarding the first commit message to at least one service system corresponding to the target transaction, controlling data corresponding to the target transaction to perform data rollback operation under the condition that the target transaction is determined to be submitted to fail, deleting the first commit message corresponding to the target transaction in the local database based on the data rollback operation, and further achieving the effect that service operation and corresponding message keep consistent due to some reasons, namely that service operation and corresponding message fail and service operation are also fail to be sent successfully.
It should be noted that the steps illustrated in the flowcharts of the figures may be performed in a computer system such as a set of computer executable instructions, and that although a logical order is illustrated in the flowcharts, in some cases the steps illustrated or described may be performed in an order other than that illustrated herein.
The embodiment of the invention also provides a message sending device corresponding to the control transaction, and it is to be noted that the message sending device corresponding to the control transaction of the embodiment of the invention can be used for executing the message sending method corresponding to the transaction provided by the embodiment of the invention. The following describes a message sending device corresponding to a control transaction provided by an embodiment of the present invention.
Fig. 6 is a schematic diagram of a transmission apparatus for controlling a message corresponding to a transaction according to an embodiment of the present invention. As shown in fig. 6, the device comprises a configuration unit 601, a determination unit 603 and a message middleware, wherein the configuration unit determines a target transaction and configures a corresponding first commit message for the target transaction, the first commit message is used for notifying at least one service system that the target transaction is committed to be completed, the persistence unit 602 performs persistence operation on the first commit message to store the first commit message in a local database, the determination unit 603 monitors the life cycle of the target transaction and extracts the first commit message and sends the first commit message to the message middleware when the completion of the commit of the target transaction is determined, the message middleware is used for receiving the first commit message and forwarding the first commit message to at least one service system corresponding to the target transaction, and the deletion unit 604 controls data corresponding to the target transaction to perform data rollback operation when the commit failure of the target transaction is determined.
In an alternative example, the device further comprises a first scanning unit for periodically scanning the local database after the first commit message is extracted and sent to the message middleware under the condition that the life cycle of the target transaction is monitored and the completion of the commit of the target transaction is determined, and a first extracting unit for extracting the first commit message until the first commit message is successfully forwarded to the message middleware under the condition that the first commit information corresponding to the scanned target transaction is still stored in the local database.
In an alternative example, the device further comprises a second extraction unit for monitoring the life cycle of the target transaction and determining whether to start a sub-transaction corresponding to the target transaction before extracting the first commit message and sending the first commit message to the message middleware if the target transaction is determined to be submitted, a storage unit for configuring a second commit message corresponding to the sub-transaction and storing the second commit message to a message temporary storage area corresponding to the sub-transaction if the sub-transaction is determined to be started, wherein the sub-transaction is a data operation transaction based on the target transaction, the second commit message is used for representing the completion of the sub-transaction, a monitoring unit for monitoring the life cycle of the sub-transaction and persisting the second commit message to the local database when the interception action corresponding to the sub-transaction before the completion of the sub-transaction is acquired, and a third extraction unit for extracting the second commit message and forwarding the second commit message to the message middleware if the sub-transaction is determined to be submitted to be completed.
In an alternative example, the device further comprises a suspending unit, and in the case of determining to open the sub-transaction, the suspending unit configures a second commit message corresponding to the sub-transaction, and suspends the data corresponding to the target transaction and the first commit message before storing the second commit message in the message buffer corresponding to the sub-transaction.
In an alternative example, the device comprises a second scanning unit and a forwarding unit, wherein the second scanning unit is used for periodically scanning the local database after extracting a second commit message and forwarding the second commit message to the message middleware under the condition that the completion of the commit of the sub-transaction is determined, and the forwarding unit is used for extracting the second commit message and forwarding the second commit message to the message middleware under the condition that the second commit information corresponding to the scanned sub-transaction is still stored in the local database.
In an alternative example, the monitoring unit comprises a first determining subunit for determining whether the action before the target transaction is submitted and the action after the target transaction is submitted can be intercepted, and a second determining subunit for determining that the target transaction is submitted to be completed under the condition that the action before the target transaction is submitted and the action after the target transaction is intercepted.
The sending device of the information corresponding to the control transaction provided by the embodiment of the invention is used for determining the target transaction and configuring the corresponding first commit message for the target transaction, wherein the first commit message is used for notifying at least one service system that the target transaction is committed to completion, performing persistence operation on the first commit message to store the first commit message into a local database, monitoring the life cycle of the target transaction, extracting the first commit message and sending the first commit message to a message middleware under the condition that the target transaction is committed to completion, wherein the message middleware is used for receiving the first commit message and forwarding the first commit message to at least one service system corresponding to the target transaction, controlling data corresponding to the target transaction to perform data rollback operation under the condition that the target transaction is committed to failure, deleting the first commit message corresponding to the target transaction in the local database based on the data rollback operation, and further solving the problem that service data and corresponding messages in the related technology are inconsistent due to some reasons, namely that the service operation and the corresponding message are successful in synchronization are achieved, and the service operation message is also successful in sending effect is achieved.
The message sending device corresponding to the control transaction comprises a processor and a memory, wherein the configuration unit 601 and the like are stored in the memory as program units, and the processor executes the program units stored in the memory to realize corresponding functions.
The processor includes a kernel, and the kernel fetches the corresponding program unit from the memory. The kernel can be provided with one or more than one, and the problem that business data and corresponding messages in the related technology are inconsistent due to some reasons is solved by adjusting kernel parameters.
The memory may include volatile memory, random Access Memory (RAM), and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM), among other forms in computer readable media, the memory including at least one memory chip.
The embodiment of the invention provides a computer readable storage medium, on which a program is stored, which when executed by a processor, implements a method for sending a message corresponding to a transaction.
The embodiment of the invention provides a processor which is used for running a program, wherein the program runs to execute a message sending method corresponding to a transaction.
The embodiment of the invention provides equipment, which comprises a processor, a memory and a program which is stored on the memory and can run on the processor, wherein the processor is used for determining a target transaction and configuring a corresponding first commit message for the target transaction, the first commit message is used for notifying at least one business system that the target transaction is committed, performing persistence operation on the first commit message to store the first commit message into a local database, monitoring the life cycle of the target transaction, extracting the first commit message and sending the first commit message to a message middleware under the condition that the commit of the target transaction is determined to be completed, the message middleware is used for receiving the first commit message and forwarding the first commit message to at least one business system corresponding to the target transaction, and controlling data corresponding to the target transaction to perform data rollback operation under the condition that the commit of the target transaction is determined to fail, and deleting the first commit message corresponding to the target transaction in the local database based on the data rollback operation.
In an alternative example, after monitoring the life cycle of the target transaction and, if it is determined that the commit of the target transaction is complete, extracting the first commit message and sending the first commit message to the message middleware, the method further includes periodically scanning a local database, and, if the first commit information corresponding to the scanned target transaction is still stored in the local database, extracting the first commit message until the first commit message is successfully forwarded to the message middleware.
In an alternative example, the method further comprises the steps of determining whether to start a sub-transaction corresponding to the target transaction or not, configuring a second commit message corresponding to the sub-transaction and storing the second commit message in a message temporary area corresponding to the sub-transaction if the sub-transaction is determined to be started, wherein the sub-transaction is a data operation transaction based on the target transaction, the second commit message is used for representing the completion of the sub-transaction commit, monitoring the life cycle of the sub-transaction, and persisting the second commit message to a local database when an interception action corresponding to the sub-transaction before commit is acquired, and extracting the second commit message and forwarding the second commit message to the message middleware if the sub-transaction is determined to be completed.
In an alternative example, in the case that the sub-transaction is determined to be started, the method further comprises suspending the data corresponding to the target transaction and the first commit message before configuring the corresponding second commit message for the sub-transaction and storing the second commit message in the message buffer corresponding to the sub-transaction.
In an alternative example, after extracting the second commit message and forwarding to the message middleware in the event that the commit of the sub-transaction is determined to be complete, the method includes periodically scanning a local database, extracting the second commit message and forwarding the second commit message to the message middleware in the event that the second commit information corresponding to the sub-transaction is scanned to remain stored in the local database.
In an alternative example, the lifecycle of the target transaction is monitored and the completion of the target transaction commit is determined, including determining whether the actions before and after the target transaction commit can be intercepted, and determining that the target transaction commit is complete if the actions before and after the commit are intercepted.
In an alternative example, in the case that the sub-transaction commit failure is determined, the method comprises the steps of controlling data corresponding to the sub-transaction to perform data rollback operation, and deleting a second commit message corresponding to the sub-transaction in the local database based on the data rollback operation.
The device herein may be a server, PC, PAD, cell phone, etc.
The invention also provides a computer program product adapted to perform, when executed on a data processing device, a program initialized with method steps of determining a target transaction and configuring a corresponding first commit message for the target transaction, wherein the first commit message is used for notifying at least one business system that the target transaction has been committed, performing a persistence operation on the first commit message to store the first commit message in a local database, monitoring a lifecycle of the target transaction, and if it is determined that the target transaction has been committed, extracting the first commit message and sending the first commit message to a message middleware, wherein the message middleware is used for receiving the first commit message and forwarding the first commit message to at least one business system corresponding to the target transaction, and if it is determined that the target transaction has failed to commit, controlling data corresponding to the target transaction to perform a data rollback operation, deleting the first commit message corresponding to the target transaction in the local database based on the data rollback operation.
In an alternative example, after monitoring the life cycle of the target transaction and, if it is determined that the commit of the target transaction is complete, extracting the first commit message and sending the first commit message to the message middleware, the method further includes periodically scanning a local database, and, if the first commit information corresponding to the scanned target transaction is still stored in the local database, extracting the first commit message until the first commit message is successfully forwarded to the message middleware.
In an alternative example, the method further comprises the steps of determining whether to start a sub-transaction corresponding to the target transaction or not, configuring a second commit message corresponding to the sub-transaction and storing the second commit message in a message temporary area corresponding to the sub-transaction if the sub-transaction is determined to be started, wherein the sub-transaction is a data operation transaction based on the target transaction, the second commit message is used for representing the completion of the sub-transaction commit, monitoring the life cycle of the sub-transaction, and persisting the second commit message to a local database when an interception action corresponding to the sub-transaction before commit is acquired, and extracting the second commit message and forwarding the second commit message to the message middleware if the sub-transaction is determined to be completed.
In an alternative example, in the case that the sub-transaction is determined to be started, the method further comprises suspending the data corresponding to the target transaction and the first commit message before configuring the corresponding second commit message for the sub-transaction and storing the second commit message in the message buffer corresponding to the sub-transaction.
In an alternative example, after extracting the second commit message and forwarding to the message middleware in the event that the commit of the sub-transaction is determined to be complete, the method includes periodically scanning a local database, extracting the second commit message and forwarding the second commit message to the message middleware in the event that the second commit information corresponding to the sub-transaction is scanned to remain stored in the local database.
In an alternative example, the lifecycle of the target transaction is monitored and the completion of the target transaction commit is determined, including determining whether the actions before and after the target transaction commit can be intercepted, and determining that the target transaction commit is complete if the actions before and after the commit are intercepted.
In an alternative example, in the case that the sub-transaction commit failure is determined, the method comprises the steps of controlling data corresponding to the sub-transaction to perform data rollback operation, and deleting a second commit message corresponding to the sub-transaction in the local database based on the data rollback operation.
It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, etc., such as Read Only Memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises an element.
It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The foregoing is merely exemplary of the present invention and is not intended to limit the present invention. Various modifications and variations of the present invention will be apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. which come within the spirit and principles of the invention are to be included in the scope of the claims of the present invention.

Claims (8)

1. The method for sending the message corresponding to the transaction is characterized by comprising the following steps:
Determining a target transaction, and configuring a corresponding first commit message for the target transaction, wherein the first commit message is used for notifying at least one service system that the target transaction is committed to completion;
performing a persistence operation on the first commit message to store the first commit message to a local database;
Monitoring the life cycle of the target transaction, and under the condition that the completion of the target transaction commit is determined, extracting the first commit message and sending the first commit message to a message middleware, wherein the message middleware is used for receiving the first commit message and forwarding the first commit message to at least one service system corresponding to the target transaction;
Under the condition that the target transaction commit failure is determined, controlling the data corresponding to the target transaction to carry out data rollback operation, deleting the first commit message corresponding to the target transaction in the local database based on the data rollback operation,
After monitoring the lifecycle of the target transaction and upon determining that the commit of the target transaction is complete, extracting the first commit message and sending the first commit message to a message middleware, the method further includes periodically scanning the local database, extracting the first commit message until the first commit message is successfully forwarded to the message middleware while the first commit message corresponding to the target transaction is scanned to remain stored in the local database,
The method further comprises the steps of determining whether to start a sub-transaction corresponding to the target transaction or not, configuring a second commit message corresponding to the sub-transaction and storing the second commit message in a message temporary area corresponding to the sub-transaction when the sub-transaction is determined to be started, wherein the sub-transaction is a data operation transaction based on the target transaction, the second commit message is used for representing the completion of the sub-transaction commit, monitoring the life cycle of the sub-transaction, and persisting the second commit message to the local database when an interception action corresponding to the sub-transaction before the completion of the sub-transaction commit is acquired, and extracting the second commit message and forwarding the second commit message to the message middleware when the completion of the sub-transaction commit is determined.
2. The method of claim 1, wherein in the event that it is determined to open the sub-transaction, configuring a corresponding second commit message for the sub-transaction and storing the second commit message in a message store corresponding to the sub-transaction, the method further comprises:
and suspending the data corresponding to the target transaction and the first commit message.
3. The method of claim 1, wherein upon determining that the sub-transaction commit is complete, extracting the second commit message and forwarding to the message middleware, the method comprises:
periodically scanning the local database;
and under the condition that the second commit message corresponding to the sub-transaction is scanned to be still stored in the local database, extracting the second commit message and forwarding the second commit message to the message middleware.
4. The method of claim 1, wherein monitoring the lifecycle of the target transaction and determining that the target transaction commit is complete comprises:
determining whether an action before the target transaction is submitted and an action after the target transaction is submitted can be intercepted;
And determining that the target transaction is submitted to completion under the condition that the action before the submission and the action after the submission are intercepted.
5. The method of claim 1, wherein in the event that determination is made that the sub-transaction commit fails, the method comprises:
Controlling the data corresponding to the sub-transaction to perform data rollback operation;
And deleting the second commit message corresponding to the sub-transaction in the local database based on the data rollback operation.
6. A transmission apparatus for controlling a message corresponding to a transaction, comprising:
The configuration unit is used for determining a target transaction and configuring a corresponding first commit message for the target transaction, wherein the first commit message is used for notifying at least one service system that the target transaction is committed to completion;
A persistence unit that performs a persistence operation on the first commit message to store the first commit message to a local database;
A determining unit, configured to monitor a life cycle of the target transaction, and extract the first commit message and send the first commit message to a message middleware if it is determined that the target transaction is completed, where the message middleware is configured to receive the first commit message and forward the first commit message to at least one service system corresponding to the target transaction;
A deleting unit for controlling data corresponding to the target transaction to perform data rollback operation under the condition that the target transaction is determined to be submitted to fail, deleting the first commit message corresponding to the target transaction in the local database based on the data rollback operation,
The device also comprises a first scanning unit for periodically scanning the local database after the first commit message is extracted and sent to the message middleware under the condition that the life cycle of the target transaction is monitored and the completion of the commit of the target transaction is determined, a first extracting unit for extracting the first commit message until the first commit message is successfully forwarded to the message middleware under the condition that the first commit message corresponding to the target transaction is scanned and still stored in the local database,
The device further comprises a second extraction unit for detecting the life cycle of the target transaction and determining whether to start a sub-transaction corresponding to the target transaction before extracting the first commit message and sending the first commit message to a message middleware under the condition that the target transaction is determined to be submitted, a storage unit for configuring a second commit message corresponding to the sub-transaction and storing the second commit message to a message temporary area corresponding to the sub-transaction under the condition that the sub-transaction is determined to be started, wherein the sub-transaction is a data operation transaction based on the target transaction, the second commit message is used for representing the completion of the sub-transaction commit, a monitoring unit for monitoring the life cycle of the sub-transaction and persisting the second commit message to the local database when an interception action corresponding to the sub-transaction before the commit is acquired, and a third extraction unit for extracting the second commit message and forwarding the second commit message to the message middleware under the condition that the sub-transaction is determined to be completed.
7. A computer-readable storage medium, characterized in that the computer-readable storage medium comprises a stored program, wherein the program, when run, controls a device in which the computer-readable storage medium is located to execute the method for sending a message corresponding to a transaction according to any one of claims 1 to 5.
8. A processor, wherein the processor is configured to run a program, and wherein the program runs to perform the method for sending a message corresponding to a transaction according to any one of claims 1 to 5.
CN202111645363.7A 2021-12-29 2021-12-29 Method and device for sending message corresponding to transaction Active CN114281603B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111645363.7A CN114281603B (en) 2021-12-29 2021-12-29 Method and device for sending message corresponding to transaction

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111645363.7A CN114281603B (en) 2021-12-29 2021-12-29 Method and device for sending message corresponding to transaction

Publications (2)

Publication Number Publication Date
CN114281603A CN114281603A (en) 2022-04-05
CN114281603B true CN114281603B (en) 2025-09-23

Family

ID=80878319

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111645363.7A Active CN114281603B (en) 2021-12-29 2021-12-29 Method and device for sending message corresponding to transaction

Country Status (1)

Country Link
CN (1) CN114281603B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114510495B (en) * 2022-04-21 2022-07-08 北京安华金和科技有限公司 Database service data consistency processing method and system
CN117290125B (en) * 2023-09-04 2025-08-26 中电金信软件有限公司 Business processing method and device

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109408203A (en) * 2018-11-01 2019-03-01 无锡华云数据技术服务有限公司 A kind of implementation method, device, the computing system of queue message consistency
CN109684045A (en) * 2017-10-18 2019-04-26 阿里巴巴集团控股有限公司 Processing method, device and the electronic equipment of transaction message
CN113760924A (en) * 2020-10-28 2021-12-07 北京沃东天骏信息技术有限公司 Distributed transaction processing method and device

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8301706B2 (en) * 2009-06-15 2012-10-30 Microsoft Corporation Routing of pooled messages via an intermediary
CN111225012A (en) * 2018-11-27 2020-06-02 阿里巴巴集团控股有限公司 Transaction processing method, device and equipment
CN110502523A (en) * 2019-08-01 2019-11-26 广东浪潮大数据研究有限公司 Business datum storage method, device, server and computer readable storage medium
CN111381987A (en) * 2020-03-13 2020-07-07 北京金山云网络技术有限公司 Message processing method and device, electronic equipment and medium

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109684045A (en) * 2017-10-18 2019-04-26 阿里巴巴集团控股有限公司 Processing method, device and the electronic equipment of transaction message
CN109408203A (en) * 2018-11-01 2019-03-01 无锡华云数据技术服务有限公司 A kind of implementation method, device, the computing system of queue message consistency
CN113760924A (en) * 2020-10-28 2021-12-07 北京沃东天骏信息技术有限公司 Distributed transaction processing method and device

Also Published As

Publication number Publication date
CN114281603A (en) 2022-04-05

Similar Documents

Publication Publication Date Title
US9189348B2 (en) High availability database management system and database management method using same
CN109951331B (en) Method, apparatus and computing cluster for sending information
JP6557323B2 (en) Data storage in case of database failure
US10942823B2 (en) Transaction processing system, recovery subsystem and method for operating a recovery subsystem
US10509585B2 (en) Data synchronization method, apparatus, and system
CN112835688A (en) Distributed transaction processing method, device and storage medium
US10884623B2 (en) Method and apparatus for upgrading a distributed storage system
JP3822381B2 (en) Distributed database system failure recovery method
CN114281603B (en) Method and device for sending message corresponding to transaction
CN104156361B (en) A kind of method and system for realizing data syn-chronization
CN110019514B (en) Data synchronization method and device and electronic equipment
CN108833479B (en) Data synchronization method and device
US10831741B2 (en) Log-shipping data replication with early log record fetching
JPH10214199A (en) Process restart method and system for realizing process restart
CN113254425B (en) Method, apparatus, system, program and storage medium for database transaction retention
CN113934745A (en) Data synchronization processing method, electronic device and storage medium
CN105824846B (en) Data migration method and device
CN109710394A (en) Timing task processing system and method
US9553929B2 (en) Episodic coordination model for distributed applications
CN110532066A (en) A kind of realization method and system of transaction consistency
CN111880947A (en) Data transmission method and device
CN112434050B (en) Data synchronization method and device of power grid business processing system and business processing system
CN113886500A (en) A data processing method, device, server and storage medium
US9128903B2 (en) Computer system, active system computer, and standby system computer
CN117539957A (en) Data synchronization method, data center, data synchronization system and electronic equipment

Legal Events

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