Message processing method and device

Through message duplication check, memory cache and database dual storage, SQLite's WAL mode and delay refresh strategy, the problems of message duplication in high concurrent message processing, large database write overhead and frequent UI refresh are solved, and efficient and stable messages are achieved Processing and page sliding fluency.

CN113778321BActive Publication Date: 2024-11-15BEIJING WODONG TIANJUN INFORMATION TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110054031.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-01-15
Publication Date
2024-11-15
Estimated Expiration
2041-01-15

AI Technical Summary

Technical Problem

In the high concurrent message processing scenario, the prior art has problems such as repeated message sending, large overhead of database writing, increased disk read and write caused by index miss when reading messages, and excessive number of UI refreshes, resulting in page stuttering.

Method used

Through message duplication checking, optimized write performance, query performance and UI refresh conditions, one duplicate checking, memory cache and database dual storage, SQLite's WAL mode, delay refresh strategy and sliding stop refresh strategy are used to ensure the efficiency of message processing and stability.

Benefits of technology

It effectively reduces the system overhead of high concurrent message processing, improves processing efficiency, reduces the risk of crashes, and improves page sliding fluency and database query performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113778321B_ABST
    Figure CN113778321B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for message processing, and relates to the field of computer technology. A specific implementation of the method includes: receiving a message sent from a server; performing a duplicate check on the message to confirm whether the message is in a state of waiting for processing or being processed; when the message is not in a state of waiting for processing or being processed, merging the message into a message queue based on the order in which the message arrives, and processing the messages in the message queue in order; and displaying the processed message on a display page. This implementation reduces the system overhead of high-concurrency message processing, improves the efficiency of high-concurrency message processing, and reduces the crash problem of instant messaging in high-concurrency message processing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method and device for message processing, and in particular to a method and device for high-concurrency message processing that can be used for instant messaging. Background Art

[0002] In the field of instant messaging, message processing, especially high-concurrency message processing, is common. In a high-concurrency message application environment, a large number of messages are received from the server in a short period of time. If these messages cannot be displayed on the display page (UI) in a timely and fast manner, these messages cannot be replied to in time, which may cause the accumulation of pending messages and delays in message processing.

[0003] Traditionally, for high-concurrency message application scenarios, the following is usually used: Fig.10 The message processing method shown in the figure. Messages are received from the server, and the messages enter the queue in the order of arrival and are processed in sequence; after the message processing is completed, the message is stored in the database and displayed on the display page.

[0004] However, the inventors have found that there are at least the following problems in the above-mentioned traditional message processing method:

[0005] (1) Messages are sent repeatedly, resulting in repeated processing of messages;

[0006] (2) Due to the characteristics of instant messaging, opening a database transaction cannot significantly reduce the system overhead of writing to the database;

[0007] (3) When reading messages, if the index misses, it will cause additional disk reads and writes;

[0008] (4) In high-concurrency message scenarios, the UI refreshes too many times in a short period of time, causing page freezes. Summary of the invention

[0009] In view of this, an embodiment of the present invention provides a message processing method and a message processing device, which can reduce the system overhead of high-concurrency message processing, improve the efficiency of high-concurrency message processing, and reduce the crash problem of instant messaging in high-concurrency message processing.

[0010] To achieve the above-mentioned purpose, according to one aspect of an embodiment of the present invention, a method for message processing is provided, comprising: receiving a message sent from a server; performing a duplicate check on the message to confirm whether the message is in a state of waiting for processing or being processed; when the message is not in a state of waiting for processing or being processed, merging the message into a message queue based on the order in which the message arrives, and processing the messages in the message queue in the order; and displaying the processed message on a display page.

[0011] Preferably, according to the message processing method of one aspect of an embodiment of the present invention, the processed message is stored before being displayed on the display page, and the storing includes storing the processed message in a memory cache and a database in sequence.

[0012] Preferably, according to the message processing method of one aspect of an embodiment of the present invention, before processing the message in the message queue, a second duplicate check is performed to confirm whether the message has been stored in the memory cache; when the message is not stored in the memory cache, a third duplicate check is performed to confirm whether the message has been stored in the database; and when the message is not stored in the database, the message is processed.

[0013] Preferably, in the message processing method according to one aspect of an embodiment of the present invention, the database is SQLite, and the write mode of SQLite is set to WAL mode.

