A method and system for converting asynchronous transactions to synchronous transactions based on message queues
Through the asynchronous transaction to synchronization method based on message queue, using thread notification and ActiveMQ message queue, the problem of poor real-time acquisition of asynchronous transaction results in the bank transaction system is solved, and efficient transaction response and resource utilization are achieved.
Patent Information
- Application Number
- CN202310021593.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-07
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2043-01-07
AI Technical Summary
The existing bank transaction system has poor real-time performance when obtaining asynchronous transaction results, and often queries through database polling, resulting in insufficient real-time performance at the business level.
An asynchronous transaction-to-synchronization method based on message queue is adopted. Through the thread notification mechanism between nodes nodeX and nodeY, ActiveMQ message queue is used for asynchronous message routing and response message delivery to avoid polling queries and realize active notification and data delivery.
It improves the real-time nature of transaction response, reduces database query frequency and operating system resource usage, and improves performance and query speed.
Smart Images

Figure CN115987917B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communications, and in particular to a method and system for converting asynchronous transactions to synchronous transactions based on message queues. Background Art
[0002] In a bank's transaction system, interaction with counterparties is handled through a front-end server. Taking the Rural Credit Union's front-end server as an example, our system sends a message to the front-end server via Transaction A. The front-end server forwards the message to the Rural Credit Union's central processing center, which then forwards it to the counterparty. The counterparty receives and processes the request message, and then sends a response message to its front-end server. Through the same forwarding method at the Rural Credit Union's central processing center, the response message is ultimately obtained by our system and processed in our Transaction B. Figure 1 shown.
[0003] For our transaction A, the synchronous transaction is completed when the request message is sent to our Rural Credit Union front-end system. The transaction result is then obtained and processed in our transaction B. Therefore, the entire request-response process is asynchronous. For transaction A, in order to respond synchronously to the transaction result, it is necessary to obtain the transaction result data from our transaction B through certain means.
[0004] The most common approach to retrieving asynchronous transaction B data from transaction A is to continuously poll the transaction log records in the database within transaction A for a certain number of times or for a certain period of time. As a result, the real-time performance of the above-mentioned existing technical solutions is poor at the business level. Summary of the Invention
[0005] To enhance the real-time performance of bank transaction systems, this application provides a method and system for converting asynchronous transactions to synchronous transactions based on message queues.
[0006] The asynchronous transaction to synchronous conversion method and system based on message queues provided in this application adopts the following technical solution:
[0007] A method for converting asynchronous transactions to synchronous transactions based on message queues, comprising:
[0008] The application cluster receives transaction requests through nodeX and generates transaction thread A, which then processes the transaction requests.
[0009] The transaction request message generated after processing is sent to our front-end machine through transaction thread A, and enters a waiting state after successful transmission.
[0010] After being forwarded by the forwarding mechanism where our front-end machine is located, the response message from the opponent's mechanism is received by our front-end machine.
[0011] The response message is obtained from our front-end machine through nodeY, and the asynchronous-to-synchronous conversion table is checked by the serial number on the associated transaction log.
[0012] Determine whether nodeX and nodeY are the same node, and then transmit the transaction result via thread notification based on the determination result.
[0013] By adopting the above technical solution, when a transaction is initiated, the transaction request is received by nodeX in the application cluster and processed by the transaction A thread, forming a request message that the front-end machine can send. This message is then forwarded to our front-end machine. Our front-end machine forwards the request message through a forwarding mechanism. The counterparty responds to the request message, generating a response message. Our front-end machine then receives the response message from the counterparty. At this point, nodeY retrieves the response message from our front-end machine and checks the asynchronous-to-synchronous conversion table using the serial number from the associated transaction log. Finally, it determines whether nodeX and nodeY are the same node, and based on this determination, transmits the transaction result via thread notification. This proactive notification method allows nodeX and nodeY to transmit transaction results via thread notification, and the asynchronous-to-synchronous conversion is completed in memory using thread notification, minimizing the need for polling to obtain transaction results and enabling the transmission of necessary notification data, thus improving performance.
[0014] Optionally, the step of receiving transaction requests and generating transaction thread A through node X in the application cluster, and processing transaction requests through transaction thread A, includes:
[0015] Connect each application node in the application cluster to the ActiveMQ message queue and then to the front-end machine. The application nodes include nodeX and nodeY.
[0016] ActiveMQ creates corresponding message queues based on the application nodes in the application cluster. The message queues include queue nodeX and queue nodeY. Each application node pushes messages to the corresponding message queue.
[0017] By adopting the above technical solution, ActiveMQ message queues can be created through the corresponding application nodes of the ActiveMQ message queue, and asynchronous messages in the application nodes can be routed to ensure that in the application cluster environment, the response processing transaction and the request sending transaction of the same transaction flow are on the same server node.
[0018] Optionally, the process of handling transaction requests through transaction thread A includes...
[0019] Determine if the card belongs to us through transaction thread A;
[0020] When the bank card in the transaction request is not our card, the transaction record of this transaction will be registered in the asynchronous-to-synchronous table of the database, and the application node that handles the request will be recorded as nodeX.
[0021] Send a transaction request message to the card issuer to request the card issuer to process the transaction.
[0022] By adopting the above technical solution, it is possible to determine whether the card in the transaction is our card. If it is not our card, the transaction record is registered in the asynchronous-to-synchronous table, and the record node is nodeX, so that the asynchronous-to-synchronous table can be called in the transaction between different bank cards.
[0023] Optionally, the step of sending the processed transaction request message to our front-end machine via transaction thread A, and entering the waiting state after successful transmission, further includes:
[0024] Set the waiting time to wake up transaction thread A according to requirements;
[0025] If the waiting time is exceeded, it means that waking up transaction thread A is a timeout wake-up.
[0026] By adopting the above technical solution, a waiting time is set to wake up the transaction A thread, so as to determine whether the transaction has failed based on whether the wake-up time exceeds the waiting time.
[0027] Optionally, the step of determining whether nodeX and nodeY are the same node, and transmitting the transaction result via thread notification based on the determination result, includes:
[0028] If the determination result is that nodeX and nodeY are the same node, then the response message is processed by the transaction B thread of nodeX or nodeY.
[0029] After processing is complete, the corresponding waiting thread of transaction A is awakened to transmit the transaction result to transaction A thread through thread notification.
[0030] By adopting the above technical solution, when the judgment result is that nodeX and nodeY are the same node, the response message is processed by the transaction B thread. It is also convenient to wake up the transaction A thread during the waiting time and to pass the transaction result to the transaction A thread, thereby increasing the speed of transaction result transmission.
[0031] Optionally, the step of determining whether nodeX and nodeY are the same node to transmit the transaction result via thread notification further includes:
[0032] When the determination result is that nodeX and nodeY are different nodes, nodeY will deliver the response message to the ActiveMQ message queue nodeX.
[0033] Listen to the queue nodeX via nodeX;
[0034] After receiving the response message in the queue nodeX, the response message is handed over to the response processing transaction B thread of nodeX for processing.
[0035] After processing is complete, the corresponding waiting thread of transaction A is awakened to pass the transaction result to transaction A through thread notification.
[0036] By adopting the above technical solution, when nodeX and nodeY are different nodes, nodeX and nodeY can communicate via ActiveMQ through thread notifications, enabling the transmission of response messages through ActiveMQ when the nodes are different, and increasing the speed of transaction result transmission.
[0037] Optionally, after determining whether nodeX and nodeY are the same node and transmitting the transaction result via thread notification based on the determination result, the process further includes:
[0038] Obtain the reason for the wake-up after transaction thread A is woken up;
[0039] When the wake-up reason is an active wake-up, the result passed to Transaction A thread through the thread passing method is the transaction result;
[0040] When the wake-up reason is a timeout wake-up, the latest transaction history is queried and the response result is based on the queried transaction history status.
[0041] By adopting the above technical solution, it is possible to determine the reason for waking up transaction thread A based on whether the waiting time has been exceeded.
[0042] Optionally, the query for the latest transaction history, with the response result based on the queried transaction history status, includes:
[0043] Query the latest transaction records and obtain the transaction status;
[0044] When the flow status is in an intermediate state, it means that the response result passed to transaction thread A is the transaction result;
[0045] When the flow state is non-intermediate, it means that the response result passed to transaction thread A is not necessarily the transaction result;
[0046] Errors in transaction results are processed during the reconciliation period.
[0047] By adopting the above technical solution, when the wake-up is a timeout wake-up, the transaction result is judged again based on whether the transaction flow is in an intermediate state, thereby increasing the accuracy of the judgment.
[0048] An asynchronous transaction to synchronous conversion system based on message queues includes:
[0049] The thread generation module is used to receive transaction requests through nodeX in the application cluster and generate transaction thread A, and to process transaction requests through transaction thread A.
[0050] The sending module is used to send the processed transaction request message to our front-end machine through the transaction A thread, and enters a waiting state after successful sending.
[0051] The receiving module is used to receive response messages from the opposing agency after forwarding through the forwarding mechanism where our front-end machine is located;
[0052] The response message acquisition module is used to acquire response messages in our front-end machine through nodeY and check the asynchronous-to-synchronous conversion table through the serial number on the associated transaction flow.
[0053] The judgment and transmission module is used to determine whether nodeX and nodeY are the same node, and to transmit the transaction result through thread notification based on the judgment result.
[0054] By adopting the above technical solution, when a transaction is initiated, the transaction result is transmitted between nodeX and nodeY through thread notification by actively notifying them. The asynchronous to synchronous operation is completed in memory by using thread notification, which avoids the use of polling to obtain transaction results as much as possible, and can carry the data that needs to be notified, thereby increasing performance.
[0055] In summary, this application includes at least one of the following beneficial technical effects:
[0056] 1. High real-time performance: Through proactive notification, waiting transactions can receive transaction response results in the first instance;
[0057] 2. Reduced database queries: The database will only be queried once to obtain the latest transaction status after a timeout.
[0058] 3. Reduced operating system resource consumption: Due to the thread waiting and waking mechanism, the operating system does not need to frequently schedule the currently waiting thread during the entire asynchronous to synchronous process, thus reducing the number of thread context switches. Attached Figure Description
[0059] Figure 1This is a flowchart of one implementation of an asynchronous transaction to synchronous conversion method based on a message queue according to an embodiment of this application;
[0060] Figure 2 This is a flowchart of one implementation of an asynchronous transaction to synchronous conversion method based on a message queue according to an embodiment of this application;
[0061] Figure 3 This is a flowchart of one implementation of an asynchronous transaction to synchronous conversion method based on a message queue according to an embodiment of this application;
[0062] Figure 4 This is a flowchart of one implementation of an asynchronous transaction to synchronous conversion method based on a message queue according to an embodiment of this application;
[0063] Figure 5 This is a flowchart of one implementation of an asynchronous transaction to synchronous conversion method based on a message queue according to an embodiment of this application;
[0064] Figure 6 This is a flowchart of one implementation of an asynchronous transaction to synchronous conversion method based on a message queue according to an embodiment of this application;
[0065] Figure 7 This is a flowchart of one implementation of an asynchronous transaction to synchronous conversion method based on a message queue according to an embodiment of this application;
[0066] Figure 8 This is a flowchart of one implementation of an asynchronous transaction to synchronous conversion method based on a message queue according to an embodiment of this application;
[0067] Figure 9 This is a structural block diagram of one embodiment of an asynchronous transaction to synchronous system based on a message queue, according to an embodiment of this application.
[0068] Figure 10 This is a connection diagram of different nodes in one embodiment of an asynchronous transaction to synchronous system based on a message queue according to an embodiment of this application. Detailed Implementation
[0069] The present application is further described in detail below with reference to the accompanying drawings.
[0070] To enhance the real-time performance of bank transaction systems, this application provides a method and system for converting asynchronous transactions to synchronous transactions based on message queues.
[0071] This application discloses an asynchronous transaction to synchronous conversion method based on message queues, referring to... Figure 1 ,include:
[0072] S110. Receive transaction requests through nodeX in the application cluster and generate transaction thread A, and process transaction requests through transaction thread A.
[0073] In this embodiment, the transaction request is mainly a deduction request, that is, a deduction that occurs when a consumption or other behavior is performed. The source channels of the transaction request include Internet channels, traditional POS machine channels, and ATM channels. In this embodiment, after a transaction request is initiated from the source, the nodeX in the application cluster receives the transaction request and generates a transaction thread A for the transaction request. The transaction request is processed by the transaction thread A. The transaction thread A runs in the server's memory to increase processing speed. The transaction A in the transaction thread A refers to a specific transaction in the consumption or refund process, enabling timely processing of transactions from memory and increasing processing speed.
[0074] S120. The transaction request message generated after processing is sent to our front-end machine through the transaction A thread, and enters the waiting state after successful transmission.
[0075] In financial systems, a front-end server is a communication application, specifically a front-end communication program, which is an intermediary transaction device based on message exchange. When different card-issuing banks communicate with each other, they all need to be forwarded through the People's Bank of China's (PBOC) front-end server. Therefore, the PBOC sets up message exchange services between two communicating banks, including request and response messages. The server with the front-end communication program installed is called the front-end server. The front-end server is used to forward bank request messages to the PBOC, or to receive request and response messages from the PBOC and forward them to the bank's internal server. Functionally, the front-end server can be seen as a server set up by the PBOC to route data between other banks. When transaction thread A sends a transaction request message to our front-end server, to reduce system load, transaction thread A enters a waiting state. Transaction thread A in the waiting state occupies less memory.
[0076] S130. After being forwarded by the forwarding agency where our front-end machine is located, the response message from the adversary agency is received by our front-end machine.
[0077] In this process, after being forwarded by the forwarding agency where our front-end machine is located, the response message from the counterparty institution is received by our front-end machine. The counterparty institution is the card-issuing bank used by the user that is different from the current bank. After receiving the message forwarded by our front-end machine, the counterparty institution sends a response message through its front-end machine, and our front-end machine receives the response message from the counterparty institution.
[0078] S140. Obtain the response message in our front-end machine through nodeY, and check the asynchronous-to-synchronous conversion table through the serial number on the associated transaction flow;
[0079] S150. Determine whether nodeX and nodeY are the same node, and transmit the transaction result via thread notification based on the determination result.
[0080] In this context, nodeY represents the node in our front-end server that receives the counterparty's response message. The asynchronous-to-synchronous conversion table refers to a table in the database used to register asynchronous-to-synchronous conversion information. This serves as evidence; when the asynchronous message (response message) returns, looking up the asynchronous-to-synchronous conversion table allows us to determine if the bank card used in the transaction is not from our bank. For example, when making a cross-bank withdrawal, such as using an Agricultural Bank of China (ABC) card at an Industrial and Commercial Bank of China (ICBC) POS terminal, this transaction information is first sent to ICBC's server. After ICBC's server detects that the card used in the transaction does not belong to ICBC, it notifies ABC via a request message through the front-end server that the issuing bank for the deduction is ABC. Therefore, before the withdrawal, it's crucial to ensure that this transaction is recorded in the asynchronous-to-synchronous conversion table. Therefore, by checking the asynchronous-to-synchronous conversion table using the serial number on the associated transaction log, it is determined whether nodeX and nodeY are the same node. When nodeX and nodeY are the same thread, it means that the bank for this transaction is the same bank in the asynchronous-to-synchronous conversion table; when nodeX and nodeY are not the same node, it means that the two banks for this transaction are different banks, and the transaction result is transmitted through thread notification.
[0081] Traditional methods involve polling a database, where data is retrieved once per query cycle. This traditional approach involves network communication, which is significantly slower than the memory-based communication used in this application (by orders of magnitude, sometimes millions of times slower). Therefore, this application significantly increases query speed. Secondly, by reducing database queries, this application lowers storage resource usage. Finally, since polling involves scheduling tasks by the computer or server, increasing CPU consumption, this application utilizes operating system thread calls, thus reducing CPU consumption.
[0082] Reference Figure 2 Before step S110, the ActiveMQ message queue needs to be applied to facilitate the routing of asynchronous messages. Therefore, the transaction request is received by nodeX in the application cluster and a transaction thread A is generated. Before the transaction request is processed by the transaction thread A, the following steps are included:
[0083] S210. Connect each application node in the application cluster to the ActiveMQ message queue and to the front-end machine. The application nodes include nodes nodeX and nodeY.
[0084] Message queues (MQ) are a communication method between applications. They are commonly used in asynchronous processing flows within business processes—processes that are time-consuming and do not require immediate results—making them suitable for asynchronous processing in the communication domain of financial systems. ActiveMQ message queues enable point-to-point sending and possess message persistence, ensuring message security. Even after an application recovers from a crash, it can still retrieve unconsumed response messages, thus achieving eventual consistency in transaction results and reducing the number of errors during subsequent end-of-day reconciliation. Therefore, message reliability is guaranteed. In this embodiment, ActiveMQ is used as the message queue; in other embodiments, a suitable message queue product will be selected based on the actual application.
[0085] Leveraging the features of the message middleware ActiveMQ, the node receiving the response message can be any node in the application cluster, and the response message can be correctly forwarded to the same node where the requesting transaction is being processed. The forwarding process is stateless, which means that the throughput of transaction data can be increased by horizontally scaling nodes.
[0086] Furthermore, due to the high transaction frequency of banks, an application cluster approach is used to deploy the bank's computers and servers. Individual computers within the application cluster are collectively referred to as nodes, connected via local area networks (LANs) or similar methods. In this embodiment, for ease of understanding, the nodes are designated as nodeX and nodeY, representing different servers. In practice, refer to... Figure 10 As shown, the nodes in the application cluster are configured based on the server, such as application node node1, node2, and node3. ActiveMQ message queues connect to each node in the application cluster (three in the diagram: node1, node2, and node3), and also connect to the front-end server via ActiveMQ message queues.
[0087] S220. ActiveMQ creates corresponding message queues based on the application nodes in the application cluster. The message queues include queue nodeX and queue nodeY. Each application node pushes messages to the corresponding message queue.
[0088] In this embodiment, ActiveMQ message queues create corresponding internal queues based on the number of nodes in the application cluster. For example, in this embodiment, if the nodes in the application cluster are node1, node2, and node3, these three nodes correspond to queues node1, node2, and node3 in the internal queues, respectively. In this embodiment, all application nodes can push messages to the ActiveMQ message queues, but each application node can only consume its corresponding ActiveMQ message queue. For example, nodeX can only consume its corresponding queue nodeX, and nodeY can only consume its corresponding queue nodeY.
[0089] Reference Figure 3 Transaction requests are processed through transaction thread A, including...
[0090] S310. Determine whether the card belongs to our side through transaction thread A.
[0091] S320. When the bank card in the transaction request is not our card, the transaction record of this transaction will be registered in the asynchronous-to-synchronous table of the database, and the application node that handles the request will be recorded as nodeX.
[0092] S330: Send a transaction request message to the issuing bank to request the issuing bank to conduct the transaction.
[0093] Since the issuing bank involved in the transaction may be a card from a bank other than ours, when the bank card is not our card, the transaction record is registered. In this embodiment, it is registered in an asynchronous-to-synchronous table, and the application node for request processing is recorded as nodeX, where nodeX is the computer node processing this transaction. When the bank card is our card, the transaction data and transaction record are directly synchronized in our application cluster server, without the need for asynchronous operations.
[0094] Reference Figure 4 The transaction request message generated after processing is sent to our front-end machine via transaction thread A, and before entering the waiting state after successful transmission, it also includes:
[0095] S410. Set the waiting time for waking up transaction thread A according to requirements;
[0096] S420. If the waiting time is exceeded, it means that the wake-up of transaction thread A is a timeout wake-up.
[0097] In this embodiment, the waiting time for transaction thread A is set as the upper limit of the waiting time. When the upper limit of the waiting time is exceeded, it is called a timeout wake-up, that is, the time to wake up transaction thread A exceeds the waiting time.
[0098] Reference Figure 5 Determine whether nodeX and nodeY are the same node, and transmit the transaction result via thread notification based on the determination result, including:
[0099] S510. When the judgment result is that nodeX and nodeY are the same node, the response message shall be processed by the transaction B thread of nodeX or nodeY.
[0100] S520. After processing is complete, wake up the corresponding waiting thread of transaction A thread to pass the transaction result to transaction A thread through thread notification.
[0101] In this embodiment, when nodeX and nodeY are the same node, the response message can be directly processed by the transaction B thread, and the processed transaction result can be passed to the transaction A thread in the same node, which facilitates thread transmission and increases the transmission speed.
[0102] Reference Figure 6 In the previous embodiment, nodeX and nodeY are the same node. In other embodiments, nodeX and nodeY may not be the same node. Therefore, determining whether nodeX and nodeY are the same node to transmit the transaction result via thread notification further includes:
[0103] S610. When the judgment result is that nodeX and nodeY are different nodes, nodeY will deliver the response message to the ActiveMQ message queue nodeX.
[0104] S620, Listen to queue nodeX through nodeX;
[0105] S630. After receiving the response message in the queue nodeX, the response message is handed over to the response processing transaction B thread of nodeX for processing.
[0106] S640. After processing is complete, wake up the corresponding waiting thread of transaction A thread to pass the transaction result to transaction A thread through thread notification.
[0107] When nodeX and nodeY are different nodes, nodeY delivers the response message to queue nodeX in the ActiveMQ message queue. NodeX listens to queue nodeX to determine whether it has received the response message delivered by nodeY. After queue nodeX receives the response message from nodeY, nodeX will also listen to the response message received by queue nodeX, enabling the transmission of response messages between different nodes through the message queue.
[0108] Reference Figure 7 In the previous embodiment, after transaction thread A is awakened, the transaction result is passed to transaction thread A. The transaction result also needs to be determined based on the reason for awakening transaction thread A. Therefore, after determining whether nodeX and nodeY are the same node and passing the transaction result via thread notification based on the determination result, the process further includes:
[0109] S710. Obtain the wake-up reason after transaction thread A is woken up.
[0110] S720. When the wake-up reason is an active wake-up, the result passed to Transaction A thread through the thread passing method is the transaction result.
[0111] S730. When the wake-up reason is a timeout wake-up, the latest transaction record is queried and the response result is based on the queried transaction record status.
[0112] When the wake-up reason is an active wake-up, it means that nodeX and nodeY are the same node. Since the communication speed between threads is faster when they are on the same node, the transaction A thread can be woken up within the waiting time. When the wake-up reason is a timeout wake-up, it means that the transaction volume is large or that nodeX and nodeY are different nodes that need to pass the response result through the ActiveMQ message queue. In this case, the waiting time will be longer, and it is necessary to query the latest transaction flow to use the query flow status as the response result.
[0113] Reference Figure 8 The system queries the latest transaction history and provides the response based on the status of the retrieved transaction history, including:
[0114] S810: Query the latest transaction records and obtain the transaction status;
[0115] S820. When the flow state is in an intermediate state, it means that the response result passed to the transaction A thread is the transaction result;
[0116] S830. When the flow state is non-intermediate, it means that the response result passed to the transaction A thread is not necessarily the transaction result.
[0117] S840. Error handling of transaction results during the reconciliation period.
[0118] Generally, when transaction thread A sends a transaction request to the front-end server, the transaction status will be updated from "registered" to "sent." "Sent" is an intermediate state, while a non-intermediate state indicates that the transaction has been determined to be either successful or failed. Therefore, after querying the latest transaction flow, the transaction status is obtained. When the transaction status is in an intermediate state, it means that the response result sent to transaction thread A is the transaction result. When the transaction status is in a non-intermediate state, it means that the response result sent to transaction thread A is not necessarily the transaction result. In this case, error handling of the transaction result needs to be performed within the reconciliation period. Specifically, this is done through the bank's reconciliation system for end-of-day reconciliation and other error handling.
[0119] This application discloses an asynchronous transaction to synchronous conversion system based on a message queue, comprising:
[0120] The thread generation module is used to receive transaction requests through nodeX in the application cluster and generate transaction thread A, and to process transaction requests through transaction thread A.
[0121] The sending module is used to send the processed transaction request message to our front-end machine through the transaction A thread, and enters a waiting state after successful sending.
[0122] The receiving module is used to receive response messages from the opposing agency after forwarding through the forwarding mechanism where our front-end machine is located;
[0123] The response message acquisition module is used to acquire response messages in our front-end machine through nodeY and check the asynchronous-to-synchronous conversion table through the serial number on the associated transaction flow.
[0124] The judgment and transmission module is used to determine whether nodeX and nodeY are the same node, and to transmit the transaction result through thread notification based on the judgment result.
[0125] The implementation principle of the asynchronous-to-synchronous transaction conversion method based on message queues in this application embodiment is as follows: When a transaction is initiated, the transaction request is received by nodeX in the application cluster, and the transaction request is processed by the transaction A thread, forming a request message that the front-end machine can send. This request message is then sent to our front-end machine. Our front-end machine forwards the request message through a forwarding mechanism. The counterparty responds to the request message, generating a response message. Our front-end machine then receives the response message from the counterparty. At this point, nodeY retrieves the response message on our front-end machine and checks the asynchronous-to-synchronous conversion table using the serial number on the associated transaction log. Finally, it determines whether nodeX and nodeY are the same node, and based on the determination result, transmits the transaction result via thread notification. By actively notifying nodeX and nodeY, the transaction result is transmitted between them via thread notification. The asynchronous-to-synchronous conversion operation is completed in memory using thread notification, minimizing the need for polling to obtain transaction results and enabling the transmission of necessary notification data, thus improving performance.
[0126] The above are all preferred embodiments of the present application, and are not intended to limit the scope of protection of the present application. Therefore, any equivalent changes made based on the structure, shape, and principle of the present application should be included in the scope of protection of the present application.
Claims
1. A method for converting asynchronous transactions to synchronous transactions based on a message queue, characterized in that: include: Receive transaction requests through node nodeX in the application cluster and generate transaction A thread, and process transaction requests through transaction A thread; The generated transaction request message is sent to our front-end processor through transaction A thread, and enters the waiting state after successful sending; After being forwarded by the forwarding organization where our front-end is located, the response message from the opponent's organization is received through our front-end; Get the response message in our front-end through node nodeY, and check the asynchronous-to-synchronous table through the serial number on the associated transaction flow; Determine whether node nodeX and node nodeY are the same node, and transmit the transaction result in thread notification based on the determination result; wherein, when the determination result is that node nodeX and node nodeY are the same node, the transaction B thread of node nodeX or node nodeY processes the response message; After the processing is completed, the corresponding waiting thread of transaction A thread is awakened to pass the transaction result to transaction A thread through thread notification; when the judgment result is that node nodeX and node nodeY are different nodes, node nodeY delivers the response message to queue nodeX of the ActiveMQ message queue; Monitor queue nodeX through node nodeX; After queue nodeX receives the response message, it is handed over to the response processing transaction B thread of node nodeX to process the response message; After the processing is completed, the corresponding waiting thread of transaction A thread is woken up to pass the transaction result to transaction A thread through thread notification.
2. The method for converting asynchronous transactions to synchronous transactions based on a message queue according to claim 1, characterized in that: The process of receiving the transaction request through the node nodeX in the application cluster and generating a transaction A thread, and processing the transaction request through the transaction A thread includes: Connect each application node of the application cluster to the ActiveMQ message queue and to the front-end processor. The application nodes include nodeX and nodeY. ActiveMQ creates corresponding message queues according to the application nodes in the application cluster. The message queues include queue nodeX and queue nodeY. Each application node pushes messages to the corresponding message queue.
3. The method for converting asynchronous transactions to synchronous transactions based on a message queue according to claim 1, characterized in that: The transaction request is processed by the transaction A thread, including Determine whether it is our card through transaction A thread; When the transaction bank card in the transaction request is not our card, the transaction flow of this transaction will be registered in the asynchronous-to-synchronous table of the database, and the application node for request processing will be recorded as node nodeX; Send a transaction request message to the issuing bank to request the issuing bank to conduct the transaction.
4. The method for converting asynchronous transactions to synchronous transactions based on a message queue according to claim 1, characterized in that: The transaction request message generated after processing is sent to our front-end through the transaction A thread, and before entering the waiting state after the sending is successful, it also includes: Set the waiting time for waking up transaction A thread according to requirements; When the waiting time is exceeded, it means that the wake-up of the transaction A thread is a timed-out wake-up.
5. A method for converting asynchronous transactions to synchronous transactions based on a message queue according to any one of claims 1 and 4, characterized in that: After determining whether node nodeX and node nodeY are the same node and transmitting the transaction result in a thread notification manner based on the determination result, the following further comprises: After the transaction A thread is awakened, the wake-up reason is obtained; When the wakeup reason is active wakeup, the result transmitted to the transaction A thread through thread transmission is the transaction result; When the wake-up reason is a timeout, the latest transaction flow is queried and the queried flow status is used as the response result.
6. The method for converting asynchronous transactions to synchronous transactions based on a message queue according to claim 5, characterized in that: The query of the latest transaction flow takes the queried flow status as a response result, including: Query the latest transaction flow to obtain the flow status; When the pipeline state is in the intermediate state, it means that the response result transmitted to the transaction A thread is the transaction result; When the pipeline state is non-intermediate, it means that the response result transmitted to the transaction A thread is not necessarily the transaction result; Perform error handling on transaction results during the reconciliation cycle.
7. A message queue-based asynchronous transaction to synchronous system, characterized in that: The method according to any one of claims 1 to 6 comprises: The thread generation module is used to receive the transaction request through the node nodeX in the application cluster and generate the transaction A thread, and process the transaction request through the transaction A thread; The sending module is used to send the generated transaction request message to our front-end through the transaction A thread, and enter the waiting state after the sending is successful; The receiving module is used to receive the response message from the opponent's organization through our front-end after forwarding it through the forwarding organization where our front-end is located; The response message acquisition module is used to obtain the response message in our front-end through node nodeY, and check the asynchronous-to-synchronous table through the serial number on the associated transaction flow; A judgment and transmission module is used to judge whether node nodeX and node nodeY are the same node, so as to transmit the transaction result in a thread notification manner based on the judgment result; wherein, when the judgment result is that node nodeX and node nodeY are the same node, the transaction B thread of node nodeX or node nodeY processes the response message; After the processing is completed, the corresponding waiting thread of transaction A thread is awakened to pass the transaction result to transaction A thread through thread notification; when the judgment result is that node nodeX and node nodeY are different nodes, node nodeY delivers the response message to queue nodeX of the ActiveMQ message queue; Monitor queue nodeX through node nodeX; After queue nodeX receives the response message, it is handed over to the response processing transaction B thread of node nodeX to process the response message; After the processing is completed, the corresponding waiting thread of transaction A thread is woken up to pass the transaction result to transaction A thread through thread notification.
