Message sending system, method, device, electronic device and storage medium
By introducing a database and retransmission mechanism between the message processing device and the producer device, the problem of possible loss of messages when transmitted to MQ is solved, and reliable transmission of messages and high system reliability are achieved.
Patent Information
- Application Number
- CN202210957450.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-10
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2042-08-10
AI Technical Summary
When a producer device sends a message to a message queue (MQ), network jitter or MQ service exceptions can cause messages to be lost.
The message to be sent from the database is retrieved by the message processing device, and confirms in the producer device whether the message is successfully sent to the MQ. If the sending fails, the message processing device re-fetches and sends the message until it is successful.
Ensure that messages can be sent successfully to MQ, effectively prevent messages from being lost, and improve system reliability.
Smart Images

Figure CN115237637B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of message middleware, and in particular to a message sending system, method, device, electronic device and storage medium. Background Art
[0002] In the related art, when a producer device sends a message generated by a transaction to a consumer device, the producer device may first send the message to a message queue (MQ), and then the MQ transmits the message to the consumer device.
[0003] However, if network jitter or MQ service exception occurs when the producer device sends the message to MQ, the message may not be sent to MQ, resulting in message loss.
[0004] Therefore, how to prevent message loss is a technical problem that needs to be solved urgently. Summary of the invention
[0005] The present application provides a message sending system, method, device, electronic device and storage medium for effectively preventing message loss.
[0006] In a first aspect, the present application provides a message sending system, the system comprising:
[0007] A message processing device, used for acquiring each message to be sent from a database with a pre-established connection, and sending each message to a producer device;
[0008] The producer device is used to receive each message and send each message to the message queue MQ;
[0009] The message processing device is further used to obtain status information of whether each message is successfully sent to the MQ; for a target message whose status information is that the message fails to be sent, re-determine the target message as a message included in the message to be sent, obtain the target message from the database again, and send the target message to the producer device again;
[0010] The producer device is further configured to receive the target message and send the target message to the MQ.
[0011] In a possible implementation, the message processing device is further used to obtain, for any transaction, a message generated during the transaction; when it is determined that the set sending conditions are met, save the message into the database, and determine the message as a message to be sent.
[0012] In a possible implementation, the message processing device is specifically configured to determine whether the transaction is successful, and if so, determine that a set sending condition is satisfied.
[0013] In a possible implementation, the message processing device is further used to identify the type of the message generated during the transaction, and if the type of the message is within a pre-saved target type, save the message into the database.
[0014] In one possible implementation, the message processing device is specifically used to obtain, for each message sent to the producer device, the time when the producer device sends the message to the MQ and the failure time period when the sending failure occurs; if the time is within the failure time period, the status information of the message is determined as a sending failure.
[0015] In a possible implementation manner, the producer device is further used to generate status information of whether each message is successfully sent to the MQ;
[0016] The message processing device is specifically used to obtain the status information generated by the producer device.
[0017] In a possible implementation, the message processing device is further configured to determine, with respect to the target message, whether the transaction to which the target message belongs is within a set target transaction set; if so, re-determine the target message as a message included in the message to be sent.
[0018] In a second aspect, the present application provides a message sending method, the method comprising:
[0019] Obtain each message to be sent from a database with a pre-established connection, and send each message to a producer device, so that the producer device sends each message to a message queue MQ;
[0020] Obtain status information of whether each message is successfully sent to the MQ; for the target message whose status information is failure to send, re-determine the target message as a message included in the message to be sent, obtain the target message from the database again, and send the target message to the producer device again, so that the producer device sends the target message to the MQ.
[0021] In a possible implementation manner, before acquiring each message to be sent from a database with a pre-established connection, the method further includes:
[0022] For any transaction, a message generated during the transaction is obtained; when it is determined that a set sending condition is met, the message is saved in the database, and the message is determined as a message to be sent.
[0023] In a possible implementation manner, determining that the set sending condition is satisfied includes:
[0024] Determine whether the transaction is successful, and if so, determine whether the set sending conditions are met.
[0025] In a possible implementation manner, after acquiring the message generated during the transaction, and before saving the message in the database when it is determined that the set sending condition is met, the method further includes:
[0026] For the message generated during the transaction, the type of the message is identified. If the type of the message is in the pre-saved target type, the subsequent step of saving the message in the database is performed when it is determined that the set sending conditions are met.
[0027] In a possible implementation manner, the status information of whether each message is successfully sent to the MQ is determined in the following manner:
[0028] For each message sent to the producer device, obtain the time when the producer device sends the message to the MQ and the failure time period when the sending failure occurs;
[0029] If the time is within the failure time period, the status information of the message is determined as sending failure.
[0030] In a possible implementation manner, after obtaining the status information of whether each message is successfully sent to the MQ, before re-determining the target message as a message included in the message to be sent for the target message whose status information is that the message fails to be sent, the method further includes:
[0031] For the target message, it is determined whether the transaction to which the target message belongs is in a set target transaction set. If so, the target message is re-determined as a message included in the message to be sent.
[0032] In a third aspect, the present application provides a message sending method, the method comprising:
[0033] Obtain each message to be sent from a pre-established connection database, and send each message to a message queue MQ;
[0034] Obtain status information of whether each message is successfully sent to the MQ; for a target message whose status information is failure to send, re-determine the target message as a message included in the message to be sent, obtain the target message from the database again, and send the target message to the MQ again.
[0035] In a fourth aspect, the present application provides a message sending device, the device comprising:
[0036] A first acquisition module is used to acquire each message to be sent from a database with a pre-established connection, and send each message to a producer device, so that the producer device sends each message to a message queue MQ;
[0037] The second acquisition module is used to obtain the status information of whether each message is successfully sent to the MQ; for the target message whose status information is failure to send, the target message is re-determined as a message included in the message to be sent, the target message is acquired from the database again, and the target message is sent to the producer device again, so that the producer device sends the target message to the MQ.
[0038] In a possible implementation, the device further includes:
[0039] The determination module is used to obtain the message generated by any transaction during the transaction process; when it is determined that the set sending condition is met, the message is saved in the database and the message is determined as a message to be sent.
[0040] In a possible implementation, the determination module is specifically configured to determine whether the transaction is successful, and if so, determine that the set sending condition is met.
[0041] In a possible implementation, the determination module is further used to identify the type of the message generated during the transaction. If the type of the message is within a pre-saved target type, the message is saved in the database when it is determined that the set sending conditions are met.
[0042] In a possible implementation manner, the second acquisition module is specifically configured to acquire, for each message sent to the producer device, a time when the producer device sends the message to the MQ, and a failure time period during which a sending failure occurs;
[0043] If the time is within the failure time period, the status information of the message is determined as sending failure.
[0044] In a possible implementation, the second acquisition module is further configured to determine, with respect to the target message, whether the transaction to which the target message belongs is within a set target transaction set; if so, re-determine the target message as a message included in the message to be sent.
[0045] In a fifth aspect, the present application provides a message sending device, the device comprising:
[0046] A third acquisition module is used to acquire each message to be sent from a database with a pre-established connection, and send each message to a message queue MQ;
[0047] The fourth acquisition module is used to obtain the status information of whether each message is successfully sent to the MQ; for the target message whose status information is failure to send, the target message is re-determined as the message included in the message to be sent, the target message is obtained from the database again, and the target message is sent to the MQ again.
[0048] In a sixth aspect, the present application provides an electronic device, which includes at least a processor and a memory, and the processor is used to implement the steps of any of the message sending methods described above when executing a computer program stored in the memory.
[0049] In a seventh aspect, the present application provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of any of the message sending methods described above.
[0050] In an eighth aspect, the present application provides a computer program product, comprising: a computer program code, which, when executed on a computer, enables the computer to execute the steps of any of the above-described message sending methods.
[0051] Since the message processing device of the present application can obtain each message to be sent from a database with a pre-established connection, and send each message to the producer device; the producer device can send each message to MQ separately; for each message, the message processing device can also obtain the status information of whether the message is successfully sent to MQ. For the target message whose status information is failure to send, the target message can be re-determined as the message included in the message to be sent, and the target message can be obtained from the database again, and the target message can be sent to the producer device again. The producer device can send the target message to MQ again, thereby ensuring that the message can be successfully sent to MQ and effectively preventing message loss. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] In order to more clearly illustrate the implementation methods in the embodiments of the present application or the related technologies, the following is a brief introduction to the drawings required for use in the embodiments or the related technology descriptions. Obviously, the drawings described below are some embodiments of the present application, and a person skilled in the art can also obtain other drawings based on these drawings.
[0053] Figure 1A A schematic diagram of a message sending system provided by some embodiments is shown;
[0054] Figure 1B A schematic diagram of a first message sending process provided by some embodiments is shown;
[0055] Figure 2 A schematic diagram of a second message sending process provided by some embodiments is shown;
[0056] Figure 3 A schematic diagram of a third message sending process provided by some embodiments is shown;
[0057] Figure 4 A schematic diagram of a fourth message sending process provided by some embodiments is shown;
[0058] Figure 5A A schematic diagram of a fifth message sending process provided by some embodiments is shown;
[0059] Figure 5B A sixth message sending process schematic diagram provided by some embodiments is shown;
[0060] Figure 6 A seventh message sending process schematic diagram provided by some embodiments is shown;
[0061] Figure 7 A schematic diagram of a first message sending device provided by some embodiments is shown;
[0062] Figure 8 A schematic diagram of the structure of a first electronic device provided by some embodiments is shown;
[0063] Fig. 9 A schematic diagram of an eighth message sending process provided by some embodiments is shown;
[0064] Fig.10 A schematic diagram of a second message sending device provided in some embodiments is shown;
[0065] Fig.11 A schematic diagram of the structure of a second electronic device provided by some embodiments is shown. DETAILED DESCRIPTION
[0066] In order to make the purpose, technical solutions and advantages of this application clearer, this application will be further described in detail below in conjunction with the accompanying drawings. Obviously, the embodiments described in this application are only part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0067] It should be noted that the brief description of terms in this application is only for the convenience of understanding the embodiments described below, and is not intended to limit the embodiments of this application. Unless otherwise specified, these terms should be understood according to their common and usual meanings.
[0068] The terms "first", "second", "third", etc. in the specification and claims of this application and the above drawings are used to distinguish similar or similar objects or entities, and do not necessarily mean to limit a specific order or sequence, unless otherwise noted. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances.
[0069] The terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover but not exclude inclusion, for example, a product or device comprising a list of components is not necessarily limited to all the components expressly listed but may include other components not expressly listed or inherent to such product or device.
[0070] The term "module" refers to any known or later developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and / or software code that is capable of performing the functions associated with that element.
[0071] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.
[0072] The following is a brief introduction to the design concept of the embodiment of the present application:
[0073] In the related art, when the producer device sends a message generated by a transaction to the consumer device, the message can be sent to the MQ first, and then the MQ passes the message to the consumer device, and the consumer device processes the message. Among them, the message can be sent by using an asynchronous message sending method. For example, after the producer device sends the message to the MQ, it is not necessary to wait in real time for the consumer device to process the message. However, for asynchronous messages, if the producer device sends the message to the MQ, network jitter or MQ service abnormality may occur when the producer device sends the message to the MQ, the message may not be sent to the MQ, and the message may be lost. Therefore, how to prevent the loss of messages is a technical problem that needs to be solved urgently. In view of this, in order to solve the technical problem that the producer device may lose the message when sending the message to the MQ in the related art, the embodiment of the present application proposes a message sending system, method, device, electronic device and storage medium. The message sending system, method, device, electronic device and storage medium provided in the embodiment of the present application are introduced below.
[0074] Embodiment 1:
[0075] All implementation methods of the embodiments of this application comply with the relevant provisions of national laws and regulations regarding the acquisition, storage, use, and processing of data.
[0076] Figure 1A A schematic diagram of a message sending system provided by some embodiments is shown, such as Figure 1A As shown, the system includes:
[0077] The message processing device 11 is used to obtain each message to be sent from a database with a pre-established connection, and send each message to the producer device 12;
[0078] The producer device 12 is used to receive each message and send each message to the message queue MQ;
[0079] The message processing device 11 is also used to obtain status information of whether each message is successfully sent to the MQ; for a target message whose status information is that the message fails to be sent, the target message is re-determined as a message included in the message to be sent, the target message is obtained from the database again, and the target message is sent to the producer device 12 again;
[0080] The producer device 12 is further configured to receive the target message and send the target message to the MQ.
[0081] In a possible implementation, the message sending system may include a message processing device 11, a producer device 12, a message queue (MQ), and a consumer device, etc. Since this application is mainly intended to solve the technical problem that messages may be lost when producer devices send messages to MQ in the related art, the message queue and the consumer device will not be described in detail here, and the message processing device and the producer device will be mainly introduced.
[0082] In a possible implementation, for any transaction, the message processing device 11 can obtain the message generated by the transaction during the transaction process. Optionally, in order to effectively prevent the loss of the message, the message processing device 11 can save the message to a database with a pre-established connection when it is determined that the set sending condition is met, that is, the message is persisted in the database. In a possible implementation, in order to avoid that when the message generated by the transaction during the transaction process is sent to the database in real time, in case the transaction fails and the transaction is rolled back, the message that has been sent to MQ, etc. may not be able to be rolled back, and data inconsistency may occur at this time. In order to ensure data consistency, when it is determined that the transaction is successful, the message generated by the transaction during the transaction process can be sent to the database, so that the message can be sent to MQ to ensure data consistency. Optionally, the message processing device 11 can know the real-time status of the transaction, and can determine whether the current status of the transaction is a successful transaction. When it is identified that the current status of the transaction is a successful transaction, it can be considered that the set sending condition is met, the message can be saved in the database, and the message can be determined as a message included in the message to be sent.
[0083] In a possible implementation, in order to ensure that when the transaction is successful, the messages generated by the transaction during the transaction process are saved to the database to ensure data consistency, the transaction and the saving of the messages generated by the transaction during the transaction process to the database can be configured as the same transaction, for example, configured as the same database transaction. After being configured as the same transaction, the execution order between the transaction and the saving of the messages generated by the transaction during the transaction process to the database is usually that after determining that the transaction is successful, the step of saving the messages generated by the transaction during the transaction process to the database is executed. Compared with configuring the transaction and the saving of the messages generated by the transaction during the transaction process to the database as two independent transactions, which may lead to data inconsistency, the present application configures the transaction and the saving of the messages generated by the transaction during the transaction process to the database as the same transaction to ensure data consistency.
[0084] In a possible implementation, the message processing device 11 may obtain each message to be sent from a pre-established database, and send each obtained message to the producer device 12. After receiving each message sent by the message processing device 11, the producer device 12 may send each message to a message queue (MQ) respectively.
[0085] In a possible implementation, after the producer device 12 sends the message to MQ, in order to prevent the message from being lost, for each message, the message processing device 11 can obtain the status information of whether the message is successfully sent to MQ. The manner in which the message processing device 11 obtains the status information of whether the message is successfully sent to MQ will be introduced later and will not be described here. Optionally, for any message, if the message has been successfully sent to MQ, the status information of the message may be successfully sent, and the status of the message in the database may be updated to successfully sent. If the message is not successfully sent to MQ, the status information of the message may be failed to send, and the status of the message in the database may be updated to failed to send.
[0086] In one possible implementation, in order to prevent message loss, for a target message that fails to be sent (for the convenience of description, the message that is not successfully sent to MQ, i.e., fails to be sent, is referred to as a target message), the target message can be re-determined as a message included in the message to be sent, the target message can be obtained from the database again, and the target message can be sent to the producer device 12 again. After the producer device 12 receives the target message, it can send the target message to MQ again, thereby effectively preventing message loss and effectively ensuring that the producer device 12 can successfully send the message to MQ.
[0087] It is understandable that if the producer device 12 fails to send the target message to MQ again, the status information of the target message is still sending failure, and the steps of determining the target message as the message included in the message to be sent again, obtaining the target message from the database again, sending the target message to the producer device 12 again, and the producer device 12 receiving the target message, and sending the target message to MQ again can be repeated until the message is successfully sent to MQ. It is understandable that if the message (target message) is successfully sent to MQ, the status information of the message can be updated to sending success, and the steps of determining it as the target message and the message to be sent can no longer be performed.
[0088] For ease of understanding, the message sending process provided by this application is described below through a specific embodiment. Figure 1B A schematic diagram of a first message sending process provided by some embodiments is shown, such as Figure 1BAs shown, the process includes the following steps:
[0089] S101 : The message processing device 11 obtains each message to be sent from a database with a pre-established connection, and sends each message to be sent to the producer device 12 .
[0090] S102: The producer device 12 receives each message to be sent, and sends each message to a message queue (MQ).
[0091] S103: For each message, the message processing device 11 obtains status information of whether the message is successfully sent to the MQ; for the target message whose status information is failure to send, the target message is re-determined as the message included in the message to be sent, the target message is obtained from the database again, and the target message is sent to the producer device 12 again.
[0092] S104: The producer device 12 receives the target message and sends the target message to the MQ.
[0093] For ease of understanding, the message sending process provided by this application is described below through a specific embodiment. Figure 2 A schematic diagram of a second message sending process provided by some embodiments is shown, such as Figure 2 As shown, the process includes the following steps:
[0094] S201: For any transaction, the message processing device 11 obtains a message generated during the transaction, and when it is determined that the transaction is successful, saves the message into a database and determines the message as a message to be sent.
[0095] Optionally, the status information of the message in the database may be configured as "not yet sent".
[0096] S202: The message processing device 11 obtains each message to be sent from a database with a pre-established connection, and sends each message to be sent to the producer device 12.
[0097] S203: The producer device 12 receives each message and sends each message to a message queue (MQ) respectively.
[0098] S204: For each message, the message processing device 11 obtains the status information of whether the message is successfully sent to the MQ. For a message whose status information indicates that the message is successfully sent, step S205 is executed; for a target message whose status information indicates that the message is unsuccessfully sent, step S206 is executed.
[0099] S205: The message processing device 11 updates the status information of the message in the database to “successfully sent”, and no longer determines the message as a message included in the messages to be sent.
[0100] S206: The message processing device 11 updates the status information of the target message in the database to "failed to send", re-determines the target message as the message included in the message to be sent, obtains the target message from the database again, and sends the target message again to the producer device 12. The producer device 12 receives the target message and sends the target message to the MQ again.
[0101] It is understandable that after step S206, step S204 can be repeated, which will not be described in detail here. In addition, it is understandable that the message to be sent obtained by the message processing device 11 each time can include a message with status information of "failed to send" and can also include the information of "not yet sent" involved in S201, which will not be described in detail here.
[0102] Since the message processing device 11 of the present application can obtain each message to be sent from a database with a pre-established connection, and send each message to the producer device 12; the producer device 12 can send each message to MQ separately; for each message, the message processing device 11 can also obtain the status information of whether the message is successfully sent to MQ. For the target message whose status information is failure to send, the target message can be re-determined as the message included in the message to be sent, and the target message can be obtained from the database again, and the target message can be sent to the producer device 12 again. The producer device 12 can send the target message to MQ again, thereby ensuring that the message can be successfully sent to MQ and effectively preventing message loss.
[0103] In one possible implementation, taking into account that messages usually cannot be successfully sent to MQ if network jitter or MQ service anomalies occur, in order to quickly and flexibly determine the status information of whether each message is successfully sent to MQ, the message processing device 11 can determine the time period when network jitter or MQ service anomalies occur as the failure time period when the sending failure occurs. At the same time, for each message sent to the producer device 12, the message processing device 11 can obtain the time when the producer device 12 sends the message to MQ. If the time when the producer device 12 sends the message to MQ is within the failure time period, it can be considered that the message has not been successfully sent to MQ, and the status information of the message can be determined as a sending failure.
[0104] For ease of understanding, the message sending process provided by this application is described below through a specific embodiment. Figure 3 A schematic diagram of a third message sending process provided by some embodiments is shown, such as Figure 3 As shown, the process includes the following steps:
[0105] S301: For any transaction, the message processing device 11 obtains a message generated during the transaction, and when it is determined that the transaction is successful, saves the message into a database and determines the message as a message to be sent.
[0106] S302: The message processing device 11 obtains each message to be sent from a database with a pre-established connection, and sends each message to be sent to the producer device 12.
[0107] S303: The producer device 12 receives each message and sends each message to a message queue (MQ) respectively.
[0108] S304: For each message, the time when the producer device 12 sends the message to MQ and the failure time period when the sending failure occurs are obtained. If the time when the producer device 12 sends the message to MQ is within the failure time period, the status information of the message is determined as a sending failure, the target message is re-determined as the message included in the message to be sent, and the target message is obtained from the database again, and the target message is sent to the producer device 12 again. The producer device 12 receives the target message and sends the target message to MQ again.
[0109] In addition, in a possible implementation, for each message, after the producer device 12 sends the message to MQ, it can know whether the message is successfully sent to MQ, and generate status information of whether the message is successfully sent to MQ. If the message is successfully sent to MQ, the status information corresponding to the message may be sending success. If the message is not successfully sent to MQ, the status information of the message may be sending failure. For each message, the message processing device 11 can obtain the status information corresponding to the message generated by the producer device 12, so as to know whether the message is successfully sent to MQ. If it is identified that one or some messages are not successfully sent to MQ, the message can be used as the target message, and the target message can be re-determined as the message included in the message to be sent, and the target message can be obtained from the database again, and the target message can be sent to the producer device 12 again, so that the producer device 12 can send the target message to MQ again, so as to effectively prevent the loss of messages.
[0110] In a possible implementation, considering that some messages may not be very important, even if the message is lost, it may not cause negative effects such as data inconsistency. In order to reduce the pressure on the database, for the messages generated during the transaction, the message processing device 11 can identify the type of the message. If the type of the message is in the pre-saved target type, it can be considered that the message is relatively important and needs to be saved in the database to prevent the message from being lost. Otherwise, if the type of the message is not in the pre-saved target type, it can be considered that the message is not very important, and the message may not be saved in the database. The message can be sent directly to the producer device 12, and the producer device 12 directly sends the message to the MQ. Among them, the present application does not specifically limit the type of message and the target type, etc., and can be flexibly set according to demand. For example, the type of message can be an organizational change, etc.
[0111] For ease of understanding, the message sending process provided by this application is described below through a specific embodiment. Figure 4 A schematic diagram of a fourth message sending process provided by some embodiments is shown, such as Figure 4 As shown, the process includes the following steps:
[0112] S401: For any transaction, the message processing device 11 obtains the message generated during the transaction and identifies the type of the message. If the type of the message is in the pre-saved target type, when it is determined that the transaction is successful, the message is saved in the database and the message is determined as a message to be sent.
[0113] S402: The message processing device 11 obtains each message to be sent from a database with a pre-established connection, and sends each message to be sent to the producer device 12.
[0114] S403: The producer device 12 receives each message and sends each message to a message queue (MQ) respectively.
[0115] S404: For each message, the message processing device 11 obtains the status information of whether each message is successfully sent to the MQ; for the target message whose status information is failure to send, the target message is re-determined as the message included in the message to be sent, the target message is obtained from the database again, and the target message is sent to the producer device 12 again.
[0116] S405: The producer device 12 receives the target message and sends the target message to the MQ.
[0117] In one possible implementation, in order to quickly and flexibly determine the message that needs to be resent from the target message that failed to be sent, for the target message that failed to be sent, it can be determined whether the transaction to which the target message belongs is within a set target transaction set. If so, the target message can be re-determined as the message that needs to be resent, and the target message can be determined as the message included in the message to be sent.
[0118] For ease of understanding, the message sending process provided by this application is described below through a specific embodiment. Figure 5A A fifth message sending process schematic diagram provided by some embodiments is shown, such as Figure 5A As shown, the process includes the following steps:
[0119] S501-A: For any transaction, the message processing device 11 obtains the message generated during the transaction and identifies the type of the message. If the type of the message is in the pre-saved target type, when it is determined that the transaction is successful, the message is saved in the database and the message is determined as a message to be sent.
[0120] S502 -A: The message processing device 11 obtains each message to be sent from a database with a pre-established connection, and sends each message to be sent to the producer device 12 .
[0121] S503-A: The producer device 12 receives each message and sends each message to a message queue (MQ) respectively.
[0122] S504-A: For each message, the message processing device 11 obtains the status information of whether each message is successfully sent to the MQ; for each target message whose status information is failure to send, it is determined whether the transaction to which the target message belongs is in the set target transaction set, and if so, execute step S505-A.
[0123] S505-A: Re-determine the target message as the message included in the message to be sent, obtain the target message from the database again, and send the target message to the producer device 12 again.
[0124] S506-A: The producer device 12 receives the target message and sends the target message to the MQ.
[0125] For ease of understanding, the message sending process provided by this application is further described below through a specific embodiment. Figure 5B A sixth message sending process schematic diagram provided by some embodiments is shown, such as Figure 5B As shown, the process includes the following steps:
[0126] S501-B: For any transaction, the message processing device 11 obtains the message generated during the transaction and identifies the type of the message. If the type of the message is in the pre-saved target type, when the transaction is determined to be successful, the message is saved in the database and determined as a message to be sent.
[0127] Optionally, the status information of the message in the database may be configured as "not yet sent".
[0128] S502 -B: The message processing device 11 obtains each message to be sent from a database with a pre-established connection, and sends each message to be sent to the producer device 12 .
[0129] S503-B: The producer device 12 receives each message and sends each message to a message queue (MQ) respectively.
[0130] S504-B: For each message, the message processing device 11 obtains the status information of whether the message is successfully sent to the MQ. For a message whose status information indicates that the message is successfully sent, the step S505-B is executed; for a target message whose status information indicates that the message is unsuccessfully sent, the step S506-B is executed.
[0131] S505-B: The message processing device 11 updates the status information of the message in the database to "successfully sent", and no longer determines the message as a message included in the messages to be sent.
[0132] S506-B: The message processing device 11 updates the status information of the target message in the database to "failed to send", and for each target message whose status information is failed to send, determines whether the transaction to which the target message belongs is in the set target transaction set, and if so, executes step S507-B.
[0133] In a possible implementation, if the transaction to which the target message belongs is not in the set target transaction set, the target message may not be determined as a message to be sent.
[0134] S507-B: re-determine the target message as the message included in the message to be sent, obtain the target message from the database again, and send the target message again to the producer device 12. The producer device 12 receives the target message and sends the target message to the MQ again.
[0135] It is understandable that after step S507-B, step S504-B may be repeated, which will not be described in detail here.
[0136] Embodiment 2:
[0137] All implementation methods of the embodiments of this application comply with the relevant provisions of national laws and regulations regarding the acquisition, storage, use, and processing of data.
[0138] Based on the same technical concept, the present application provides a message sending method, which is applied to a message processing device. Figure 6 A seventh message sending process schematic diagram provided in some embodiments is shown, and the process includes the following steps:
[0139] S601: Acquire each message to be sent from a database with a pre-established connection, and send each message to a producer device, so that the producer device sends each message to a message queue MQ.
[0140] S602: Obtain status information of whether each message is successfully sent to the MQ; for a target message whose status information is failure to send, re-determine the target message as a message included in the message to be sent, obtain the target message from the database again, and send the target message to the producer device again, so that the producer device sends the target message to the MQ.
[0141] In a possible implementation manner, before acquiring each message to be sent from a database with a pre-established connection, the method further includes:
[0142] For any transaction, a message generated during the transaction is obtained; when it is determined that a set sending condition is met, the message is saved in the database, and the message is determined as a message to be sent.
[0143] In a possible implementation manner, determining that the set sending condition is satisfied includes:
[0144] Determine whether the transaction is successful, and if so, determine whether the set sending conditions are met.
[0145] In a possible implementation manner, after acquiring the message generated during the transaction, and before saving the message in the database when it is determined that the set sending condition is met, the method further includes:
[0146] For the message generated during the transaction, the type of the message is identified. If the type of the message is in the pre-saved target type, the subsequent step of saving the message in the database is performed when it is determined that the set sending conditions are met.
[0147] In a possible implementation manner, the status information of whether each message is successfully sent to the MQ is determined in the following manner:
[0148] For each message sent to the producer device, obtain the time when the producer device sends the message to the MQ and the failure time period when the sending failure occurs;
[0149] If the time is within the failure time period, the status information of the message is determined as sending failure.
[0150] In a possible implementation manner, after obtaining the status information of whether each message is successfully sent to the MQ, before re-determining the target message as a message included in the message to be sent for the target message whose status information is that the message fails to be sent, the method further includes:
[0151] For the target message, it is determined whether the transaction to which the target message belongs is in a set target transaction set. If so, the target message is re-determined as a message included in the message to be sent.
[0152] Based on the same technical concept, the present application provides a message sending device, which is applied to a message processing device. Figure 7 A schematic diagram of a first message sending device provided in some embodiments is shown, the device comprising:
[0153] A first acquisition module 71 is used to acquire each message to be sent from a database with a pre-established connection, and send each message to a producer device, so that the producer device sends each message to a message queue MQ;
[0154] The second acquisition module 72 is used to obtain the status information of whether each message is successfully sent to the MQ; for the target message whose status information is failure to send, the target message is re-determined as a message included in the message to be sent, the target message is obtained from the database again, and the target message is sent to the producer device again, so that the producer device sends the target message to the MQ.
[0155] In a possible implementation, the device further includes:
[0156] The determination module is used to obtain the message generated by any transaction during the transaction process; when it is determined that the set sending condition is met, the message is saved in the database and the message is determined as a message to be sent.
[0157] In a possible implementation, the determination module is specifically configured to determine whether the transaction is successful, and if so, determine that the set sending condition is met.
[0158] In a possible implementation, the determination module is further used to identify the type of the message generated during the transaction. If the type of the message is within a pre-saved target type, the message is saved in the database when it is determined that the set sending conditions are met.
[0159] In a possible implementation manner, the second acquisition module is specifically configured to acquire, for each message sent to the producer device, a time when the producer device sends the message to the MQ, and a failure time period during which a sending failure occurs;
[0160] If the time is within the failure time period, the status information of the message is determined as sending failure.
[0161] In a possible implementation, the second acquisition module is further configured to determine, with respect to the target message, whether the transaction to which the target message belongs is within a set target transaction set; if so, re-determine the target message as a message included in the message to be sent.
[0162] Based on the same technical concept, the present application also provides an electronic device, Figure 8 A schematic diagram of the structure of a first electronic device provided by some embodiments is shown, such as Figure 8 As shown, the electronic device includes: a processor 81, a communication interface 82, a memory 83 and a communication bus 84, wherein the processor 81, the communication interface 82, and the memory 83 communicate with each other through the communication bus 84;
[0163] The memory 83 stores a computer program. When the program is executed by the processor 81, the processor 81 is configured to perform the following steps:
[0164] Obtain each message to be sent from a database with a pre-established connection, and send each message to a producer device, so that the producer device sends each message to a message queue MQ;
[0165] Obtain status information of whether each message is successfully sent to the MQ; for the target message whose status information is failure to send, re-determine the target message as a message included in the message to be sent, obtain the target message from the database again, and send the target message to the producer device again, so that the producer device sends the target message to the MQ.
[0166] In a possible implementation, the processor 81 is further used to obtain, for any transaction, messages generated during the transaction process before obtaining each message to be sent from a database with a pre-established connection; when it is determined that the set sending conditions are met, save the message in the database and determine the message as a message to be sent.
[0167] In a possible implementation, the processor 81 is specifically configured to determine whether the transaction is successful, and if so, determine that a set sending condition is satisfied.
[0168] In a possible implementation, the processor 81 is further used for, after acquiring the message generated during the transaction, identifying the type of the message generated during the transaction, before saving the message into the database when it is determined that the set sending conditions are met, and if the type of the message is within the pre-saved target type, performing the subsequent step of saving the message into the database when it is determined that the set sending conditions are met.
[0169] In a possible implementation manner, the processor 81 is specifically configured to obtain, for each message sent to the producer device, a time when the producer device sends the message to the MQ, and a failure time period during which a sending failure occurs;
[0170] If the time is within the failure time period, the status information of the message is determined as sending failure.
[0171] In a possible implementation, the processor 81 is also used for, after obtaining the status information of whether each message is successfully sent to the MQ, and before re-determining the target message as a message included in the message to be sent for the target message whose status information is failure to send, determining whether the transaction to which the target message belongs is located in a set target transaction set; if so, re-determining the target message as a message included in the message to be sent.
[0172] Since the principle of solving the problem by the electronic device is similar to the message sending method in the above embodiment, the implementation of the electronic device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0173] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0174] The communication interface 82 is used for communication between the above electronic device and other devices.
[0175] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0176] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (Network Processor, NP), etc.; it can also be a digital signal processing processor (Digital Signal Processing, DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.
[0177] Based on the same technical concept, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program executable by an electronic device. When the program runs on the electronic device, the electronic device performs the following steps:
[0178] Obtain each message to be sent from a database with a pre-established connection, and send each message to a producer device, so that the producer device sends each message to a message queue MQ;
[0179] Obtain status information of whether each message is successfully sent to the MQ; for the target message whose status information is failure to send, re-determine the target message as a message included in the message to be sent, obtain the target message from the database again, and send the target message to the producer device again, so that the producer device sends the target message to the MQ.
[0180] In a possible implementation manner, before acquiring each message to be sent from a database with a pre-established connection, the method further includes:
[0181] For any transaction, a message generated during the transaction is obtained; when it is determined that a set sending condition is met, the message is saved in the database, and the message is determined as a message to be sent.
[0182] In a possible implementation manner, determining that the set sending condition is satisfied includes:
[0183] Determine whether the transaction is successful, and if so, determine whether the set sending conditions are met.
[0184] In a possible implementation manner, after acquiring the message generated during the transaction, and before saving the message in the database when it is determined that the set sending condition is met, the method further includes:
[0185] For the message generated during the transaction, the type of the message is identified. If the type of the message is in the pre-saved target type, the subsequent step of saving the message in the database is performed when it is determined that the set sending conditions are met.
[0186] In a possible implementation manner, the status information of whether each message is successfully sent to the MQ is determined in the following manner:
[0187] For each message sent to the producer device, obtain the time when the producer device sends the message to the MQ and the failure time period when the sending failure occurs;
[0188] If the time is within the failure time period, the status information of the message is determined as sending failure.
[0189] In a possible implementation manner, after obtaining the status information of whether each message is successfully sent to the MQ, before re-determining the target message as a message included in the message to be sent for the target message whose status information is that the message fails to be sent, the method further includes:
[0190] For the target message, it is determined whether the transaction to which the target message belongs is in a set target transaction set. If so, the target message is re-determined as a message included in the message to be sent.
[0191] Since the principle of solving the problem by the above-mentioned computer-readable storage medium is similar to that of the message sending method, the implementation of the above-mentioned computer-readable storage medium can refer to the implementation of the card making method, and the repeated parts will not be repeated.
[0192] The above-mentioned computer-readable storage medium can be any available medium or data storage device that can be accessed by the processor in the electronic device, including but not limited to magnetic storage such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc., optical storage such as CD, DVD, BD, HVD, etc., and semiconductor storage such as ROM, EPROM, EEPROM, non-volatile memory (NANDFLASH), solid-state drive (SSD), etc.
[0193] Based on the same technical concept, the present application provides a computer program product, which includes: computer program code, when the computer program code runs on a computer, the computer implements the message sending method described in any method embodiment applied to an electronic device when executing.
[0194] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof, and all or part of the embodiments may be implemented in the form of a computer program product. The computer program product includes one or more computer instructions, and when the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated.
[0195] Embodiment 3:
[0196] All implementation methods of the embodiments of this application comply with the relevant provisions of national laws and regulations regarding the acquisition, storage, use, and processing of data.
[0197] Based on the same technical concept, the present application provides a message sending method, which is applied to a message processing device. Fig. 9 A schematic diagram of an eighth message sending process provided by some embodiments is shown, and the process includes the following steps:
[0198] S901: Acquire each message to be sent from a database with a pre-established connection, and send each message to a message queue MQ.
[0199] S902: Obtain status information of whether each message is successfully sent to the MQ; for a target message whose status information is failure to send, re-determine the target message as a message included in the message to be sent, obtain the target message from the database again, and send the target message to the MQ again.
[0200] The message sending method provided in the embodiment of the present application is applied to an electronic device, which may be a PC, a mobile terminal or other device, or a server or other device.
[0201] Based on the same technical concept, the present application provides a message sending device, Fig.10A schematic diagram of a second message sending device provided in some embodiments is shown, the device comprising:
[0202] The third acquisition module 101 is used to acquire each message to be sent from a pre-established database, and send each message to the message queue MQ;
[0203] The fourth acquisition module 102 is used to obtain the status information of whether each message is successfully sent to the MQ; for the target message whose status information is failure to send, the target message is re-determined as the message included in the message to be sent, the target message is obtained from the database again, and the target message is sent to the MQ again.
[0204] Based on the same technical concept, the present application also provides an electronic device, Fig.11 A schematic diagram of the structure of a second electronic device provided by some embodiments is shown, such as Fig.11 As shown, the electronic device includes: a processor 111, a communication interface 112, a memory 113 and a communication bus 114, wherein the processor 111, the communication interface 112, and the memory 113 communicate with each other through the communication bus 114;
[0205] The memory 113 stores a computer program. When the program is executed by the processor 111, the processor 111 is configured to perform the following steps:
[0206] Obtain each message to be sent from a pre-established connection database, and send each message to a message queue MQ;
[0207] Obtain status information of whether each message is successfully sent to the MQ; for a target message whose status information is failure to send, re-determine the target message as a message included in the message to be sent, obtain the target message from the database again, and send the target message to the MQ again.
[0208] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0209] The communication interface 112 is used for communication between the above electronic device and other devices.
[0210] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0211] The above-mentioned processor can be a general-purpose processor, including a central processing unit, a network processor (Network Processor, NP), etc.; it can also be a digital signal processing processor (Digital Signal Processing, DSP), an application-specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, a discrete hardware component, etc.
[0212] Based on the same technical concept, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program executable by an electronic device. When the program runs on the electronic device, the electronic device performs the following steps:
[0213] Obtain each message to be sent from a pre-established connection database, and send each message to a message queue MQ;
[0214] Obtain status information of whether each message is successfully sent to the MQ; for a target message whose status information is failure to send, re-determine the target message as a message included in the message to be sent, obtain the target message from the database again, and send the target message to the MQ again.
[0215] The above-mentioned computer-readable storage medium can be any available medium or data storage device that can be accessed by the processor in the electronic device, including but not limited to magnetic storage such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO), etc., optical storage such as CD, DVD, BD, HVD, etc., and semiconductor storage such as ROM, EPROM, EEPROM, non-volatile memory (NANDFLASH), solid-state drive (SSD), etc.
[0216] Based on the same technical concept, the present application provides a computer program product, which includes: computer program code, when the computer program code runs on a computer, the computer implements the message sending method described in any method embodiment applied to an electronic device when executing.
[0217] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof, and all or part of the embodiments may be implemented in the form of a computer program product. The computer program product includes one or more computer instructions, and when the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated.
[0218] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0219] The present application is described with reference to the flowchart and / or block diagram of the method, device (system), and computer program product according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the process and / or box 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 produce a device for implementing the function specified in one process or multiple processes in the flowchart and / or one box or multiple boxes in the block diagram.
[0220] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0221] These computer program instructions may also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0222] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A message sending system, characterized in that: The system comprises: A message processing device, used for acquiring each message to be sent from a database with a pre-established connection, and sending each message to a producer device; The producer device is used to receive each message and send each message to the message queue MQ; The message processing device is further used to obtain status information of whether each message is successfully sent to the MQ; for a target message whose status information is that the message fails to be sent, re-determine the target message as a message included in the message to be sent, obtain the target message from the database again, and send the target message to the producer device again; The producer device is further configured to receive the target message and send the target message to the MQ; The message processing device is specifically used to obtain the time when the producer device sends each message to the MQ, and the failure time period when the sending failure occurs. If the time is within the failure time period, the status information of the message is determined as a sending failure.
2. The system according to claim 1, characterized in that The message processing device is also used to obtain, for any transaction, a message generated during the transaction; when it is determined that the set sending condition is met, save the message into the database, and determine the message as a message to be sent.
3. The system according to claim 2, characterized in that The message processing device is specifically used to determine whether the transaction is successful, and if so, determine that the set sending conditions are met.
4. The system according to claim 2, characterized in that The message processing device is further used to identify the type of the message generated during the transaction, and if the type of the message is within the pre-saved target type, save the message into the database.
5. The system according to any one of claims 1 to 4, characterized in that: The producer device is also used to generate status information of whether each message is successfully sent to the MQ; The message processing device is specifically used to obtain the status information generated by the producer device.
6. The system according to any one of claims 1 to 4, characterized in that: The message processing device is further used to determine, for the target message, whether the transaction to which the target message belongs is in a set target transaction set, and if so, re-determine the target message as a message included in the message to be sent.
7. A message sending method, characterized in that: The method comprises: Obtain each message to be sent from a database with a pre-established connection, and send each message to a producer device, so that the producer device sends each message to a message queue MQ; Obtaining status information of whether each message is successfully sent to the MQ; for a target message whose status information indicates that the message fails to be sent, re-determining the target message as a message included in the message to be sent, obtaining the target message from the database again, and sending the target message to the producer device again, so that the producer device sends the target message to the MQ; The status information of whether each message is successfully sent to the MQ is determined in the following manner: For each message sent to the producer device, obtain the time when the producer device sends the message to the MQ and the failure time period when the sending failure occurs; If the time is within the failure time period, the status information of the message is determined as sending failure.
8. The method according to claim 7, characterized in that Before obtaining each message to be sent from the database with a pre-established connection, the method further comprises: For any transaction, a message generated during the transaction is obtained; when it is determined that a set sending condition is met, the message is saved in the database, and the message is determined as a message to be sent.
9. The method according to claim 8, characterized in that Determining that the set sending conditions are met includes: Determine whether the transaction is successful, and if so, determine whether the set sending conditions are met.
10. The method according to claim 8, characterized in that After acquiring the message generated during the transaction, and before saving the message into the database when it is determined that the set sending condition is met, the method further includes: For the message generated during the transaction, the type of the message is identified. If the type of the message is in the pre-saved target type, the subsequent step of saving the message in the database is performed when it is determined that the set sending conditions are met.
11. The method according to any one of claims 7 to 10, characterized in that: After obtaining the status information of whether each message is successfully sent to the MQ, before re-determining the target message as a message included in the message to be sent for the target message whose status information is that the message fails to be sent, the method further includes: For the target message, it is determined whether the transaction to which the target message belongs is in a set target transaction set. If so, the target message is re-determined as a message included in the message to be sent.
12. A message sending device, characterized in that: The device comprises: A first acquisition module is used to acquire each message to be sent from a database with a pre-established connection, and send each message to a producer device, so that the producer device sends each message to a message queue MQ; The second acquisition module is used to obtain the status information of whether each message is successfully sent to the MQ; for the target message whose status information is that the sending fails, the target message is re-determined as a message included in the message to be sent, the target message is obtained from the database again, and the target message is sent to the producer device again, so that the producer device sends the target message to the MQ; The second acquisition module is specifically used to obtain the time when the producer device sends each message sent to the producer device to the MQ, and the failure time period when the sending failure occurs; if the time is within the failure time period, the status information of the message is determined as a sending failure.
13. The device according to claim 12, characterized in that The device also includes: The determination module is used to obtain the message generated by any transaction during the transaction process; when it is determined that the set sending condition is met, the message is saved in the database and the message is determined as a message to be sent.
14. The device according to claim 13, characterized in that The determination module is specifically used to determine whether the transaction is successful, and if so, determine that the set sending conditions are met.
15. The device according to claim 13, characterized in that The determination module is also used to identify the type of the message generated during the transaction. If the type of the message is within the pre-saved target type, the message is saved in the database when it is determined that the set sending conditions are met.
16. The device according to any one of claims 12 to 15, characterized in that: The second acquisition module is further configured to determine, with respect to the target message, whether the transaction to which the target message belongs is within a set target transaction set, and if so, to re-determine the target message as a message included in the message to be sent.
17. An electronic device, characterized in that: The electronic device comprises at least a processor and a memory, and the processor is used to implement the steps of the message sending method as claimed in any one of claims 7 to 11 when executing a computer program stored in the memory.
18. A computer-readable storage medium, characterized in that: It stores a computer program, which, when executed by a processor, implements the steps of the message sending method according to any one of claims 7 to 11.
19. A computer program product, characterized in that The computer program product comprises: a computer program code, and when the computer program code is run on a computer, the computer is enabled to execute the steps of the message sending method according to any one of claims 7 to 11.
Citation Information
Patent Citations
Message confirmation method and device, storage medium and electronic equipment
CN113742354A
Message pushing method, device and system, electronic equipment and storage medium
CN114500443A