[0014] Preferably, according to the message processing method of one aspect of an embodiment of the present invention, before displaying the processed message on the display page, a target message is extracted, and the target message is queried in the memory cache, and when the target message is found, the target message is displayed on the display page; when the target message is not found in the memory cache, a further query is performed in the database, and the queried target message is displayed on the display page.

[0015] Preferably, according to the message processing method of one aspect of an embodiment of the present invention, the message that has been processed is sent to the display queue of the display page, and a display page refresh operation is performed based on the time difference between the time point when the message that has been processed arrives at the display queue and the last refresh and a predetermined refresh threshold.

[0016] Preferably, according to the message processing method of one aspect of an embodiment of the present invention, performing a display page refresh operation according to the time difference and a predetermined refresh threshold includes: when the time difference is greater than or equal to the refresh threshold, directly performing the display page refresh operation; and when the time difference is less than the refresh threshold and the sum of the time difference and the predetermined delay duration is greater than the refresh threshold, performing the display page refresh operation at a time point past the refresh threshold from the last refresh.

[0017] Preferably, according to the message processing method of one aspect of an embodiment of the present invention, performing a display page refresh operation according to the time difference and a predetermined refresh threshold includes: when the time difference is less than the refresh threshold and the sum of the time difference and the predetermined delay time is less than the refresh threshold, generating a delayed refresh instruction and performing the display page refresh operation at a time point after a predetermined delay time has passed since the time point when the processed message arrives at the display queue, wherein when performing the display page refresh operation, other delayed refresh instructions that have been generated are canceled.

[0018] Preferably, according to the message processing method of one aspect of an embodiment of the present invention, when the user slides the display page, the display page is not refreshed.

[0019] Preferably, according to a message processing method of one aspect of an embodiment of the present invention, a mark is added to the message that is confirmed by the one duplicate check to be not in a state of waiting for processing or being processed, for retrieval in subsequent operations.

[0020] According to another aspect of an embodiment of the present invention, there is provided a device for message processing, comprising: a receiving module for receiving a message sent from a server; a duplicate checking module for performing a duplicate checking on the message to confirm whether the message is in a state of waiting for processing or being processed; a queue module, when the message is not in a state of waiting for processing or being processed, the queue module merges the message into a message queue based on the order in which the message arrives at the receiving module, and processes the messages in the message queue in the order; and a display module for displaying the processed message on a display page.

[0021] According to another aspect of an embodiment of the present invention, there is provided an electronic device for message processing, comprising: one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the message processing method described in one aspect of an embodiment of the present invention.

[0022] According to yet another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the message processing method according to one aspect of an embodiment of the present invention is implemented.

[0023] The present invention provides an effective high-concurrency message processing method through four aspects: message duplication checking, write performance optimization, query performance optimization, and message UI refresh condition optimization. The message processing method constructed by the present invention, in addition to normal operation in ordinary low-concurrency scenarios, can also solve the technical problems encountered in high-concurrency performance message processing in most scenarios, and construct a stable and efficient message processing method and message processing device that can be used for instant messaging.

[0024] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.

[0026] Figure 1 is a schematic diagram of the main flow of the message processing method according to an embodiment of the present invention;

[0027] Figure 2 is a schematic diagram of main modules of a message processing device according to an embodiment of the present invention;

[0028] Figure 3 It is a schematic diagram mainly showing a duplicate check in a message processing method according to an embodiment of the present invention;

[0029] Figure 4 It is a schematic diagram mainly showing the process of one-time duplicate checking, two-time duplicate checking and three-time duplicate checking in the message processing method according to an embodiment of the present invention;

[0030] Figure 5 It is a schematic diagram showing the logic of adding, deleting, modifying and checking a database in a message processing method according to an embodiment of the present invention;

[0031] Figure 6 is a schematic diagram showing a logic of delayed refresh of a display page in a message processing method according to an embodiment of the present invention;

[0032] Figure 7 is a schematic diagram showing a specific example of the overall flow of the message processing method according to an embodiment of the present invention;

[0033] Figure 8 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;

[0034] Fig. 9 It is a schematic diagram of the structure of a terminal device or a server-side computer system suitable for implementing an embodiment of the present invention;

[0035] Fig.10 It is a schematic diagram of the traditional message processing method. DETAILED DESCRIPTION

