Message processing method and device
By carrying out unified management and batch processing in the message center, the problems of complexity and low efficiency in message processing between business systems are solved, efficient and stable message delivery and unified management are achieved, and operation and maintenance costs are reduced.
Patent Information
- Application Number
- CN202410278618.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-12
- Publication Date
- 2025-09-12
AI Technical Summary
In the existing technology, the message processing method of each business system is complex and inefficient, resulting in difficulties in operation and maintenance and unified management, and there is a risk of message loss.
A message center is used for unified management. Messages are saved to a receiving table and multiple sending tables are generated through scheduled tasks. Messages are processed in batches according to the recipient type, and message delivery is performed when the recipient supports push or pull mode. Redis cache and automatic retry mechanism are used to improve system stability.
It achieves efficient and unified management of message processing, reduces development and operation and maintenance costs, improves system throughput, reduces the risk of message loss, and simplifies the message sending and receiving process.
Smart Images

Figure CN120639732A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technologies, and in particular to a message processing method and device. Background Art
[0002] This section is intended to provide a background or context to the embodiments of the invention that are recited in the claims. No statement herein is admitted to be prior art by virtue of its inclusion in this section.
[0003] Currently, each business system establishes an information channel with users by sending messages. Since each business system is developed by different people with different coding styles, troubleshooting online problems is very time-consuming and slow, and subsequent operation and maintenance work is extremely challenging, which is not conducive to unified management. The existing message processing methods are as follows:
[0004] The message sender sends an MQ message and pushes it to the MQ message queue. The message generation service detects new MQ messages and pulls the latest message from the queue. The message center receives the message and processes it. The message center pushes the processed message to the MQ message queue. The receiving service subscribes to the messages in the MQ message queue and pulls the latest message after detecting new messages. The message receiving service notifies the user of the message based on its business needs. In this solution, both the message sender and the message receiver need to subscribe to the MQ messages in the message center, which complicates operations for both the message sender and the message receiver and reduces message processing efficiency. Summary of the Invention
[0005] An embodiment of the present invention provides a message processing method for simplifying the processing flow of a message sender and a message receiver and improving message processing efficiency. The method includes:
[0006] After receiving the message to be sent from the message sender, the message to be sent is saved in the message receiving table; the message to be sent includes the recipient information, sender information, message content, and sending time;
[0007] Periodically scan the messages to be sent in the message receiving table, and generate multiple message sending tables according to the messages to be sent;
[0008] Periodically scan the messages to be sent in each message sending table;
[0009] Process the messages to be sent in each message sending table according to the received message type of the message recipient corresponding to the message to be sent.
[0010] An embodiment of the present invention further provides a message processing device for simplifying the processing flow of a message sender and a message receiver and improving message processing efficiency. The device includes:
[0011] The scanning module is used to save the to-be-sent message to the message receiving table after receiving the to-be-sent message from the message sender; the to-be-sent message includes the recipient information, the sender information, the message content, and the sending time; regularly scan the to-be-sent messages in the message receiving table, generate multiple message sending tables based on the to-be-sent messages; and regularly scan the to-be-sent messages in each message sending table;
[0012] The processing module is used to process the messages to be sent in each message sending table according to the received message type of the message recipient corresponding to the message to be sent.
[0013] An embodiment of the present invention further provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned message processing method when executing the computer program.
[0014] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the message processing method described above is implemented.
[0015] An embodiment of the present invention further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the message processing method is implemented.
[0016] In an embodiment of the present invention, after receiving a message to be sent from a message sender, the message to be sent is saved in a message receiving table; the message to be sent includes recipient information, sender information, message content, and sending time; the messages to be sent in the message receiving table are scanned periodically, and multiple message sending tables are generated according to the messages to be sent; the messages to be sent in each message sending table are scanned periodically; according to the received message type of the message recipient corresponding to the message to be sent, the messages to be sent in each message sending table are processed. Compared with the prior art, two scheduled tasks are used to batch process messages according to the received message type of the message recipient, decouple message reception and message sending, increase the throughput of message processing, simplify the processing flow of the message sender and the message recipient, and improve the efficiency of message processing. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] 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 the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0018] Figure 1 A flow chart of the message processing method provided by the present invention;
[0019] Figure 2 A flow chart of the message processing method provided by the present invention;
[0020] Figure 3 A flow chart of the message processing method provided by the present invention;
[0021] Figure 4 A flow chart of the message processing method provided by the present invention;
[0022] Figure 5 This is a structural diagram of the message processing device provided by the present invention. DETAILED DESCRIPTION
[0023] To make the purpose, technical solutions and advantages of the embodiments of the present invention more clear, the embodiments of the present invention are further described in detail below with reference to 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.
[0024] Currently, each business system establishes a communication channel with users through messaging. Message types include SMS, system messages, WeChat messages, emails, and intelligent outbound calls. Each business system has its own messaging system. Each business system is developed by different people with different coding styles. This makes troubleshooting online issues time-consuming and slow, and subsequent operations and maintenance tasks pose significant challenges, hindering unified management.
[0025] Based on this, Figure 1 A flowchart corresponding to a message processing method provided by an embodiment of the present invention is shown in FIG. Figure 1 As shown, the method includes:
[0026] Step 101: After receiving a message to be sent from a message sender, the message to be sent is saved in a message receiving table.
[0027] It should be noted that the message to be sent includes recipient information, sender information, message content, and sending time.
[0028] In the embodiment of the present invention, the message sender calls the message sending SDK interface of the message center to push information such as the recipient information and the sender information to the message center.
[0029] Step 102 : regularly scan the messages to be sent in the message receiving table, and generate multiple message sending tables according to the messages to be sent.
[0030] Step 103: Periodically scan the messages to be sent in each message sending table.
[0031] Step 104 : Process the messages to be sent in each message sending table according to the message receiving type corresponding to the message to be sent.
[0032] In the embodiment of the present invention, after receiving the message to be sent, the message center saves the message to be sent to the message receiving table. The message center starts a scheduled task to regularly scan the message receiving table for newly received messages to be sent.
[0033] In a possible implementation, the message center is split according to dimensions such as recipient information and message type, and multiple message sending tables are generated according to the messages to be sent.
[0034] For example, message A needs to be sent to 100 people. Only one piece of data is saved in the message receiving table. The message needs to be split into 100 pieces in the message sending table. The 100 pieces of message A need to be sent correspond to each recipient information one by one.
[0035] The message center supports sending multiple types of messages at the same time, such as SMS, WeChat, email, system messages, etc., and splits messages into multiple messages according to different message types and different recipients.
[0036] In the embodiment of the present invention, the second scheduled task is started to scan the messages to be sent in each message sending table, and the messages to be sent in each message sending table are processed according to the received message type of the message recipient corresponding to the message to be sent.
[0037] The above solution enables unified message management, reducing the development and subsequent maintenance costs associated with independently built business systems. It also avoids the risk of data leakage caused by independent business system development. The message center uses two scheduled tasks to batch messages internally during message processing, decoupling message reception and sending, increasing the overall throughput of the message center. This enables unified processing and maintenance of different message types, simplifies the processing process for both message senders and receivers, improves work efficiency, and saves costs.
[0038] In step 104 of the embodiment of the present invention, the messages to be sent in each message sending table are processed according to the message type received by the message recipient corresponding to the message to be sent. Figure 2 As shown, the details are as follows:
[0039] Step 201: When the message recipient supports the push mode, a message queue MQ message is sent to the message recipient.
[0040] Step 202: When the message receiver supports the pull mode, the message to be sent is saved in the Redis cache.
[0041] In the embodiment of the present invention, when the message recipient supports the push mode, pre-configured recipient application information is obtained, a pre-configured URL interface is called, and the MQ message is pushed to the message recipient.
[0042] If the message receiver supports pull mode, the message to be sent is saved in the Redis cache. The message receiver calls the corresponding SDK interface to query the information in the Redis cache and pull the message to the application. The message receiver then delivers the message to the user based on actual business requirements.
[0043] The above solution uses a Redis database to reduce the number of times message recipients frequently call SDK interfaces, which could lead to message center service unavailability, thereby improving system performance. When messages reach recipients, the message center can automatically push messages to the recipient's application, while the recipient's application can pull messages from the message center based on business needs, providing greater flexibility in delivery methods.
[0044] In the embodiment of the present invention, when scanning the messages to be sent, the two scheduled tasks will process the messages according to the sending time of the messages to be sent, and only process the messages within the time period to be sent.
[0045] In existing technology, the message sender calls the message center SDK interface to push the message to the message sending center; the message center receives and stores the message; the message receiver pulls the corresponding message based on its business identifier; the message receiver service follows up on its business needs and notifies the user of the message. If the message sender and message receiver directly call the message center SDK interface due to network or other reasons, there is a risk of message loss if the message center fails to send the message.
[0046] Based on this, after processing the messages to be sent in each message sending table, the embodiment of the present invention follows the steps as follows: Figure 3 As shown, the details are as follows:
[0047] Step 301: Automatically retry when message sending is abnormal.
[0048] Step 302: Automatically save the abnormal message to the abnormal message table.
[0049] Step 303: Feedback the exception information to the message sender.
[0050] In the embodiment of the present invention, the message center has an automatic retry mechanism, and a message sending failure can be automatically retried.
[0051] It should be noted that the number of retries and retry frequency can be configured in the configuration center according to business needs.
[0052] Before receiving a message to be sent from a message sender, the embodiment of the present invention has the following steps: Figure 4 As shown, the details are as follows:
[0053] Step 401: Receive configuration information of a message sender and a message receiver.
[0054] Step 402: Register in the message center according to the configuration information of the message sender and the message receiver.
[0055] In an embodiment of the present invention, before sending a message, the message sender and the message receiver services respectively register their respective services with the configuration center, obtain their own unique codes, and register their own service configuration information such as domain names and server IP addresses with the message center.
[0056] In the above solution, the message sender and the message receiver register the application with the message sending center, which improves the security of the system.
[0057] The embodiment of the present invention also provides a message processing device, as described in the following embodiment. Figure 5 As shown, the device includes:
[0058] Scanning module 501 is used to save the to-be-sent message to a message receiving table after receiving the to-be-sent message from the message sender; the to-be-sent message includes recipient information, sender information, message content, and sending time; periodically scan the to-be-sent messages in the message receiving table, generate multiple message sending tables based on the to-be-sent messages; and periodically scan the to-be-sent messages in each message sending table;
[0059] The processing module 502 is configured to process the messages to be sent in each message sending table according to the message receiving type of the message to be sent corresponding to the message to be sent.
[0060] In the embodiment of the present invention, the processing module 502 is specifically configured to:
[0061] When the message receiver supports push mode, send a message queue MQ message to the message receiver;
[0062] When the message receiver supports the pull mode, the message to be sent is saved in the Redis cache.
[0063] In the embodiment of the present invention, the processing module 502 is specifically configured to:
[0064] Call the pre-configured URL interface to push the MQ message to the message recipient.
[0065] In the embodiment of the present invention, the processing module 502 is further configured to:
[0066] After processing the pending messages in each message sending table, it will automatically retry if a message sending exception occurs;
[0067] Automatically save the sent exception message to the exception message table;
[0068] Feedback exception information to the message sender.
[0069] In the embodiment of the present invention, the scanning module 501 is further configured to:
[0070] Before receiving a message to be sent from a message sender, receiving configuration information of the message sender and the message receiver;
[0071] Register in the message center according to the configuration information of the message sender and message receiver.
[0072] Since the principle of solving the problem by the device is similar to that of the message processing method, the implementation of the device can refer to the implementation of the message processing method, and the repeated parts will not be repeated.
[0073] An embodiment of the present invention further provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned message processing method when executing the computer program.
[0074] An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the message processing method described above is implemented.
[0075] An embodiment of the present invention further provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the message processing method is implemented.
[0076] In an embodiment of the present invention, after receiving a pending message from a message sender, the pending message is saved in a message receiving table. The pending message includes recipient information, sender information, message content, and sending time. The pending messages in the message receiving table are periodically scanned, and multiple message sending tables are generated based on the pending messages. The pending messages in each message sending table are periodically scanned. The pending messages in each message sending table are processed based on the message type of the corresponding message recipient. Compared with the existing technology, this achieves unified message management, reducing the development costs and subsequent operation and maintenance costs associated with independently building each business system. It also avoids the risk of data leakage caused by independently building each business system. During internal message processing, the message center uses two scheduled tasks to batch messages, decoupling message reception and sending, and increasing the overall throughput of the message center. This enables unified processing and maintenance of different message types, simplifies the processing workflow for both message senders and recipients, improves work efficiency, and saves costs.
[0077] It will be understood by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware. Furthermore, 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 magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0078] 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 flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, 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 flowcharts and / or block diagrams. 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.
[0079] 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 an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0080] These computer program instructions can 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, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0081] 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 message processing method, characterized in that: include: After receiving the message to be sent from the message sender, the message to be sent is saved in the message receiving table; the message to be sent includes the recipient information, sender information, message content, and sending time; Periodically scan the messages to be sent in the message receiving table, and generate multiple message sending tables according to the messages to be sent; Periodically scan the messages to be sent in each message sending table; Process the messages to be sent in each message sending table according to the received message type of the message recipient corresponding to the message to be sent.
2. The message processing method according to claim 1, wherein: Process the messages to be sent in each message sending table according to the message type of the message recipient corresponding to the message to be sent, including: When the message receiver supports push mode, send a message queue MQ message to the message receiver; When the message receiver supports the pull mode, the message to be sent is saved in the Redis cache.
3. The message processing method according to claim 2, wherein: Send a message queue MQ message to the message receiver, including: Call the pre-configured URL interface to push the MQ message to the message receiver.
4. The message processing method according to claim 1, wherein: After processing the messages to be sent in each message sending table, it also includes: Automatically retry when message sending fails; Automatically save the sent exception message to the exception message table; Feedback exception information to the message sender.
5. The message processing method according to claim 1, wherein: Before receiving the message to be sent from the message sender, it also includes: Receive configuration information of the message sender and message receiver; Register in the message center according to the configuration information of the message sender and message receiver.
6. A message processing device, characterized in that: include: The scanning module is used to save the to-be-sent message to the message receiving table after receiving the to-be-sent message from the message sender; the to-be-sent message includes the recipient information, the sender information, the message content, and the sending time; regularly scan the to-be-sent messages in the message receiving table, generate multiple message sending tables based on the to-be-sent messages; and regularly scan the to-be-sent messages in each message sending table; The processing module is used to process the messages to be sent in each message sending table according to the received message type of the message recipient corresponding to the message to be sent.
7. The message processing device according to claim 6, wherein: The processing module is specifically used to: When the message receiver supports push mode, send a message queue MQ message to the message receiver; When the message receiver supports the pull mode, the message to be sent is saved in the Redis cache.
8. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 5 is implemented.
9. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.
10. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.