Message processing method and device, equipment and storage medium
By generating atomic operations when receiving messages to be pushed and transmitting them to the message write diffusion model, compatibility and expansion problems during multi-type client access in the prior art are solved, and efficient message processing is achieved.
Patent Information
- Application Number
- CN202411445336.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-16
- Publication Date
- 2025-02-21
AI Technical Summary
In the prior art, message processing methods are prone to incompatibility and inability to expand when there are multiple types of client access, and are not very practical.
When receiving the message to be pushed, atomic operations are generated using the preset script processing method, and transmitted to the preset message write diffusion model to obtain the message sequence to be pushed, and the message sequence is pushed to the client through this model. Multi-type clients.
The compatibility and expansion problems of message processing methods during multi-type client access in the prior art are solved, and the practicality of message processing is improved.
Smart Images

Figure CN119496820A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of message processing, and in particular to a message processing method, apparatus, device and storage medium. Background Art
[0002] With the development of mobile Internet technology, many businesses in various industries are gradually expanding online. At this time, online network communication and message processing are becoming more and more important. In the existing message processing technology, it is usually implemented in the back-end using HTTP (Hypertext Transfer Protocol) request polling based on RESTful API (Application Programming Interface). However, when processing messages in this way, only a single type of client access is usually allowed. If there are multiple types of client access, incompatibility and expansion problems are likely to occur, resulting in low practicality.
[0003] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention
[0004] The main purpose of the present application is to provide a message processing method, apparatus, device and storage medium, aiming to solve the technical problem that the message processing method in the prior art is easily incompatible and cannot be expanded when there are multiple types of client accesses, and is not practical.
[0005] To achieve the above object, the present application proposes a message processing method, the method comprising:
[0006] When receiving a message to be pushed, an atomic operation corresponding to the message to be pushed is generated through a preset script processing method, and the atomic operation is used to bind the message sequence self-increment and the message push;
[0007] Transmitting the atomic operation to a preset message write diffusion model to obtain a sequence of messages to be pushed;
[0008] The sequence of messages to be pushed is pushed to the client through the preset message write diffusion model, and the message saving mechanism of the preset message write diffusion model supports multiple types of clients.
[0009] In one embodiment, the preset message write diffusion model is provided with: a length trimmer and an expiration checker; before the step of pushing the sequence of messages to be pushed to the client through the preset message write diffusion model, it also includes:
[0010] The sequence of messages to be pushed is updated in real time by the length trimmer and the expiration checker; wherein the length trimmer is used to manage the length of the sequence of messages to be pushed, and the expiration checker is used to delete expired messages from the sequence of messages to be pushed;
[0011] The step of pushing the sequence of messages to be pushed to the client through the preset message write diffusion model includes:
[0012] The updated sequence of messages to be pushed is pushed to the client through the preset message write diffusion model.
[0013] In one embodiment, after the step of pushing the sequence of messages to be pushed to the client through the preset message write diffusion model, the method further includes:
[0014] During the message push process, the delayed message checker performs message check on the message sequence to be pushed to determine the delayed push message in the message sequence to be pushed;
[0015] Generate a distributed delayed message queue based on the delayed push message;
[0016] The distributed delayed message queue is pushed to the client through a timed message processor.
[0017] In one embodiment, the step of pushing the distributed delayed message queue to the client through the timed message processor includes:
[0018] Detect in real time through a timing message processor whether there is a target delayed push message with a message push time of the current time in the distributed delayed message queue;
[0019] If so, the target delayed push message is pushed to the client;
[0020] Return to the step of detecting in real time through the timing message processor whether there is a target delayed push message with a message push time of the current time in the distributed delayed message queue until all delayed push messages in the distributed delayed message queue are pushed to the client.
[0021] In one embodiment, the method further comprises:
[0022] Evenly mapping the user's to-be-processed messages to the target message processing thread bound to the user through a preset message mapping algorithm;
[0023] The to-be-processed message is processed by the target message processing thread.
[0024] In one embodiment, the users include: a first user and a second user; the step of uniformly mapping the user's to-be-processed messages to the target message processing thread bound to the user by using a preset message mapping algorithm includes:
[0025] Determine a first message processing thread corresponding to the first user, and a second message processing thread corresponding to the second user;
[0026] Mapping the first to-be-processed message corresponding to the first user to the first message processing thread through a preset message mapping algorithm;
[0027] Mapping the second to-be-processed message corresponding to the second user to the second message processing thread by using the preset message mapping algorithm;
[0028] The step of processing the to-be-processed message through the target message processing thread includes:
[0029] The first message to be processed is processed by the first message processing thread, and the second message to be processed is processed by the second message processing thread.
[0030] In one embodiment, the step of processing the to-be-processed message by the target message processing thread includes:
[0031] During the processing, the socket processing capability of the target message processing thread is detected in real time;
[0032] When the socket processing capacity does not meet the preset capacity requirement, the TimeLine thread is blocked to continue message processing.
[0033] In addition, to achieve the above purpose, the present application also proposes a message processing device, the device comprising:
[0034] An atomic operation generation module, which is used to generate an atomic operation corresponding to the message to be pushed through a preset script processing method when receiving the message to be pushed, and the atomic operation is used to bind the message sequence self-increment and the message push;
[0035] A message sequence acquisition module, used for transmitting the atomic operation to a preset message write diffusion model to obtain a message sequence to be pushed;
[0036] The message sequence push module is used to push the message sequence to be pushed to the client through the preset message write diffusion model, and the message saving mechanism of the preset message write diffusion model supports multiple types of clients.
[0037] In addition, to achieve the above objectives, the present application also proposes a message processing device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the message processing method described above.
[0038] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the message processing method described above are implemented.
[0039] The present application provides a message processing method, which discloses that when a message to be pushed is received, an atomic operation corresponding to the message to be pushed is generated through a preset script processing method, and the atomic operation is used to bind the message sequence self-increment and the message push; the atomic operation is transmitted to a preset message write diffusion model to obtain the message sequence to be pushed; the message sequence to be pushed is pushed to the client through the preset message write diffusion model, and the message saving mechanism of the preset message write diffusion model supports multiple types of clients; compared with the prior art method of implementing message processing in the back end using a RESTful API-based HTTP request polling method, which usually only allows a single client to access, the present invention pushes the message sequence to be pushed to the client through a preset message write diffusion model, wherein the message saving mechanism of the preset message write diffusion model supports multiple types of clients, thereby solving the technical problem that the message processing method in the prior art is prone to incompatibility and inability to expand when multiple types of clients access, and is not practical. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0041] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0042] Figure 1 A flowchart of the first embodiment of the message processing method of the present application is provided;
[0043] Figure 2 A flowchart of message processing by a preset message writing diffusion model in the message processing method of the present application;
[0044] Figure 3A schematic diagram of the process of high-performance processing of real-time messages in the message processing method of this application;
[0045] Figure 4 A flowchart of the second embodiment of the message processing method of the present application is provided;
[0046] Figure 5 This is a flowchart of delayed message processing in the message processing method of this application;
[0047] Figure 6 A flowchart of the third embodiment of the message processing method of the present application is provided;
[0048] Figure 7 This is a flowchart of multi-threaded concurrent processing in the message processing method of this application;
[0049] Figure 8 This is a schematic diagram of the module structure of the message processing device according to an embodiment of the present application;
[0050] Fig. 9 A schematic diagram of the device structure of the hardware operating environment involved in the message processing method in the embodiment of the present application.
[0051] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0052] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0053] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.
[0054] The main solution of the embodiment of the present application is: when a message to be pushed is received, an atomic operation corresponding to the message to be pushed is generated through a preset script processing method, and the atomic operation is used to bind the message sequence self-increment and message push; the atomic operation is transmitted to the preset message write diffusion model to obtain the message sequence to be pushed; the message sequence to be pushed is pushed to the client through the preset message write diffusion model, and the message saving mechanism of the preset message write diffusion model supports multiple types of clients.
[0055] Because the prior art usually only allows a single client to access when processing messages using HTTP request polling based on RESTful API at the back end, incompatibility and non-scalability problems are prone to occur when multiple types of clients access, resulting in low practicality.
[0056] The present application provides a solution, which pushes a sequence of messages to be pushed to a client through a preset message write diffusion model, wherein the message storage mechanism of the preset message write diffusion model supports multiple types of clients, thereby solving the technical problem that the message processing method in the prior art is prone to incompatibility and cannot be expanded when multiple types of clients are connected, and is not practical.
[0057] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, a personal computer, a mobile phone, etc., or an electronic device capable of realizing the above functions, a message processing device, etc. The following takes a message processing device as an example (hereinafter referred to as a device) to illustrate this embodiment and the following embodiments.
[0058] Based on this, the present application embodiment provides a message processing method, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the message processing method of the present application.
[0059] In this embodiment, the message processing method includes steps S10 to S30:
[0060] Step S10: when receiving a message to be pushed, generating an atomic operation corresponding to the message to be pushed through a preset script processing method, wherein the atomic operation is used to bind the message sequence self-increment and the message push.
[0061] It should be understood that the message to be pushed may be any message that needs to be pushed to the client. In this embodiment, the message to be pushed may be in the form of text, picture, file and the like.
[0062] It should be noted that the above-mentioned preset script processing method may be a method for executing a script. In this embodiment, the preset script processing method may be a Lua script processing method, wherein the Lua script processing method is a method for processing a Lua script, and the Lua script is a lightweight, efficient, and embeddable scripting language, which is commonly used in game development, embedded device control, Web development, and other fields. For example, when using a Lua script in Web development, the HTTP request can be processed through the Lua CGI library.
[0063] It should be noted that the above atomic operation can be an operation that binds the sequence increment operation and the push operation of the message to be pushed. In practical applications, after the sequence increment operation and the push operation of the message to be pushed are bound, the sequence increment operation and the push operation are executed as an indivisible whole, thereby ensuring the integrity and consistency of the operation. This solution can ensure the orderliness of distributed multi-instance push messages by binding the message sequence increment and the message push as atomic operations. Specifically, this solution has global orderliness in the single-user dimension, does not rely on machine timestamps, and supports distributed expansion.
[0064] Step S20: transmitting the atomic operation to a preset message write diffusion model to obtain a sequence of messages to be pushed.
[0065] In this embodiment, the above-mentioned preset message write diffusion model can be a model for message synchronization, such as the Timeline write diffusion model, which is suitable for scenarios where messages need to be pushed to multiple receiving ends efficiently. Among them, Timeline is generally understood as a logical model of a message queue, which is used to store and synchronize messages. In the Timeline model, each message has a unique sequence ID (SeqId) to ensure the orderliness and uniqueness of the message; write diffusion is also called push mode, which means that after the message is generated, it is not only written to the Timeline where the message is stored, but also written to the synchronization Timeline of the receiving end that needs to be synchronized, so that the receiving end can directly read the message from its synchronization Timeline without complicated pull operations.
[0066] In actual applications, after the atomic operation is transmitted to the preset message write diffusion model, a message sequence can be formed in the preset message write diffusion model based on these messages to be pushed, and the above-mentioned message sequence to be pushed is obtained. In this embodiment, the message sequence to be pushed is a monotonically increasing sequence, which supports message continuation and offline retransmission, and supports accurate once consumption semantics. In actual applications, when batch messages are pushed, if the connection is interrupted or the network fluctuates, the current push progress will be automatically recorded, and consumption can be continued from the last consumption after the subsequent reconnection is successful, so that the consumption progress of multiple clients does not interfere with each other.
[0067] Step S30: Pushing the message sequence to be pushed to the client through the preset message write diffusion model, wherein the message storage mechanism of the preset message write diffusion model supports multiple types of clients.
[0068] It should be understood that when the client needs to obtain information, it can send a message push request to the device. After receiving the message push request, the device can push the message sequence to be pushed to the corresponding client through the preset message write diffusion model. In this embodiment, Redis can be used in the preset message write diffusion model to implement user-dimensional message preservation, and at the same time, based on the offset of the Timeline message incremental sequence, maintain the reading rate of different clients. In addition, the Timeline message preservation mechanism of the user dimension in the preset message write diffusion model supports multiple clients and has zero cost for expansion, that is, the reading rate of different clients can be maintained by the message middle station based on the offset of the message incremental sequence, and supports zero-cost unlimited expansion.
[0069] In this embodiment, the message receiving service can ensure the isolation of consumption progress of different users and different clients through cursor management of consumption progress based on the message confirmation mechanism. At the same time, this solution can also perform batch pull and sequential push of messages. When the message push fails, it can be submitted in time to ensure accurate consumption without duplication. In addition, this solution can implement the message response mechanism based on TimeLine, and record the consumption progress of multiple clients in Redis to support message continuation and reception of offline message data.
[0070] In the specific implementation, refer to Figure 2 , Figure 2 This is a flowchart of the message processing method of this application using a preset message write diffusion model to process messages. Figure 2 As shown in the figure, the message center in this solution supports multi-terminal reception and multi-user message sending on the web side. It can use lightweight Lua script processing to bind the sequence increment and message push of messages sent by user A, user B and user C as atomic operations based on group management, session management, message routing, message broadcasting and breakpoint resumption, so as to support distributed expansion. When processing messages, the message to be pushed can be first transmitted to the preset message write diffusion model to obtain the sequence of messages to be pushed, where the sequence of messages to be pushed is monotonically increasing, such as Figure 2 As shown in Timeline D and Timeline E in . When users D and E need to obtain messages, the preset message write diffusion model can push the message sequences to be pushed in Timeline D and Timeline E to users D and E respectively, where both users D and E support multiple types of terminals.
[0071] Furthermore, the preset message write diffusion model is provided with: a length trimmer and an expiration checker; before the step S30, it also includes:
[0072] Step S301: updating the sequence of messages to be pushed in real time through the length trimmer and the expiration checker; wherein the length trimmer is used to manage the length of the sequence of messages to be pushed, and the expiration checker is used to delete expired messages from the sequence of messages to be pushed.
[0073] It should be noted that the Timeline-based length trimmer in this solution can automatically manage memory, support dynamic adjustment of the maximum length of the message queue, and control the size of batch pulls. Batch operations can greatly increase consumption speed and reduce network io.
[0074] It should be understood that the Timeline-based expiration checker in this solution can delete expired message data of the Timeline, thereby ensuring high-performance processing of messages.
[0075] In actual applications, the device can adjust the maximum length of the sequence of messages to be pushed through the timeline-based length trimmer, and delete expired messages in the sequence of messages to be pushed through the expiration checker, thereby updating the sequence of messages to be pushed and ensuring high-performance processing of messages.
[0076] In this embodiment, all messages in the sequence of messages to be pushed are based on a globally unique identifier, supporting the addition, deletion and modification of real-time messages. At the same time, this solution can add, delete and modify messages based on message semantics, and supports transparent transmission of messages to the client for processing by the client.
[0077] Accordingly, the step S30 includes:
[0078] Step S30': Pushing the updated sequence of messages to be pushed to the client through the preset message write diffusion model.
[0079] In the specific implementation, refer to Figure 3 , Figure 3 This is a flow chart of high-performance processing of real-time messages in the message processing method of this application. Figure 3 As shown, the preset message write diffusion model in this scheme is provided with: a length trimmer and an expiration checker, and the length trimmer and the expiration checker are designed and implemented based on Redis TimeLine. During message processing, after receiving the atomic operation sent by the user end, the preset message write diffusion model can obtain the sequence of messages to be pushed based on the messages to be pushed sent by the user, and then update the sequence of messages to be pushed through the length trimmer and the expiration checker therein, after which the client can pull messages from the preset message write diffusion model for consumption. In addition, in this embodiment, the fused message middle station can perform security control on the message processing process, and it can record the consumption status of the user ID and the client ID.
[0080] The present embodiment provides a message processing method, which discloses that when a message to be pushed is received, an atomic operation corresponding to the message to be pushed is generated through a preset script processing method, and the atomic operation is used to bind the message sequence self-increment and the message push; the atomic operation is transmitted to the preset message write diffusion model to obtain the message sequence to be pushed; the message sequence to be pushed is pushed to the client through the preset message write diffusion model, and the message saving mechanism of the preset message write diffusion model supports multiple types of clients; compared with the prior art method of implementing message processing in the back end using a RESTful API-based HTTP request polling method, which usually only allows a single client to access, since the present embodiment pushes the message sequence to be pushed to the client through the preset message write diffusion model, wherein the message saving mechanism of the preset message write diffusion model supports multiple types of clients, thereby solving the technical problem that the message processing method in the prior art is prone to incompatibility and inability to expand when multiple types of clients access, and is not practical.
[0081] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the above-mentioned embodiment 1 can be referred to the above introduction, and will not be repeated in the following. Figure 4 , Figure 4 A flowchart of the second embodiment of the message processing method of this application is provided.
[0082] In this embodiment, after step S30, the method further includes steps S40 to S60:
[0083] Step S40: During the message push process, the delayed message verifier performs message verification on the message sequence to be pushed, and determines the delayed push message in the message sequence to be pushed.
[0084] It should be understood that the above-mentioned delayed push message can be a message that needs to be delayed / scheduled pushed in the sequence of messages to be pushed. In this embodiment, the device can distribute messages based on session management, and a delayed message verifier is designed to be built in the delayed message sending model to verify the message that needs to be delayed, so as to determine the delayed push message in the sequence of messages to be pushed.
[0085] Step S50: Generate a distributed delayed message queue based on the delayed push message.
[0086] It should be noted that the above-mentioned distributed delayed message queue can be a message queue generated based on all delayed push messages in the sequence of messages to be pushed, wherein the delayed push messages in the distributed delayed message queue can also be an increasing sequence, which is not limited in this embodiment.
[0087] Step S60: Push the distributed delayed message queue to the client through a timed message processor.
[0088] It can be understood that the above-mentioned scheduled message processor can be a component used to perform scheduled sending processing on messages in a distributed delayed message queue.
[0089] Specifically, the step S60 includes: detecting in real time through a timing message processor whether there is a target delayed push message with a message push time of the current time in the distributed delayed message queue; if so, pushing the target delayed push message to the client; returning to execute the step of detecting in real time through a timing message processor whether there is a target delayed push message with a message push time of the current time in the distributed delayed message queue until all delayed push messages in the distributed delayed message queue are pushed to the client.
[0090] It should be understood that the above-mentioned target delayed push message can be a message in the distributed delayed message queue whose message push time is the current time. In practical applications, the timed message processor can detect whether there is a message in the distributed delayed message queue whose message push time is the current time. If so, the message is pushed to the client, thereby realizing the timed sending of the message in the distributed delayed queue.
[0091] In this embodiment, an event notification processor may also be provided in the device, which supports event response processing and relationship mapping processing between events and sent messages, and can save the mapping relationship in Redis and back it up to a MySQL data table.
[0092] In the specific implementation, refer to Figure 5 , Figure 5 This is a flowchart of delayed message processing in the message processing method of this application. Figure 5 As shown, first, the device can detect the delayed push messages in the queue of messages to be pushed through the delayed message verifier, and generate a distributed delayed queue based on these delayed push messages, and then the delayed push messages in the distributed delayed queue can be sent on a scheduled basis through the scheduled message processor. At the same time, in this embodiment, the delayed messages can also be processed based on a mutex lock, thereby ensuring the orderliness and uniqueness of the scheduled messages.
[0093] In the present embodiment, it is disclosed that in the process of message push, a delayed message verifier is used to perform message verification on a message sequence to be pushed to determine the delayed push message in the message sequence to be pushed; a distributed delayed message queue is generated based on the delayed push message; and the distributed delayed message queue is pushed to the client through a timed message processor, thereby realizing delayed message sending. At the same time, since a distributed delayed message queue is designed in this embodiment, the orderly and unique processing of delayed messages can be guaranteed.
[0094] Based on the first embodiment and / or the second embodiment of the present application, in the third embodiment of the present application, the same or similar contents as those in the above embodiments can be referred to the above introduction, and will not be described in detail later. Figure 6 , Figure 6 A flowchart of the third embodiment of the message processing method of this application is provided.
[0095] In this embodiment, the method further includes steps S100 to S200:
[0096] Step S100: uniformly mapping the user's to-be-processed messages to the target message processing thread bound to the user through a preset message mapping algorithm.
[0097] It should be noted that the above-mentioned preset message mapping algorithm can be an algorithm for mapping messages to a specified space. The preset message mapping algorithm in this embodiment may include but is not limited to a hash algorithm and a consistent hash algorithm, wherein the hash algorithm is an algorithm that converts data input of any length into data output of a fixed length through a hash function; the consistent hash algorithm can be an algorithm that maps data input to a fixed circular hash space.
[0098] It can be understood that the target message processing thread may be any thread for processing the message to be processed.
[0099] Step S200: Processing the to-be-processed message through the target message processing thread.
[0100] In this embodiment, a customized multi-queue thread binding thread pool can be used, and the user message load can be balanced and mapped to the specified thread (i.e., the target message processing thread mentioned above) through a hash algorithm or a consistent hash algorithm, so that user messages can be processed concurrently through multiple threads, thereby improving the concurrent processing capability and achieving high-performance message processing.
[0101] Furthermore, the user includes: a first user and a second user; the step S100 includes:
[0102] Determine a first message processing thread corresponding to a first user, and a second message processing thread corresponding to a second user; map a first to-be-processed message corresponding to the first user to the first message processing thread through a preset message mapping algorithm; map a second to-be-processed message corresponding to the second user to the second message processing thread through the preset message mapping algorithm.
[0103] The step S200 includes: processing the first message to be processed by the first message processing thread, and processing the second message to be processed by the second message processing thread.
[0104] In the specific implementation, refer to Figure 7 , Figure 7 Flow chart of multi-thread concurrent processing in the message processing method of this application. In this embodiment, a single user can be bound to a specified thread, such as Figure 7 As shown, first, the user message load can be balanced and mapped to the specified thread through the hash algorithm or the consistent hash algorithm. For example, the first pending messages user1:msg1 and user1:msg2 corresponding to the first user user1 are bound to the first message processing thread thread1, and the second pending messages user2:msg1 and user2:msg2 corresponding to the second user user2 are bound to the second message processing thread thread2. Then, the first message processing thread thread1 and the second message processing thread thread2 can be used to process the corresponding messages, thereby realizing multi-threaded concurrent message processing and improving message processing efficiency. After that, the client can pull messages in batches for consumption and submit the consumption progress when the consumption is successful.
[0105] Furthermore, the step S200 also includes: during the processing, detecting the socket processing capability of the target message processing thread in real time; when the socket processing capability does not meet the preset capability requirement, pulling the TimeLine thread to block in order to continue the message processing.
[0106] It should be noted that, in this embodiment, the data sending and receiving operations of the socket can be performed simultaneously in a single thread, thereby preventing concurrent security issues. In addition, since the socket operation has no additional lock mechanism, the message sending efficiency can be improved.
[0107] It should be noted that if Figure 7 As shown, in this solution, a blocking queue based on the producer-consumer model can be set up to achieve automatic back pressure. In addition, when the processing capacity of the socket is insufficient, the device can block the thread that pulls the timeline and wait for consumption to be completed, and continue to pull when consumption is completed.
[0108] In this embodiment, it is possible to support dynamic adjustment of the maximum length of the message queue and control the size of batch pull. Through batch operations, when messages are sent frequently, the consumption speed can be greatly improved and network io can be reduced.
[0109] In this embodiment, a preset message mapping algorithm is used to evenly map the user's pending messages to the target message processing thread bound to the user; the pending messages are processed by the target message processing thread, so that the messages can be processed concurrently through multiple threads, thereby achieving high-performance message processing.
[0110] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the message processing method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.
[0111] This application also provides a message processing device, please refer to Figure 8 , the message processing device comprises:
[0112] The atomic operation generation module 10 is used to generate the atomic operation corresponding to the message to be pushed by a preset script processing method when receiving the message to be pushed, and the atomic operation is used to bind the message sequence self-increment and the message push;
[0113] A message sequence acquisition module 20, used for transmitting the atomic operation to a preset message write diffusion model to obtain a message sequence to be pushed;
[0114] The message sequence pushing module 30 is used to push the message sequence to be pushed to the client through the preset message write diffusion model. The message saving mechanism of the preset message write diffusion model supports multiple types of clients.
[0115] The message processing device provided by the present application adopts the message processing method in the above embodiment, which can solve the technical problem that the message processing method in the prior art is easily incompatible and cannot be expanded when there are multiple types of client accesses, and is not practical. Compared with the prior art, the beneficial effects of the message processing device provided by the present application are the same as the beneficial effects of the message processing method provided by the above embodiment, and other technical features in the message processing device are the same as the features disclosed in the above embodiment method, which will not be repeated here.
[0116] The present application provides a message processing device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the message processing method in the above-mentioned embodiment one.
[0117] Reference below Fig. 9 , which shows a schematic diagram of the structure of a message processing device suitable for implementing an embodiment of the present application. The message processing device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Fig. 9 The message processing device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0118] like Fig. 9 As shown, the message processing device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the message processing device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the message processing device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows a message processing device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.
[0119] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0120] The message processing device provided by the present application adopts the message processing method in the above embodiment to solve the technical problem of message processing. Compared with the prior art, the beneficial effects of the message processing device provided by the present application are the same as the beneficial effects of the message processing method provided by the above embodiment, and other technical features in the message processing device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0121] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0122] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0123] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, wherein the computer-readable program instructions are used to execute the message processing method in the above-mentioned embodiment.
[0124] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.
[0125] The computer-readable storage medium may be included in the message processing device; or may exist independently without being assembled into the message processing device.
[0126] The above-mentioned computer-readable storage medium carries one or more programs. When the above-mentioned one or more programs are executed by the message processing device, the message processing device: when receiving a message to be pushed, generates an atomic operation corresponding to the message to be pushed through a preset script processing method, and the atomic operation is used to bind the message sequence self-increment and message push; transmits the atomic operation to a preset message write diffusion model to obtain a message sequence to be pushed; pushes the message sequence to be pushed to the client through the preset message write diffusion model, and the message saving mechanism of the preset message write diffusion model supports multiple types of clients.
[0127] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0128] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0129] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.
[0130] The readable storage medium provided by the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned message processing method, and can solve the technical problem that the message processing method in the prior art is easily incompatible and cannot be expanded when there are multiple types of client accesses, and is not practical. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as the beneficial effects of the message processing method provided by the above-mentioned embodiment, and will not be repeated here.
[0131] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.
Claims
1. A message processing method, characterized in that: The method includes: When receiving a message to be pushed, an atomic operation corresponding to the message to be pushed is generated through a preset script processing method, and the atomic operation is used to bind the message sequence self-increment and the message push; Transmitting the atomic operation to a preset message write diffusion model to obtain a sequence of messages to be pushed; The sequence of messages to be pushed is pushed to the client through the preset message write diffusion model, and the message saving mechanism of the preset message write diffusion model supports multiple types of clients.
2. The method according to claim 1, characterized in that The preset message write diffusion model is provided with: a length trimmer and an expiration checker; before the step of pushing the message sequence to be pushed to the client through the preset message write diffusion model, it also includes: The sequence of messages to be pushed is updated in real time by the length trimmer and the expiration checker; wherein the length trimmer is used to manage the length of the sequence of messages to be pushed, and the expiration checker is used to delete expired messages from the sequence of messages to be pushed; The step of pushing the sequence of messages to be pushed to the client through the preset message write diffusion model includes: The updated sequence of messages to be pushed is pushed to the client through the preset message write diffusion model.
3. The method according to claim 1, characterized in that After the step of pushing the message sequence to be pushed to the client through the preset message write diffusion model, the method further includes: During the message push process, the delayed message checker performs message check on the message sequence to be pushed to determine the delayed push message in the message sequence to be pushed; Generate a distributed delayed message queue based on the delayed push message; The distributed delayed message queue is pushed to the client through a timed message processor.
4. The method according to claim 3, characterized in that The step of pushing the distributed delayed message queue to the client through the timing message processor includes: Detect in real time through a timing message processor whether there is a target delayed push message with a message push time of the current time in the distributed delayed message queue; If so, the target delayed push message is pushed to the client; Return to the step of detecting in real time through the timing message processor whether there is a target delayed push message with a message push time of the current time in the distributed delayed message queue until all delayed push messages in the distributed delayed message queue are pushed to the client.
5. The method according to any one of claims 1 to 4, characterized in that The method further comprises: Evenly mapping the user's to-be-processed messages to the target message processing thread bound to the user through a preset message mapping algorithm; The to-be-processed message is processed by the target message processing thread.
6. The method according to claim 5, characterized in that The users include: a first user and a second user; the step of uniformly mapping the user's to-be-processed messages to the target message processing thread bound to the user by using a preset message mapping algorithm includes: Determine a first message processing thread corresponding to the first user, and a second message processing thread corresponding to the second user; Mapping the first to-be-processed message corresponding to the first user to the first message processing thread through a preset message mapping algorithm; Mapping the second to-be-processed message corresponding to the second user to the second message processing thread by using the preset message mapping algorithm; The step of processing the to-be-processed message through the target message processing thread includes: The first message to be processed is processed by the first message processing thread, and the second message to be processed is processed by the second message processing thread.
7. The method according to claim 5, characterized in that The step of processing the to-be-processed message through the target message processing thread includes: During the processing, the socket processing capability of the target message processing thread is detected in real time; When the socket processing capacity does not meet the preset capacity requirement, the TimeLine thread is blocked to continue message processing.
8. A message processing device, characterized in that: The device comprises: An atomic operation generation module, which is used to generate an atomic operation corresponding to the message to be pushed through a preset script processing method when receiving the message to be pushed, and the atomic operation is used to bind the message sequence self-increment and the message push; A message sequence acquisition module, used for transmitting the atomic operation to a preset message write diffusion model to obtain a message sequence to be pushed; The message sequence push module is used to push the message sequence to be pushed to the client through the preset message write diffusion model, and the message saving mechanism of the preset message write diffusion model supports multiple types of clients.
9. A message processing device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the message processing method according to any one of claims 1 to 7.
10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the message processing method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Message processing method and system, storage medium and computer device
CN107733778A
Message processing method and related product
CN117201445A
Data information pushing method based on Timeline model, gateway and related equipment
CN117714532A
Distributing multi-source push notifications to multiple targets
US20130067024A1