[0036] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0037] Figure 1 is a schematic diagram of the main flow of the message processing method according to an embodiment of the present invention, and Figure 3 It is a schematic diagram mainly showing a duplicate check in the message processing method according to an embodiment of the present invention.

[0038] In the traditional message processing method, after a message is processed and stored in the database, the client will send a receipt to the server. After receiving the receipt, the server will no longer send the message to the client again. However, in real scenarios, when the client has received the message, but the message processing is too slow or network packet loss occurs, resulting in the receipt sent not being received by the server, the server may not receive the message receipt in time. In this case, since the server cannot distinguish the specific reason for not receiving the receipt, it generally determines that the client has not received the message, and then sends the message to the client again. Repeated processing of messages is a waste of resources. At the same time, since the message queue to be processed is a serial queue, the messages will be queued in the queue in the order of time reception. If the server repeatedly sends the message because it has not received the client receipt for a long time, in extreme cases, a large number of duplicate messages will appear in the message queue, the pressure on the message queue will increase, and the memory will surge, causing the system to crash.

[0039] To solve the above problems, Figure 1 and Figure 3 As shown, the message processing method according to an embodiment of the present invention includes: receiving a message sent from a server; performing a duplicate check on the message to confirm whether the message is in a state of waiting for processing or being processed; when the message is not in a state of waiting for processing or being processed, merging the message into a message queue based on the order in which the message arrives, and processing the messages in the message queue in order; and displaying the processed message on a display page. The above processing refers to extracting fields of the message, such as the sender of the message, the sending time of the message, the content of the message, etc.

[0040] In a preferred embodiment of the present invention, the processed message is stored, the message is stored in the memory cache and the database in sequence, and the message is removed from the message queue, and then the message is displayed on the display page. The processed message is first stored in the memory cache, and batch-processed and stored in the database in a timely / quantitative manner. The processed messages stored in the memory cache are updated and replaced according to the capacity of the memory cache. After the message is stored in the database, a receipt is sent to the server to inform the server that the message has been received. After receiving the receipt, the server will no longer send the message repeatedly.

[0041] Figure 4 1 is a schematic diagram mainly showing the process of one-time duplicate checking, two-time duplicate checking and three-time duplicate checking in the message processing method according to an embodiment of the present invention. Figure 4 As shown, before processing the message in the message queue, a second duplicate check is performed to confirm whether the message has been stored in the memory cache; when the message is not stored in the memory cache, a third duplicate check is performed to confirm whether the message has been stored in the database (for example, by querying through SQL (Structured Query Language)); and when the message is not stored in the database, the message is processed.

[0042] During the first duplicate check of a message, if it is confirmed that the message is in the waiting or processing state in the message queue, then the message is determined to be a duplicate message and is directly discarded. A mark can be added to the message that passes the first duplicate check for subsequent duplication checks and / or retrieval during reading. During the second duplicate check of a message, if it is confirmed that a message has been stored in the memory cache, then the message is also determined to be a duplicate message and is directly discarded. Similarly, during the third duplicate check of a message, if it is confirmed that a message has been stored in the database, then the message is also determined to be a duplicate message and is directly discarded.

[0043] That is to say, if the message has been determined to be a duplicate message during a duplicate check, the message can be directly discarded, and the message no longer enters the message queue for subsequent processing. When the message passes a duplicate check (i.e., confirming that the message is not in a state of waiting for processing or being processed in the message queue), a secondary duplicate check is performed. If the message has been determined to be a duplicate message during the secondary duplicate check, the message can be directly discarded, and the message no longer undergoes three duplicate checks and subsequent processing. In this way, if the existence of the message is confirmed in the memory cache, a database query can be reduced, saving database I / O time. Only when the message passes a duplicate check, a secondary duplicate check, and a triple duplicate check, that is, the message is neither in a state of waiting for processing or being processed in the message queue nor in a state of being processed and stored in the memory cache and / or database, the message is processed, and fields such as the sender, the sending time, and the content of the message are extracted.

