A multi-channel access message forwarding method and device
Through parameterized configuration and message queue mechanism, the problem of high response time and system resource utilization in the distributed architecture is solved, the message sequence and retransmission mechanism are realized, and business consistency and system stability are improved.
Patent Information
- Application Number
- CN202011484464.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-16
- Publication Date
- 2024-12-20
- Estimated Expiration
- 2040-12-16
AI Technical Summary
When the existing distributed architecture handles calls across multiple services, the response time cannot be guaranteed, the system resource occupies high, and lacks query or automatic retry functions when the service provider processes messages unknown, resulting in data consistency and business. The process complexity is difficult to meet.
Create a message queue through parameterized configuration, including waiting queue, error queue and buffer queue, use scheduling tasks to obtain event messages and match forwarding parameters, adopt strong sequence guarantee mechanism and sending buffer mechanism, and dynamically adjust the sending quota to ensure message order and resend message order and resend mechanism.
It realizes automatic identification of business scenarios, reduces system coupling, improves the speed of new business launch, ensures transaction consistency and message order, reduces downstream system pressure, and provides a dynamically adjustable buffer mechanism to cope with complex scenarios.
Smart Images

Figure CN112579274B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer data processing, and in particular to a multi-channel access message forwarding method and device. Background Art
[0002] This section is intended to provide a background or context to embodiments of the invention that are recited in the claims. No description herein is admitted to be prior art by inclusion in this section.
[0003] With the development of society and economy, IT software systems inevitably need to be modularized to meet the growing business needs while ensuring maintainability. As the modules are split into smaller and smaller parts, the interactions between modules increase, the scenarios become more and more complex, and each module has corresponding logical processing, and the requirements for pre- and post-conditions are more stringent than before.
[0004] Overall, this call across multiple services involves multiple data sources and can be considered a special distributed transaction, but it has higher consistency requirements than distributed transactions. The business logic processing of each module is also very complex, and it is necessary to clearly obtain the results of the previous step before deciding on the subsequent business process. The current popular distributed architecture is basically designed with eventual consistency as the ultimate goal, which does not meet the requirement of consistency in every link.
[0005] A business involves multiple environments, and each link needs to process complex business logic. Different system implementation methods lead to different time consumption, caching and exception handling mechanisms. In order to ensure business continuity, the business transit system needs to be compatible with various complex and unpredictable scenarios, and needs to implement sequential forwarding, caching mechanism, and error retransmission mechanism.
[0006] In the IT practice of the banking industry, the importance of accounting data consistency often exceeds other non-functional features. Under the SOA architecture, the "store and forward" mechanism is currently widely used. This mechanism starts from the transaction initiator and, according to the business process, pushes messages to multiple services in different modules in turn by chaining. When the last message is pushed successfully, the entire business process is completed. If any message returns an unknown or failed result status after a certain period of time, in order to ensure the overall data consistency, it is necessary to initiate a reversal for each pushed message, regardless of whether the last execution was successful or not. The main process and execution order are as follows: Figure 2 shown.
[0007] Under this type of message synchronization call mechanism, the push message needs to synchronously wait for the receiving service to return the message processing result. Although the implementation is relatively simple and the execution order is guaranteed, its shortcomings are also obvious:
[0008] 1. When the synchronous waiting mechanism has a long call chain, the response time cannot be guaranteed.
[0009] 2. Synchronous waiting will occupy more system resources, resulting in the application system being unable to support high-concurrency scenarios.
[0010] In terms of data consistency, although the reversal mechanism provides a reverse cancellation function in the event of failure on one side, it does not provide a query or automatic retry function for situations where the result of message processing by the service party is unknown.
[0011] Therefore, how to provide a new solution that can solve the above technical problems is a technical problem that needs to be solved urgently in this field. Summary of the invention
[0012] The embodiment of the present invention provides a multi-channel access message forwarding method, which realizes a dynamic adjustment, message sequence control and cache retransmission mechanism through parameterized configuration to ensure normal downstream system business processing. The method includes:
[0013] Configure forwarding parameters;
[0014] Establish a message queue through platform scheduling tasks; the message queue includes: waiting queue, error queue, and buffer queue;
[0015] Use the scheduling task to obtain the event messages generated when executing local transactions;
[0016] Match the event message with the forwarding parameters. If the match is successful, put it into the waiting queue and buffer queue according to the service restrictions of the event message.
[0017] Read the event messages in the buffer queue through the message forwarding service, and use the strong order guarantee mechanism to configure the sending order for the event messages;
[0018] According to the sending buffer mechanism, event messages are sent to peripheral systems in the order of sending, and the sending quota is dynamically adjusted during the sending process;
[0019] When sending to the peripheral system fails, the event message is placed in the error queue.
[0020] The embodiment of the present invention also provides a multi-channel access message forwarding device, including:
[0021] Parameter configuration module, used to configure forwarding parameters;
[0022] The message queue establishment module is used to establish a message queue through the platform scheduling task; wherein the message queue includes: a waiting queue, an error queue, and a buffer queue;
[0023] An event message acquisition module is used to use a scheduling task to acquire event messages generated when executing local transactions;
[0024] A forwarding parameter matching module is used to match the event message with the forwarding parameter. After the match is successful, the event message is placed in the waiting queue and the buffer queue according to the service restrictions of the event message.
[0025] The sending order configuration module is used to read the event messages in the buffer queue through the message forwarding service and configure the sending order for the event messages using the strong order guarantee mechanism;
[0026] The event message forwarding module is used to send the event message to the peripheral system in the sending order according to the sending buffer mechanism, and dynamically adjust the sending quota during the sending process;
[0027] The error handling module is used to put the event message into the error queue when the sending to the peripheral system fails.
[0028] An embodiment of the present invention further provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned multi-channel access message forwarding method when executing the computer program.
[0029] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program for executing the above-mentioned multi-channel access message forwarding method.
[0030] A multi-channel access message forwarding method and device provided by an embodiment of the present invention includes: first configuring forwarding parameters; then establishing a message queue through a platform scheduling task; wherein the message queue includes: a waiting queue, an error queue, and a buffer queue; continuing to use the scheduling task to obtain event messages generated when executing local transactions; then matching the event message with the forwarding parameters, and after a successful match, placing them in the waiting queue and the buffer queue respectively according to the business restrictions of the event message; next, reading the event message in the buffer queue through the message forwarding service, and configuring the sending order for the event message using a strong order guarantee mechanism; next, sending the event message to the peripheral system in the sending order according to the sending buffer mechanism, and dynamically adjusting the sending quota during the sending process; finally, when the sending to the peripheral system fails, placing the event message in the error queue. The embodiment of the present invention implements a dynamically adjustable, message sequence control, and cache retransmission mechanism through parameterized configuration to ensure normal downstream system business processing; the main technical effects include:
[0031] 1. Through parameter configuration, business scenarios can be automatically identified, the coupling between the system's internal business code and message forwarding can be reduced, key elements of message business can be obtained, business expansion can be simple and convenient, the possibility of parallel development can be increased, the speed of new business launch can be improved, and the forwarding of multiple systems and multiple messages can be realized to ensure transaction consistency. During the forwarding process, business scenarios can be restored to meet the needs of downstream systems.
[0032] 2. Provide a strong order guarantee mechanism to ensure that application service execution messages are forwarded in a predetermined order, and that downstream message disorder is not caused by timeouts and other reasons, thereby reducing the complexity of downstream system services and ensuring that peripheral systems can still receive messages in a specific order when messages arrive out of order. At the same time, regardless of the order in which the confirmed messages arrive, they are guaranteed to be sent to the downstream in a predefined order according to the business needs of the downstream system.
[0033] 3. When messages are sent to downstream peripheral systems, a flow control mechanism is used. The message sending process is dynamically adjusted according to the sending quota. While ensuring the order, a dynamically adjustable buffer is provided for the peripheral system to ensure that the downstream does not suddenly receive a large number of messages, thereby reducing system pressure. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0035] Figure 1 The present invention is a schematic diagram of a multi-channel access message forwarding method according to an embodiment of the present invention.
[0036] Figure 2 It is a flow chart and execution sequence diagram of the "store and forward" mechanism in the prior art.
[0037] Figure 3 The present invention is a schematic diagram of a process of generating event messages when executing local transactions in a multi-channel access message forwarding method according to an embodiment of the present invention.
[0038] Figure 4 A schematic diagram of a computer device for running a multi-channel access message forwarding method implemented by the present invention.
[0039] Figure 5 The present invention is a schematic diagram of a multi-channel access message forwarding device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0040] To make the purpose, technical solution and advantages of the embodiments of the present invention more clear, the embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings. Here, the exemplary embodiments of the present invention and their descriptions are used to explain the present invention, but are not intended to limit the present invention.
[0041] Figure 1 FIG. 1 is a schematic diagram of a multi-channel access message forwarding method according to an embodiment of the present invention. Figure 1As shown, an embodiment of the present invention provides a multi-channel access message forwarding method, which realizes a dynamic adjustment, message sequence control and cache retransmission mechanism through parameterized configuration to ensure normal downstream system business processing. The method includes:
[0042] Step 101: Configure forwarding parameters;
[0043] Step 102: Establish a message queue through the platform scheduling task; wherein the message queue includes: a waiting queue, an error queue, and a buffer queue;
[0044] Step 103: Using the scheduling task to obtain the event message generated when executing the local transaction;
[0045] Step 104: Match the event message with the forwarding parameters, and after a successful match, put the event message into the waiting queue and the buffer queue according to the service restrictions of the event message;
[0046] Step 105: read the event message in the buffer queue through the message forwarding service, and configure the sending order for the event message using the strong order guarantee mechanism;
[0047] Step 106: Send the event message to the peripheral system in the sending order according to the sending buffer mechanism, and dynamically adjust the sending quota during the sending process;
[0048] Step 107: When the sending to the peripheral system fails, the event message is placed in an error queue.
[0049] A multi-channel access message forwarding method provided by an embodiment of the present invention includes: first configuring forwarding parameters; then establishing a message queue through a platform scheduling task; wherein the message queue includes: a waiting queue, an error queue, and a buffer queue; continuing to use the scheduling task to obtain event messages generated when executing local transactions; then matching the event message with the forwarding parameters, and after a successful match, placing them in the waiting queue and the buffer queue respectively according to the business restrictions of the event message; next, reading the event message in the buffer queue through the message forwarding service, and configuring the sending order for the event message using a strong order guarantee mechanism; next, sending the event message to the peripheral system in the sending order according to the sending buffer mechanism, and dynamically adjusting the sending quota during the sending process; finally, when the sending to the peripheral system fails, placing the event message in the error queue. The embodiment of the present invention implements a dynamically adjustable, message sequence control, and cache retransmission mechanism through parameterized configuration to ensure normal downstream system business processing; the main technical effects are:
[0050] 1. Through parameter configuration, business scenarios can be automatically identified, the coupling between the system's internal business code and message forwarding can be reduced, key elements of message business can be obtained, business expansion can be simple and convenient, the possibility of parallel development can be increased, the speed of new business launch can be improved, and the forwarding of multiple systems and multiple messages can be realized to ensure transaction consistency. During the forwarding process, business scenarios can be restored to meet the needs of downstream systems.
[0051] 2. Provide a strong order guarantee mechanism to ensure that application service execution messages are forwarded in a predetermined order, and that downstream message disorder is not caused by timeouts and other reasons, thereby reducing the complexity of downstream system services and ensuring that peripheral systems can still receive messages in a specific order when messages arrive out of order. At the same time, regardless of the order in which the confirmed messages arrive, they are guaranteed to be sent to the downstream in a predefined order according to the business needs of the downstream system.
[0052] 3. When messages are sent to downstream peripheral systems, a flow control mechanism is used. The message sending process is dynamically adjusted according to the sending quota. While ensuring the order, a dynamically adjustable buffer is provided for the peripheral system to ensure that the downstream does not suddenly receive a large number of messages, thereby reducing system pressure.
[0053] With the increase in business complexity and user scale, business needs are becoming more and more complex, involving more and more systems. Each system has different business processing logic, and the consistency requirements for things are higher than distributed. The reversal cost is very high, and a single system cannot be rolled back, so strong consistency is needed.
[0054] Today’s businesses cannot complete all business processing in a single link. The interactivity between systems is very strong. Sometimes a transaction requires 3 to 4 interactions, and there are also timing requirements. Strong consistency is required under the premise of ensuring the normal completion of the business. The interaction between systems is completed in the business processing logic. With more and more access channels and more and more complex business scenarios, the coupling between codes is very strong. To complete synchronous confirmation, fault-tolerant reissue, and ensure orderly transactions, sometimes modifying a little content will have a very large adjustment range. Especially for new access channels or completing a new business requirement, it is necessary to sort out and adjust all related business logic to ensure the normal completion of the business.
[0055] The present invention aims to establish a comprehensive scheduling platform, realize parameterized configuration, realize a dynamic adjustment, increase message sequence control, cache retransmission mechanism, and ensure normal downstream system business processing.
[0056] The main functions achieved by the present invention include:
[0057] 1. Under the premise of reducing code coupling, the function of parameterized configuration is realized to achieve global transaction consistency of data sharding / multiple data sources;
[0058] 2. Provide a message order guarantee mechanism. The platform completes the sequential processing of out-of-order messages, and the downstream can still read the messages in a specific order;
[0059] 3. Provide dynamically adjustable buffers for downstream consumption while ensuring order, to ensure that downstream does not suddenly receive a large number of messages.
[0060] When a multi-channel access message forwarding method provided by an embodiment of the present invention is specifically implemented, it may include: configuring forwarding parameters; establishing a message queue through a platform scheduling task; wherein the message queue includes: a waiting queue, an error queue, and a buffer queue; using the scheduling task to obtain the event message generated when executing a local transaction; matching the event message with the forwarding parameters, and after a successful match, placing the event message in the waiting queue and the buffer queue respectively according to the business restrictions of the event message; reading the event message in the buffer queue through a message forwarding service, and configuring the sending order for the event message using a strong order guarantee mechanism; sending the event message to the peripheral system in the sending order according to the sending buffer mechanism, and dynamically adjusting the sending quota during the sending process; when the sending to the peripheral system fails, placing the event message in the error queue.
[0061] In the normal business logic processing process, in addition to processing the business of this system, message forwarding logic processing also takes up a lot of time. The coupling between codes is becoming more and more tight. When adding new access channels or new business type forwarding requirements, the original business code needs to be modified, the modification cost is high, and the online time is long.
[0062] At the same time, due to the unreliability of the network and the difficulty in truly synchronizing the business processing capabilities of the downstream system, and the fact that the downstream has certain business dependencies on the order of messages, the order of messages that finally reach the downstream after traditional storage and forwarding and distributed multi-segment message aggregation cannot be guaranteed, which ultimately results in the order of messages sent to the downstream being unable to be guaranteed, leading to business failure.
[0063] The present invention establishes a set of parameterized configuration logic, configures forwarding parameters, and ensures the orderly arrival of messages through platform scheduling. It also adopts a sending quota mechanism to control the sending speed, and dynamically adjusts the quota to achieve a caching effect.
[0064] The embodiment of the present invention realizes the forwarding of multiple systems and multiple messages through parameter configuration under the premise of reducing the coupling of the internal code of the system, thereby ensuring the consistency of transactions; provides a message order guarantee mechanism to ensure that when the messages arrive out of order, the peripheral systems can still receive the messages in a specific order; while ensuring the order, a dynamically adjustable buffer is provided for the peripheral systems to ensure that the downstream does not suddenly receive a large number of messages, thereby reducing the system pressure.
[0065] When implementing a multi-channel access message forwarding method provided by an embodiment of the present invention, in one embodiment, the aforementioned configuration forwarding parameters include:
[0066] The service initiator, service type, service receiver and original service type are used as key elements to form parameters, which are configured as forwarding parameters.
[0067] In the embodiment, a parameterized configuration logic is established, and the service initiator, service type, service receiver, and original service type are used as key elements to form parameters, which are recorded as forwarding configuration information, decoupling message forwarding from the service processing logic, and message forwarding is completed by the platform scheduling task. The embodiment of the present invention automatically identifies the business scenario through parameter configuration, reduces the coupling between the internal business code of the system and message forwarding, obtains the key elements of the message service, makes business expansion simple and convenient, increases the possibility of parallel development, improves the speed of new business launch, realizes the forwarding of multiple systems and multiple messages, ensures transaction consistency, and can restore the business scenario during the forwarding process to meet the needs of downstream systems.
[0068] When specifically implementing a multi-channel access message forwarding method provided by an embodiment of the present invention, in one embodiment, the aforementioned establishment of a message queue through a scheduling task of the platform includes: the platform scheduling task establishes three queues, a waiting queue, an error queue, and a buffer queue, and each queue establishes a channel queue according to the accessed channel; the platform scheduling task is also used to obtain event messages.
[0069] Figure 3 FIG. 1 is a schematic diagram of a process of generating event messages when executing local transactions in a multi-channel access message forwarding method according to an embodiment of the present invention. Figure 3 As shown, when a multi-channel access message forwarding method provided by an embodiment of the present invention is specifically implemented, in one embodiment, the event message generated when the aforementioned local transaction is executed includes:
[0070] Step 301: When the local transaction is successfully executed, the generated event message is acquired by the scheduling task and placed into the message queue; wherein, the event message is persistent and supports repeated consumption;
[0071] Step 302: When the execution of the local transaction fails, no event message is generated.
[0072] In the embodiment, to ensure reliable event messages, at least two conditions need to be met:
[0073] 1) Persistence of the message itself: Event messages submitted to the message queue must be persisted and support repeated consumption. This feature can be provided by the message queue, such as Apache Kafka;
[0074] 2) Atomicity between local transactions and transaction events: If a local transaction is successfully executed, the corresponding event message must be obtained by the scheduling task and submitted to the message queue. Conversely, a local transaction that fails to execute must not push event messages. Specifically, the push is directly prevented by not generating event messages when the local transaction fails to execute.
[0075] When implementing a multi-channel access message forwarding method provided by an embodiment of the present invention, in one embodiment, the aforementioned event message is matched with a forwarding parameter, and after the match is successful, the event message is placed in a waiting queue and a buffer queue respectively according to the service restrictions of the event message, including:
[0076] Match the event message with the forwarding parameters. When the match is successful, schedule the forwarding process. When the business restrictions of the event message meet the forwarding logic but need to wait for the preceding message, calculate the HASH value of the event message, instantiate the HASH value, establish the event message index, put the event message into the waiting queue, and wait for the preceding message to arrive;
[0077] When the business restrictions of the event message meet the forwarding logic and there is a preceding message, the event message is placed in the buffer queue, and the waiting queue is checked to see if there is a subsequent message waiting to be sent. If so, the subsequent waiting message is taken out of the waiting queue and placed in the buffer queue.
[0078] In the embodiment, after the scheduling task obtains the event message, the event message is matched with the forwarding parameter. When the match fails, no peripheral system subscribes to the message, and the event message is set to be forwarded successfully;
[0079] When the match is successful, the forwarding process is scheduled. When the business restrictions of the event message meet the forwarding logic but need to wait for the preceding message, the HASH value of the event message is calculated, the HASH value is instantiated, the event message index is established, and the event message is put into the waiting queue to wait for the preceding information to arrive;
[0080] When the business restrictions of the event message meet the forwarding logic and there is a preceding message, the event message is placed in the buffer queue, and the waiting queue is checked to see if there is a subsequent message waiting to be sent. If so, the subsequent waiting message is taken out of the waiting queue and placed in the buffer queue.
[0081] Since transaction events need to go through multiple stages of processing and confirmation before they can be finally forwarded to the corresponding destination queue, coupled with the introduction of the timeout confirmation mechanism and the concurrency mechanism of the message queue itself, some events may not reach the destination queue in the original order. In some specific order-sensitive scenarios, out-of-order events will affect the correctness or success rate of subsequent processing logic. To solve the above problems, the embodiment of the present invention specially designs a strong order guarantee mechanism for event messages; when specifically implementing a multi-channel access message forwarding method provided by the embodiment of the present invention, in one embodiment, the aforementioned use of the strong order guarantee mechanism to configure the sending order for event messages includes:
[0082] Use the strong order guarantee mechanism to set a number key and a preceding transaction key for each event message and configure the sending order.
[0083] This mechanism will set a number key and a preceding transaction key for each event message. The current message can only be sent after the preceding message is sent successfully. The strong order guarantee is based on the order in which the transaction initiator sends the preparation phase messages. The aforementioned Key represents a sequence encoding for event messages. The strong order guarantee mechanism provided by the embodiment of the present invention can ensure that the application service execution messages are forwarded in a predetermined order, and that downstream message disorder is not caused due to timeouts and other reasons, thereby reducing the complexity of downstream system services and ensuring that the peripheral system can still receive messages in a specific order when messages arrive out of order; at the same time, regardless of the order in which the confirmation messages arrive, they are guaranteed to be sent to the downstream in a predefined order according to the business needs of the downstream system.
[0084] The cache queue stores messages that are available for sending to the downstream but have not yet been sent under each sequence chain. If a sequential search is performed from the beginning of the sequence chain downwards, once a message that has been confirmed is encountered, it is sent directly. If the sequence chain is long, a large number of messages will be sent in a short time, which may cause great pressure on downstream applications. In order to solve the above problem, a concept of a sending quota and a time period T is introduced, and the sending quota is dynamically adjusted during operation. When a multi-channel access message forwarding method provided by an embodiment of the present invention is specifically implemented, in one embodiment, the sending quota is dynamically adjusted during the aforementioned sending process, including:
[0085] The sending task runs regularly, and the initial sending quota is set to m=m i , the step quota is set to Δm, and the maximum quota is set to m max ;
[0086] The sending task is triggered, and the number of sends c and the task time t are recorded. If the task time t exceeds the time period T or the number of sends exceeds the set sending quota, the sending is stopped and the task execution status is checked.
[0087] If t is less than T, change the sending quota to m = c + Δm;
[0088] If c is less than m, change the sending quota to m = c - Δm;
[0089] If c<10, change the sending quota m=1;
[0090] If m<Δm / 2, change the sending quota to m=2m;
[0091] If the current sending quota t = t max , the sending quota will no longer be increased.
[0092] In the embodiment, a flow control mechanism is adopted when messages are sent to downstream peripheral systems, and the message sending process is dynamically adjusted according to the sending quota, while ensuring the order, providing a dynamically adjustable buffer for the peripheral system to ensure that the downstream does not suddenly receive a large number of messages, thereby reducing system pressure; within the maximum quota range, if the time consumed exceeds the current quota, the quota for the next batch of sending is increased, and if the time consumed does not exceed the current quota, the quota for the next batch of sending is reduced.
[0093] When event messages are sent to peripheral systems in the order of sending according to the sending buffer mechanism, if the sending is successful, the message is deleted, the next message is sent, and the sending limit is adjusted; if the timeout or response time is too long, the sending limit is adjusted; if it fails, the message is put into the error queue and the next message is sent.
[0094] When the forwarding peripheral system reports an error and the message fails to be sent to the peripheral system, the message is put into the error queue, the number of sending times is increased by 1, and when the maximum number is reached, the forwarding fails, the message is deleted, and the failure status is recorded.
[0095] A multi-channel access message forwarding method implemented by the present invention can achieve:
[0096] 1. Through parameterized configuration, the coupling of business codes is reduced, business expansion is simple and convenient, the possibility of parallel development is increased, and the speed of launching new businesses is improved.
[0097] 2. The message conversion platform provides a mandatory order guarantee mechanism to ensure that application service execution messages are forwarded in a predetermined order, and that downstream message disorder is not caused by timeouts and other reasons, thereby reducing the complexity of downstream system services.
[0098] 3. Message sending is dynamically adjusted based on the sending quota, which improves program execution efficiency without causing great pressure on the downstream.
[0099] Figure 4 A schematic diagram of a computer device for running a multi-channel access message forwarding method implemented by the present invention, such as Figure 4As shown, an embodiment of the present invention further provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned multi-channel access message forwarding method when executing the computer program.
[0100] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program for executing the above-mentioned multi-channel access message forwarding method.
[0101] The present invention also provides a multi-channel access message forwarding device, as described in the following embodiments. Since the principle of the device to solve the problem is similar to that of a multi-channel access message forwarding method, the implementation of the device can refer to the implementation of a multi-channel access message forwarding method, and the repeated parts will not be repeated.
[0102] Figure 5 FIG. 1 is a schematic diagram of a multi-channel access message forwarding device according to an embodiment of the present invention. Figure 5 As shown, the embodiment of the present invention further provides a multi-channel access message forwarding device, which may include:
[0103] Parameter configuration module 501, used to configure forwarding parameters;
[0104] The message queue establishment module 502 is used to establish a message queue through the platform scheduling task; wherein the message queue includes: a waiting queue, an error queue, and a buffer queue;
[0105] An event message acquisition module 503 is used to acquire event messages generated when executing local transactions by using a scheduling task;
[0106] Forwarding parameter matching module 504, used to match the event message with the forwarding parameter, and after the match is successful, put the event message into the waiting queue and the buffer queue according to the service restrictions of the event message;
[0107] The sending order configuration module 505 is used to read the event messages in the buffer queue through the message forwarding service and configure the sending order for the event messages using the strong order guarantee mechanism;
[0108] An event message forwarding module 506 is used to send the event message to the peripheral system in a sending order according to a sending buffer mechanism, and dynamically adjust the sending quota during the sending process;
[0109] The error handling module 507 is used to put the event message into an error queue when the sending to the peripheral system fails.
[0110] When implementing a multi-channel access message forwarding device provided by an embodiment of the present invention, in one embodiment, the aforementioned parameter configuration module is used to:
[0111] The service initiator, service type, service receiver and original service type are used as key elements to form parameters, which are configured as forwarding parameters.
[0112] When implementing a multi-channel access message forwarding device provided by an embodiment of the present invention, in one embodiment, the event message acquisition module acquires an event message generated when executing a local transaction, including:
[0113] When the local transaction is successfully executed, the generated event message is obtained by the scheduling task and placed in the message queue; the event message is persisted and supports repeated consumption;
[0114] When the execution of a local transaction fails, no event message is generated.
[0115] When implementing a multi-channel access message forwarding device provided by an embodiment of the present invention, in one embodiment, the forwarding parameter matching module is specifically used to:
[0116] Match the event message with the forwarding parameters. When the match is successful, schedule the forwarding process. When the business restrictions of the event message meet the forwarding logic but need to wait for the preceding message, calculate the HASH value of the event message, instantiate the HASH value, establish the event message index, put the event message into the waiting queue, and wait for the preceding message to arrive;
[0117] When the business restrictions of the event message meet the forwarding logic and there is a preceding message, the event message is placed in the buffer queue, and the waiting queue is checked to see if there is a subsequent message waiting to be sent. If so, the subsequent waiting message is taken out of the waiting queue and placed in the buffer queue.
[0118] When implementing a multi-channel access message forwarding device provided by an embodiment of the present invention, in one embodiment, the aforementioned sending sequence configuration module is specifically used to:
[0119] Use the strong order guarantee mechanism to set a number key and a preceding transaction key for each event message and configure the sending order.
[0120] When implementing a multi-channel access message forwarding device provided by an embodiment of the present invention, in one embodiment, the aforementioned event message forwarding module is specifically used to:
[0121] The sending task runs regularly, and the initial sending quota is set to m=m i , the step quota is set to Δm, and the maximum quota is set to m max ;
[0122] The sending task is triggered, and the number of sends c and the task time t are recorded. If the task time t exceeds the time period T or the number of sends exceeds the set sending quota, the sending is stopped and the task execution status is checked.
[0123] If t is less than T, change the sending quota to m = c + Δm;
[0124] If c is less than m, change the sending quota to m = c - Δm;
[0125] If c<10, change the sending quota m=1;
[0126] If m<Δm / 2, change the sending quota to m=2m;
[0127] If the current sending quota t = t max , the sending quota will no longer be increased.
[0128] The embodiment of the present invention automatically identifies business scenarios through parameter configuration, reduces the coupling between business codes and message forwarding, and the key elements of message business. The platform can restore business scenarios during forwarding to meet the needs of downstream systems. A message sequence guarantee mechanism is provided to ensure that messages are sent to the downstream in a predefined order regardless of the order in which they arrive, in accordance with the business needs of the downstream system. When a message is sent to the downstream, a flow control mechanism is used, and the process is limited by a sending quota. Within the maximum quota, if the time consumed exceeds the current quota, the quota for the next batch of sending is increased. If the time consumed does not exceed the current quota, the quota for the next batch of sending is reduced.
[0129] In summary, a multi-channel access message forwarding method and device provided by an embodiment of the present invention includes: first, configuring forwarding parameters; then establishing a message queue through a platform scheduling task; wherein the message queue includes: a waiting queue, an error queue, and a buffer queue; continuing to use the scheduling task to obtain event messages generated when executing local transactions; then matching the event message with the forwarding parameters, and after a successful match, placing them in the waiting queue and the buffer queue respectively according to the business restrictions of the event message; next, reading the event message in the buffer queue through the message forwarding service, and configuring the sending order for the event message using a strong order guarantee mechanism; next, sending the event message to the peripheral system in the sending order according to the sending buffer mechanism, and dynamically adjusting the sending quota during the sending process; finally, when the sending to the peripheral system fails, placing the event message in the error queue. The embodiment of the present invention implements a dynamically adjustable, message sequence control, and cache retransmission mechanism through parameterized configuration to ensure normal downstream system business processing; the main technical effects are:
[0130] 1. Through parameter configuration, business scenarios can be automatically identified, the coupling between the system's internal business code and message forwarding can be reduced, key elements of message business can be obtained, business expansion can be simple and convenient, the possibility of parallel development can be increased, the speed of new business launch can be improved, and the forwarding of multiple systems and multiple messages can be realized to ensure transaction consistency. During the forwarding process, business scenarios can be restored to meet the needs of downstream systems.
[0131] 2. Provide a strong order guarantee mechanism to ensure that application service execution messages are forwarded in a predetermined order, and that downstream message disorder is not caused by timeouts and other reasons, thereby reducing the complexity of downstream system services and ensuring that even if messages arrive out of order, the surrounding system can still receive messages in a specific order; at the same time, regardless of the order in which the confirmed messages arrive, they are guaranteed to be sent to the downstream in a predefined order according to the business needs of the downstream system.
[0132] 3. A flow control mechanism is used when messages are sent to downstream peripheral systems. The message sending process is dynamically adjusted according to the sending quota. While ensuring the order, a dynamically adjustable buffer is provided for the peripheral system to ensure that the downstream does not suddenly receive a large number of messages, thereby reducing system pressure. Within the maximum quota range, if the time consumed exceeds the current quota, the quota for the next batch of sending is increased; if the time consumed does not exceed the current quota, the quota for the next batch of sending is reduced.
[0133] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0134] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0135] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0136] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0137] The specific embodiments described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A multi-channel access message forwarding method, characterized in that: include: Configure forwarding parameters; Establish a message queue through platform scheduling tasks; the message queue includes: waiting queue, error queue, and buffer queue; Use the scheduling task to obtain the event messages generated when executing local transactions; Match the event message with the forwarding parameters. If the match is successful, put it into the waiting queue and buffer queue according to the service restrictions of the event message. Read the event messages in the buffer queue through the message forwarding service, and use the strong order guarantee mechanism to configure the sending order for the event messages; According to the sending buffer mechanism, event messages are sent to peripheral systems in the order of sending, and the sending quota is dynamically adjusted during the sending process; When sending to the peripheral system fails, the event message is placed in the error queue; Match the event message with the forwarding parameters. After the match is successful, put it into the waiting queue and the buffer queue respectively according to the business restrictions of the event message, including: match the event message with the forwarding parameters. When the match is successful, schedule the forwarding process. When the business restrictions of the event message meet the forwarding logic but need to wait for the preceding message, calculate the HASH value of the event message, instantiate the HASH value, establish the event message index, put the event message into the waiting queue, and wait for the preceding information to arrive; when the business restrictions of the event message meet the forwarding logic and there is a preceding message, put the event message into the buffer queue, and find out whether there is a subsequent message waiting to be sent in the waiting queue. If there is, take the subsequent waiting message out of the waiting queue and put it into the buffer queue.
2. The method according to claim 1, characterized in that Configure forwarding parameters, including: The service initiator, service type, service receiver and original service type are used as key elements to form parameters, which are configured as forwarding parameters.
3. The method according to claim 1, characterized in that Event messages are generated when executing local transactions, including: When the local transaction is successfully executed, the generated event message is obtained by the scheduling task and placed in the message queue; the event message is persisted and supports repeated consumption; When the execution of a local transaction fails, no event message is generated.
4. The method according to claim 1, characterized in that Use the strong order guarantee mechanism to configure the sending order of event messages, including: Use the strong order guarantee mechanism to set a number key and a preceding transaction key for each event message and configure the sending order.
5. The method according to claim 1, characterized in that Dynamically adjust the sending quota during the sending process, including: The sending task runs regularly, and the initial sending quota is set to m=m i , the step quota is set to Δm, and the maximum quota is set to m max ; The sending task is triggered, and the number of sends c and the task time t are recorded. If the task time t exceeds the time period T or the number of sends exceeds the set sending quota, the sending is stopped and the task execution status is checked. If t is less than T, change the sending quota to m = c + Δm; If c is less than m, change the sending quota to m = c - Δm; If c<10, change the sending quota m=1; If m<Δm / 2, change the sending quota to m=2m; If the current sending quota t = t max , the sending quota will no longer be increased.
6. A multi-channel access message forwarding device, characterized in that: include: Parameter configuration module, used to configure forwarding parameters; The message queue establishment module is used to establish a message queue through the platform scheduling task; wherein the message queue includes: a waiting queue, an error queue, and a buffer queue; An event message acquisition module is used to use a scheduling task to acquire event messages generated when executing local transactions; A forwarding parameter matching module is used to match the event message with the forwarding parameter. After the match is successful, the event message is placed in the waiting queue and the buffer queue according to the service restrictions of the event message. The sending order configuration module is used to read the event messages in the buffer queue through the message forwarding service and configure the sending order for the event messages using the strong order guarantee mechanism; The event message forwarding module is used to send the event message to the peripheral system in the sending order according to the sending buffer mechanism, and dynamically adjust the sending quota during the sending process; The error handling module is used to put the event message into the error queue when the message fails to be sent to the peripheral system; The forwarding parameter matching module is specifically used to: match the event message with the forwarding parameters. When the match is successful, the forwarding process is scheduled. When the business restrictions of the event message meet the forwarding logic but need to wait for the preceding message, the HASH value of the event message is calculated, the HASH value is instantiated, and the event message index is established. The event message is placed in the waiting queue and waits for the preceding information to arrive; when the business restrictions of the event message meet the forwarding logic and there is a preceding message, the event message is placed in the buffer queue, and it is checked whether there is a subsequent message waiting to be sent in the waiting queue. If so, the subsequent waiting message is taken out of the waiting queue and placed in the buffer queue.
7. The device according to claim 6, characterized in that Parameter configuration module, used to: The service initiator, service type, service receiver and original service type are used as key elements to form parameters, which are configured as forwarding parameters.
8. The device according to claim 6, characterized in that The event message acquisition module acquires event messages generated when executing local transactions, including: When the local transaction is successfully executed, the generated event message is obtained by the scheduling task and placed in the message queue; the event message is persisted and supports repeated consumption; When the execution of a local transaction fails, no event message is generated.
9. The device according to claim 6, characterized in that Sending sequence configuration module, specifically used for: Use the strong order guarantee mechanism to set a number key and a preceding transaction key for each event message and configure the sending order.
10. The device according to claim 6, characterized in that The event message forwarding module is specifically used for: The sending task runs regularly, and the initial sending quota is set to m=m i , the step quota is set to Δm, and the maximum quota is set to m max ; The sending task is triggered, and the number of sends c and the task time t are recorded. If the task time t exceeds the time period T or the number of sends exceeds the set sending quota, the sending is stopped and the task execution status is checked. If t is less than T, change the sending quota to m = c + Δm; If c is less than m, change the sending quota to m = c - Δm; If c<10, change the sending quota m=1; If m<Δm / 2, change the sending quota to m=2m; If the current sending quota t = t max , the sending quota will no longer be increased.
11. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 5 is implemented.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program for executing the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Method and device for sending data and related equipment
CN110071873A
Message event distribution method, distribution platform, system and server
CN111866191A
System and method for scheduling messages on a common channel
US5729540A
Method and apparatus for performing high-speed traffic shaping
US6904014B1
On-site analysis system with central processor and method of analysing
WO2003010624A2