[0044] After the message is processed, it needs to be stored in the database. The write operation of the database belongs to the input / output (I / O) operation of the data file. Frequent writing of data will cause the file to be opened and closed frequently, which will greatly reduce performance. A common optimization method is to enable database transactions. The so-called database transaction is a batch storage method. By enabling database transactions, the data is first cached in the memory. When the database transaction is submitted, all the data cached in the memory is updated to the database file at one time. At this time, the database file only needs to be opened and closed once, which also avoids the problem of poor performance caused by long-term occupation of file I / O. However, for instant messaging systems, in most cases (i.e., ordinary low-concurrency message scenarios), messages do not arrive in batches, but are sent one by one. In addition, due to the characteristics of message arrival, the final situation will become more complicated due to network conditions. In this case, since the database transaction is enabled, it is necessary to cache the processed messages in the memory first, and batch process the messages accumulated in the memory into the database regularly or quantitatively. This requires additional logic implementation, which will increase the complexity of the code and increase the maintenance cost.

[0045] To solve the above problem, according to a preferred embodiment of the present invention, the database is SQLite (a lightweight database), and the write mode of SQLite is set to WAL (Write-Ahead Log) mode.

[0046] Compared with the default rollback mode, WAL mode has the following advantages: in most cases, writing is faster using WAL mode; WAL mode further improves the concurrency of the database, because reading does not block writing, and writing does not block reading, and reading and writing can be executed concurrently; using WAL mode, disk I / O operations are more orderly; using WAL mode reduces the number of fsync() (function synchronizes all modified file data in memory to the storage device) operations, so it is not easily affected by the fsync() system call (system call) interrupt on the system.

[0047] Specifically, you can use the following code to enable WAL mode:

[0048] PRAGMA journal_mode=WAL.

[0049] When reading in WAL mode, SQLite will first search in the -wal file (write-through file) to find the last write point, remember the write point, and ignore the write points after that (this ensures concurrent read and write and concurrent read and read execution). Then, it determines whether the page where the data to be read is located exists in the -wal file. If it exists, it reads the data in the -wal file. If it does not exist, it directly reads the data in the database file. In order to avoid scanning the entire -wal file to find the page for each read operation, SQLite provides a WAL-index (write-through index) file to assist in page search. The WAL-index file uses the technology of shared memory between processes. Shared memory is a file ending with .shm and in the same directory as the database file. This file is special. There is a mapping relationship between memory and file. After obtaining the address of this file, it can be read and written like memory, while general files need to call read (read) and write (write) functions to read and write. WAL-index can help read operations quickly locate pages in the -wal file, greatly improving the performance of reading. In the scenario where reading does not affect writing, it can further significantly improve the write performance of the database.

[0050] Figure 5 The diagram is a schematic diagram showing the logic of adding, deleting, modifying and checking a database according to an embodiment of the present invention.

[0051] After the processed message is stored in the database, when the page for displaying the processed message is displayed, the message needs to be searched in the database and extracted, that is, the data in the database needs to be read. If the database is queried by the message ID every time, all messages in the database need to be traversed for matching. Therefore, as the number of messages in the database increases, the query speed will become slower and slower. A conventional optimization method is to add indexes. Common relational databases all provide indexes. Adding indexes appropriately can improve the reading performance of the database. However, although the reading performance of the database can be improved by adding indexes, disk I / O is still required when the database's own cache misses, and disk I / O is very time-consuming.

[0052] To solve the above problem, according to a preferred embodiment of the present invention, before displaying the processed message on the display page, the target message (the message to be displayed) is extracted. Figure 5The target message is queried in the memory cache layer in the memory cache. When the target message is found, the target message is returned for display on the page. At this time, one database read operation can be reduced. The memory cache can use a simple key-value (distributed storage system) structure, and the key (keyword) is the primary key (PrimaryKey, or other unique key, which should often be used as a query condition). When the target message is not hit in the memory cache, further search in the database ( Figure 5 The query is performed in the DB layer in the database, and the queried target message is first updated to the memory cache and then returned to be displayed on the display page.

[0053] According to a preferred embodiment of the present invention, the Where condition can also be used to directly query the database and return the relevant data of the message to be displayed on the display page. Similarly, when writing and updating data, as described above, the data can be first written / updated to the memory cache layer, and then the data can be written / updated to the database.

[0054] Figure 6 It is a schematic diagram showing the logic of delayed refresh of a display page in a message processing method according to an embodiment of the present invention.

[0055] After the message is processed, the next step is to display the message on the UI. If the page is refreshed immediately after each message is processed, there is no big problem in ordinary low-concurrency scenarios, but in high-concurrency scenarios, it will cause too many UI refreshes in a short period of time, resulting in page freezes.

[0056] To solve the above problems, Figure 6 As shown, according to a preferred embodiment of the present invention, the message of completed processing is sent to the display queue of the display page, and the display page refresh operation is performed based on the time difference between the time point when the message of completed processing arrives at the display queue and the last refresh and a predetermined refresh threshold.

[0057] Specifically, performing a display page refresh operation according to the time difference and a predetermined refresh threshold includes: when the time difference is greater than or equal to the refresh threshold, directly performing the display page refresh operation; and when the time difference is less than the refresh threshold and the sum of the time difference and the predetermined delay duration is greater than the refresh threshold, performing the display page refresh operation at a time point past the refresh threshold from the last refresh.

[0058] For example, the refresh threshold can be set to 2000ms and the predetermined delay time can be set to 100ms. When message A arrives, the time difference from the last refresh is equal to 2000ms, and the display page refresh operation is directly performed. When message A arrives, the time difference from the last refresh is equal to 2500ms, and the display page refresh operation is also directly performed.

[0059] If the time difference from the last refresh is less than the refresh threshold (for example, 1950ms) and the sum of the time difference from the last refresh and the predetermined delay duration is greater than the refresh threshold (that is, 1950ms+100ms>2000ms), then a display page refresh operation is performed at a time point after the refresh threshold has passed since the last refresh (2000ms from the last refresh).

[0060] Specifically, performing a display page refresh operation according to the time difference and a predetermined refresh threshold includes: when the time difference is less than the refresh threshold and the sum of the time difference and the predetermined delay time is less than the refresh threshold, generating a delayed refresh instruction and performing the display page refresh operation at a time point after a predetermined delay time has passed since the time point when the processed message arrives at the display queue, wherein when performing the display page refresh operation, other delayed refresh instructions that have been generated are canceled.

[0061] For example, if the time difference from the last refresh when message A arrives is less than 2000ms (for example, 1600ms) and the sum of the time difference from the last refresh and the predetermined delay time is less than the refresh threshold (i.e., 1600ms+100ms<2000ms), a delayed refresh instruction is generated and a display page refresh operation is performed at a time point after a predetermined delay time has passed since the time when message A arrives at the display queue (i.e., 1600ms+100ms=1700ms from the last refresh). If there is message B at the same time, and the time difference from the time when it arrives at the display queue to the last refresh is 1650ms, a delayed refresh instruction will be generated at 1750ms. When the 1700ms delayed refresh instruction generated by message A is executed and a display page refresh operation is performed, the 1750ms delayed refresh instruction generated by message B will be canceled, that is, the display page refresh operation will not be performed at 1750ms.

[0062] According to a preferred embodiment of the present invention, when a user slides a display page (such as a conversation list / conversation page message list), the display page is not refreshed, and the page is refreshed only when the sliding of the display page stops. This ensures the smoothness of the sliding of the display page.

[0063] Figure 7 FIG. 2 is a schematic diagram showing a specific example of the overall process of the message processing method according to an embodiment of the present invention. Figure 7 As shown, a message sent from a server is received. Then, a duplicate check is performed on the message to confirm whether the message is in a state of waiting for processing or being processed. When it is confirmed that the message is in a state of waiting for processing or being processed in the message queue, the message is determined to be a duplicate message and is directly discarded; when the message is not in a state of waiting for processing or being processed, the message is merged into the message queue based on the order in which the message arrives. Then, a second duplicate check is performed to confirm whether the message has been stored in the memory cache. When it is confirmed that the message has been stored in the memory cache, the message is also determined to be a duplicate message and is directly discarded; when the message is not stored in the memory cache, a third duplicate check is performed to confirm whether the message has been stored in the database (for example, by querying through SQL). When it is confirmed that a message has been stored in the database, the message is also determined to be a duplicate message and is directly discarded; and when the message is not stored in the database, the message is processed. The processed messages are first cached in the memory cache, and the processed messages stored in the memory cache are batched and stored in the database in a timely / quantitative manner. At this time, the message queue notifies the UI queue that there is a new message, and performs a display page refresh operation according to the time difference between the time point when the processed message arrives at the display queue and the last refresh and a predetermined refresh threshold.

[0064] Figure 2 Schematic diagram of main modules of a message processing device according to an embodiment of the present invention. Figure 2 As shown, the message processing device 200 includes:

[0065] Receiving module 201, used to receive a message sent from the server;

[0066] A duplicate checking module 202 is used to check the message for duplicates and confirm whether the message is in a state of waiting to be processed or being processed;

[0067] A queue module 203, when the message is not in a state of waiting for processing or being processed, the queue module merges the message into a message queue based on the order in which the message arrives at the receiving module 201, and processes the messages in the message queue in the order; and

[0068] The display module 204 is used to display the message of the completed processing on the display page.

[0069] The queue module 203 adds a mark to the message that is confirmed by a duplicate check to be not in a waiting or being processed state, for retrieval in subsequent operations.

[0070] Before displaying the processed message on the display page, the message processing device 200 can use a storage module (not shown) to store the processed message, and store the processed message in the memory cache and the database in sequence. The database is SQLite, and the write mode of SQLite is set to WAL mode.

[0071] In addition, before processing, the queue module 203 performs a second check for duplicates to confirm whether the message has been stored in the memory cache; when the message is not stored in the memory cache, a third check for duplicates is performed to confirm whether the message has been stored in the database; and when the message is not stored in the database, the queue module 203 processes the message.

[0072] Before the display module 204 displays the processed message on the display page, the extraction module (not shown) extracts the target message, searches the memory cache for the target message, and displays the target message on the display page when the target message is found. When the target message is not found in the memory cache, the extraction module further searches the database and displays the found target message on the display page.

[0073] The display module 204 receives the target message extracted by the extraction module and merges it into the display queue, and performs a display page refresh operation according to the time difference between the time point when the target message (the message that has been processed) arrives at the display queue and the last refresh and the predetermined refresh threshold. When the time difference is greater than or equal to the refresh threshold, the display module 204 directly performs a display page refresh operation. And when the time difference is less than the refresh threshold and the sum of the time difference and the predetermined delay duration is greater than the refresh threshold, the display module 204 performs a display page refresh operation at the time point after the last refresh passes the refresh threshold. When the time difference is less than the refresh threshold and the sum of the time difference and the predetermined delay duration is less than the refresh threshold, the display module 204 generates a delayed refresh instruction and performs a display page refresh operation at the time point after the predetermined delay duration from the time point when the target message (the message that has been processed) arrives at the display queue. When the display module 204 performs a display page refresh operation, it cancels other delayed refresh instructions that have been generated. When the user slides the display page, the display module 204 does not perform a display page refresh operation.

[0074] Figure 8 An exemplary system architecture 800 is shown to which the message processing method or message processing apparatus according to the embodiment of the present invention can be applied.

[0075] like Figure 8As shown, the system architecture 800 may include terminal devices (e.g., clients receiving messages) 801, 802, 803, a network 804, and a server (e.g., a server sending messages) 805. The network 804 is used to provide a medium for communication links between the terminal devices 801, 802, 803 and the server 805. The network 804 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.

[0076] Users can use terminal devices 801, 802, and 803 to interact with server 805 through network 804 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 801, 802, and 803, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0077] The terminal devices 801 , 802 , and 803 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0078] The server 805 may be a server that provides various services, such as a background management server that provides support for shopping websites browsed by users using the terminal devices 801, 802, and 803. The background management server may send received messages to the terminal device.

[0079] It should be noted that the message processing method provided in the embodiment of the present invention is generally executed by terminal devices (for example, clients receiving messages) 801, 802, 803, and accordingly, the message processing apparatus is generally arranged in the terminal devices 801, 802, 803.

[0080] It should be understood that Figure 8 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0081] Reference below Fig. 9 , which shows a schematic diagram of the structure of a computer system 900 of a terminal device suitable for implementing an embodiment of the present invention. Fig. 9 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.

[0082] like Fig. 9As shown, the computer system 900 includes a central processing unit (CPU) 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage part 908 into a random access memory (RAM) 903. In the RAM 903, various programs and data required for the operation of the system 900 are also stored. The CPU 901, the ROM 902, and the RAM 903 are connected to each other via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0083] The following components are connected to the I / O interface 905: an input section 906 including a keyboard, a mouse, etc.; an output section 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, a modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage section 908 as needed.

[0084] In particular, according to the embodiments disclosed in the present invention, 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 invention 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 the network through the communication part 909, and / or installed from the removable medium 911. When the computer program is executed by the central processing unit (CPU) 901, the above-mentioned functions defined in the system of the present invention are executed.

[0085] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, 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 the present invention, a 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, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0086] 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 invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a 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 box can also occur in a different order from the order marked in the accompanying drawings. For example, two 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 box in the block diagram or flow chart, and the combination of the boxes in the block diagram 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.

[0087] The modules involved in the embodiments of the present invention may be implemented by software or hardware. The modules described may also be arranged in a processor, for example, they may be described as: a processor including a receiving module, a duplicate checking module, a queue module and a display module. The names of these modules do not constitute limitations on the modules themselves in certain cases, for example, the receiving module may also be described as a "module for receiving messages from a server".

[0088] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: receiving a message sent from a server; performing a duplicate check on the message to confirm whether the message is in a state of waiting for processing or being processed; when the message is not in a state of waiting for processing or being processed, merging the message into a message queue based on the order in which the message arrives, and processing the messages in the message queue in order; and displaying the processed message on a display page.

[0089] The present invention provides an effective high-concurrency message processing method through four aspects: message duplication checking, write performance optimization, query performance optimization, and message UI refresh condition optimization. The message processing method constructed by the present invention, in addition to normal operation in ordinary low-concurrency scenarios, can also solve the technical problems encountered in high-concurrency performance message processing in most scenarios, and construct a stable and efficient message processing method and message processing device that can be used for instant messaging.

[0090] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A message processing method, characterized in that: include: Receive messages sent by the server; Perform a duplicate check on the message to confirm whether the message is in a state of waiting to be processed or being processed; When the message is not in a state of waiting for processing or being processed, merging the message into a message queue based on the order in which the message arrives; Performing a second duplicate check on the message to confirm whether the message has been stored in the memory cache; if the message is not stored in the memory cache, performing a third duplicate check to confirm whether the message has been stored in the database; When the message is not stored in the database, processing the messages in the message queue in the order; as well as The processed messages are stored in the memory cache and the database in sequence, and the processed messages are displayed on a display page.

2. The message processing method according to claim 1, characterized in that: The database is SQLite, and the write mode of SQLite is set to WAL mode.

3. The message processing method according to claim 1, characterized in that: Before displaying the processed message on the display page, extracting the target message, Querying the target message in the memory cache, and when the target message is found, displaying the target message on the display page; When the target message is not found in the memory cache, a further query is performed in the database, and the queried target message is displayed on the display page.

4. The message processing method according to claim 1, characterized in that: The processed message is sent to the display queue of the display page, and a display page refresh operation is performed according to the time difference between the time point when the processed message arrives at the display queue and the last refresh and a predetermined refresh threshold.

5. The message processing method according to claim 4, characterized in that: Performing a display page refresh operation according to the time difference and a predetermined refresh threshold comprises: When the time difference is greater than or equal to the refresh threshold, directly performing the display page refresh operation; and When the time difference is smaller than the refresh threshold and the sum of the time difference and the predetermined delay time is larger than the refresh threshold, the display page refresh operation is performed at a time point after the refresh threshold has passed since the last refresh.

6. The message processing method according to claim 4, characterized in that: Performing a display page refresh operation according to the time difference and a predetermined refresh threshold comprises: When the time difference is less than the refresh threshold and the sum of the time difference and the predetermined delay time is less than the refresh threshold, a delayed refresh instruction is generated and the display page refresh operation is performed at a time point after a predetermined delay time has elapsed since the time point when the processed message arrives at the display queue, Wherein, when the display page refresh operation is performed, other generated delayed refresh instructions are cancelled.

7. The message processing method according to any one of claims 4 to 6, characterized in that: When the user slides the display page, the display page refresh operation is not performed.

8. The message processing method according to claim 1, characterized in that: A mark is added to the message that is confirmed by the duplicate check to be not in the state of waiting for processing or being processed, for retrieval in subsequent operations.

9. A message processing device, characterized in that: include: The receiving module is used to receive messages sent from the server; A duplicate checking module is used to check the message for duplicates and confirm whether the message is in a state of waiting to be processed or being processed; A queue module, when the message is not in a state of waiting for processing or being processed, the queue module merges the message into a message queue based on the order in which the message arrives at the receiving module, performs a secondary duplicate check on the message to confirm whether the message has been stored in the memory cache; when the message is not stored in the memory cache, performs a tertiary duplicate check to confirm whether the message has been stored in the database; when the message is not stored in the database, processes the messages in the message queue in the order; as well as The display module is used to display the processed message on the display page.

10. An electronic device for message processing, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 8.

11. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.