Message processing method and device, equipment and storage medium
By collecting and publishing messages from the persistent data bus in the message server and generating message indexes and push queue lists, the problems of high stability requirements and message loss in traditional message push technology are solved, and higher message push reliability is achieved.
Patent Information
- Application Number
- CN202311332343.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-16
- Publication Date
- 2025-04-18
AI Technical Summary
In traditional message push technology, the stability requirements of the message server are high, and messages are easily lost due to fault restarts and other conditions, making it difficult to ensure the reliability of message push.
By collecting publishing messages from the persistent data bus, determining the corresponding push access terminal and message sequence number, persisting the message in the message file, and generating a message index and push queue list, which are stored in memory to quickly find and push messages.
This method improves the reliability of message push, avoids message loss caused by fault restart, and quickly regenerates consistent message index and push queue list after the server restarts.
Smart Images

Figure CN119854096A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information technology, and in particular to a message processing method, apparatus, computer equipment, storage medium and computer program product. Background Art
[0002] With the development of information technology, the number of network messages has exploded, and users' demand for obtaining messages has also increased. In order to meet users' demand for obtaining messages, message providers often push messages to users' access terminals through message servers.
[0003] Among them, in traditional message push technology, the message server usually forms a message queue for the received messages and pushes them to the corresponding access terminal in order. However, this method has extremely high requirements on the stability of the message server. When the message server encounters a failure and restarts, it is easy to cause message loss, and it is difficult to ensure the reliability of message push. Summary of the invention
[0004] Based on this, it is necessary to provide a message processing method for the above technical problems.
[0005] In a first aspect, the present application provides a message processing method. The method comprises:
[0006] Determine the push access terminal and message sequence number corresponding to the published message according to the published message received from the persistent data bus;
[0007] Persistently storing the published message in a message file;
[0008] Generate a message index according to the message sequence number corresponding to the published message and the position in the message file, and store the message index in a memory;
[0009] The message sequence number of the published message is added to the push queue table corresponding to the push access terminal stored in the memory.
[0010] In one of the embodiments, the method further includes: generating a database operation instruction according to the message sequence number corresponding to the published message and the position in the message file; creating a database transaction including the database operation instruction; executing the database transaction in an in-memory database; generating a message index according to the message sequence number corresponding to the published message and the position in the message file, and storing the message index in the memory, including: when executing the database transaction, writing the message sequence number corresponding to the published message and the position in the message file in a message index table in the in-memory database according to the database operation instruction to form a message index; adding the message sequence number of the published message to a push queue table corresponding to the push access terminal stored in the memory, including: when executing the database transaction, writing the message sequence number of the published message into the push queue table corresponding to the push access terminal in the in-memory database according to the database operation instruction.
[0011] In one of the embodiments, the method further includes: obtaining an access terminal identifier of the push access terminal based on the sign-in information of the push access terminal; querying a push queue list corresponding to the push access terminal in a memory based on the access terminal identifier, and obtaining a message sequence number of the message to be pushed from the push queue list; querying a message index in a memory based on the message sequence number of the message to be pushed, and obtaining location information of the message to be pushed in a persistently stored message file based on the message index; obtaining the message to be pushed from the message file based on the location information; and pushing the message to be pushed to the push access terminal.
[0012] In one of the embodiments, obtaining the message sequence number of the message to be pushed includes: obtaining the pushed message sequence number corresponding to the push access terminal according to the check-in information of the push access terminal; obtaining the maximum message sequence number in the push queue list; when the maximum message sequence number is greater than the pushed message sequence number, taking all message sequence numbers in the push queue list that are greater than the pushed message sequence number as the message sequence number of the message to be pushed; after pushing the message to be pushed to the push access terminal, it also includes: updating the pushed message sequence number in the check-in information of the push access terminal according to the message sequence number of the message to be pushed.
[0013] In one of the embodiments, the method further includes: updating the confirmation message sequence number in the sign-in information of the push access terminal according to the message confirmation information received from the push access terminal; when the maximum message sequence number is greater than the pushed message sequence number, before using all messages corresponding to message sequence numbers greater than the pushed message sequence number in the push queue list as the push message, it also includes: obtaining the confirmation message sequence number corresponding to the push access terminal according to the sign-in information of the push access terminal; when the difference between the pushed message sequence number and the confirmation message sequence number is greater than a preset value, using the confirmation message sequence number as the pushed message sequence number.
[0014] In one of the embodiments, the method further includes: sending a heartbeat signal to a push access terminal storing sign-in information according to a set first time period; upon receiving a sign-in request sent by the push access terminal, establishing a connection with the push access terminal, and checking whether the sign-in information of the push access terminal is stored; if not, adding the sign-in information of the push access terminal; wherein the sign-in request is sent by a push access terminal that has not sent the sign-in request, or is sent by a push access terminal that has sent the sign-in request but has not received the heartbeat signal and has not received the push message within a second time period.
[0015] In one of the embodiments, the method further includes: upon receiving a sign-out request sent by the push access terminal, or upon not receiving a confirmation message sent by the push access terminal within a third time period after pushing the message to be pushed to the push access terminal, disconnecting from the push access terminal and deleting the sign-in information of the push access terminal.
[0016] In a second aspect, the present application also provides a message processing device. The device comprises:
[0017] A message receiving module, used to determine the push access terminal and message sequence number corresponding to the published message according to the published message received from the persistent data bus;
[0018] A message storage module, used for persistently storing the published message in a message file;
[0019] An index generating module, used to generate a message index according to the message sequence number corresponding to the published message and the position in the message file, and store the message index in a memory;
[0020] The queue adding module is used to add the message sequence number of the published message to the push queue table corresponding to the push access terminal stored in the memory.
[0021] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:
[0022] Determine the push access terminal and message sequence number corresponding to the published message according to the published message received from the persistent data bus;
[0023] Persistently storing the published message in a message file;
[0024] Generate a message index according to the message sequence number corresponding to the published message and the position in the message file, and store the message index in a memory;
[0025] The message sequence number of the published message is added to the push queue table corresponding to the push access terminal stored in the memory.
[0026] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0027] Determine the push access terminal and message sequence number corresponding to the published message according to the published message received from the persistent data bus;
[0028] Persistently storing the published message in a message file;
[0029] Generate a message index according to the message sequence number corresponding to the published message and the position in the message file, and store the message index in a memory;
[0030] The message sequence number of the published message is added to the push queue table corresponding to the push access terminal stored in the memory.
[0031] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0032] Determine the push access terminal and message sequence number corresponding to the published message according to the published message received from the persistent data bus;
[0033] Persistently storing the published message in a message file;
[0034] Generate a message index according to the message sequence number corresponding to the published message and the position in the message file, and store the message index in a memory;
[0035] The message sequence number of the published message is added to the push queue table corresponding to the push access terminal stored in the memory.
[0036] The above-mentioned message processing method, device, computer equipment, storage medium and computer program product determine the corresponding push access terminal and message sequence number according to the published message received from the persistent data bus, store the published message persistently in the message file, and generate a message index stored in the memory according to its message sequence number and the position in the message file, and add the message sequence number of the published message to the push queue list corresponding to the push access terminal stored in the memory. In this process, after receiving the published message from the persistent data bus, on the one hand, it is persistently stored in the message file, and on the other hand, a message index stored in the memory is generated, and it is added to the push list stored in the memory, which enables the subsequent message push process to search the list and index in the memory, quickly determine the position of the message to be pushed to the push access terminal in the message file, and by persistently storing the published message in the message file, it can avoid the loss of messages caused by fault restart and the like, thereby improving the reliability of message push. Furthermore, since the message index and the push list are formed according to the published message received from the persistent data bus, on the basis of the persistence of the published message, the server can quickly regenerate a consistent message index and push queue list after restart, thereby further ensuring the reliability of message push. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 An application environment diagram of a message processing method in an embodiment;
[0038] Figure 2 A schematic diagram of a flow chart of a message processing method in an embodiment;
[0039] Figure 3 A schematic diagram of a process of message push in an embodiment;
[0040] Figure 4 A flowchart of a step of obtaining a message sequence number of a message to be pushed and a step of updating a sequence number of a message that has been pushed in one embodiment;
[0041] Figure 5 A flowchart of the steps of updating the confirmation message sequence number and determining the pushed message sequence number in one embodiment;
[0042] Figure 6 is an application environment diagram of a message processing method in another embodiment;
[0043] Figure 7 A schematic diagram of sign-in information in one embodiment;
[0044] Figure 8is a structural block diagram of a message processing device in one embodiment;
[0045] Fig. 9 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0047] The message processing method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown, the application environment may include: a persistent data bus, a server, and a push access terminal, and the push access terminal may communicate with the server through a communication network. In the present application, the server may receive and process a published message from the persistent data bus, and the push access terminal may be used to receive data such as a push message from the server.
[0048] like Figure 1 In the application environment shown, the push access terminal can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, IoT devices and portable wearable devices. IoT devices can be smart speakers, smart TVs, smart air conditioners, smart car devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server can be implemented using an independent server or a server cluster consisting of multiple servers.
[0049] In one embodiment, Figure 2 As shown, a message processing method is provided, which is applied to Figure 1 The server in the example is used to illustrate the following steps:
[0050] Step S201, according to the published message received from the persistent data bus, determine the push access terminal and message sequence number corresponding to the published message.
[0051] Specifically, the persistent data bus can receive published messages from a message publishing source and store them persistently. The server can receive the published message from the persistent data bus, determine the message sequence number corresponding to the published message, and determine the push access terminal corresponding to the published message based on the category information contained in the published message and the message topic categories subscribed by each push access terminal that are pre-stored.
[0052] Step S202, persistently storing the published message in a message file.
[0053] Specifically, the server can save the received published message into a persistent message file, and obtain the position of the published message in the message file. Exemplarily, the published message can be stored in the message file according to the message sequence number.
[0054] Step S203, generating a message index according to the message sequence number corresponding to the published message and the position in the message file, and storing the message index in the memory.
[0055] In this step, according to the message sequence number determined in step S201 and the position of the published message in the message file determined in step S202, a message index can be compiled and stored in the memory. The message index can include the message sequence number and position information of the published message, so that the position of the corresponding message in the message file can be obtained by querying the message index using the message sequence number.
[0056] In some embodiments, the message index may be stored in a memory database, and the process in the server may access it through a memory database interface.
[0057] Step S204: Add the message sequence number of the published message to the push queue list corresponding to the push access terminal stored in the memory.
[0058] In this step, according to the push access terminal corresponding to the published message determined in step S201, the message sequence number of the published message can be added to the push queue list corresponding to the push access terminal in the memory. Exemplarily, the server can search for the corresponding push queue list in the memory according to the access terminal identifier of the determined push access terminal, and when the list does not exist, a push queue list can be created for the push access terminal. The push queue list is used to store the message sequence number of each message corresponding to the push access terminal. In this step, the server can add the message sequence number of the currently received published message to the push queue list.
[0059] In some embodiments, the push queue table may be stored in a memory database, and a process in the server may access it through a memory database interface.
[0060] The above message processing method determines the corresponding push access terminal and message sequence number according to the published message received from the persistent data bus, stores the published message persistently in the message file, generates a message index stored in the memory according to its message sequence number and the position in the message file, and adds the message sequence number of the published message to the push queue list corresponding to the push access terminal stored in the memory. In this process, after receiving the published message from the persistent data bus, on the one hand, it is persistently stored in the message file, and on the other hand, a message index stored in the memory is generated, and it is added to the push list stored in the memory, which enables the subsequent message push process to search the list and index in the memory, quickly determine the position of the message to be pushed to the push access terminal in the message file, and by persistently storing the published message in the message file, it can avoid the loss of messages caused by fault restart and the like, thereby improving the reliability of message push. Further, since the message index and the push queue list are formed according to the published message received from the persistent data bus, on the basis of the persistence of the published message, the server can quickly regenerate a consistent message index and push queue list after restart, thereby further ensuring the reliability of message push.
[0061] In one embodiment, the above method also includes: generating a database operation instruction according to the message sequence number corresponding to the published message and the position in the message file; creating a database transaction containing the database operation instruction; executing the database transaction in the memory database; generating a message index according to the message sequence number corresponding to the published message and the position in the message file, and storing the message index in the memory, including: when executing the database transaction, writing the message sequence number corresponding to the published message and the position in the message file in the message index table in the memory database according to the database operation instruction to form a message index; adding the message sequence number of the published message to the push queue table corresponding to the push access terminal stored in the memory, including: when executing the database transaction, writing the message sequence number of the published message into the push queue table corresponding to the push access terminal in the memory database according to the database operation instruction.
[0062] Specifically, in this embodiment, a memory database is used to store message indexes and push queue tables corresponding to each push access terminal. Exemplarily, the memory database may be a relational memory database.
[0063] The message index may be stored in a message index table of a memory database, and the fields of the message index table may include: message sequence number, message file sequence number, message displacement in the message file, message size, and the like.
[0064] In this embodiment, after determining the push access terminal corresponding to the published message in the above step S201, the server can obtain the access terminal identifier corresponding to the push access terminal, and after persistently storing the published message in the message file in step S202, the message file sequence number of the message file and the position of the published message can be obtained. The position may include the displacement of the published message in the message file and the message size.
[0065] Based on the above information, the server can determine the specific write operations that need to be performed on each table in the memory database and generate corresponding database operation instructions. Exemplarily, the database operation instructions may include write operation instructions for the message index table and write operation instructions for the push queue table.
[0066] Furthermore, according to the generated database operation instruction, a database transaction containing the corresponding database operation instruction can be created to submit the writing to different tables in a centralized manner. Then, by executing the database transaction, the corresponding message sequence number, message file sequence number, displacement and size of the message in the message file can be written into the message index table, thereby forming a message index for publishing the message, and the message sequence number of the published message can be written into the push queue table.
[0067] This embodiment stores the message index and push queue table in an in-memory database and submits the database operation instructions for both in one database transaction, thereby ensuring the isolation and integrity of the write operation and keeping the data in multiple tables in the database consistent. Therefore, when the message is pushed subsequently, consistent data can be read from multiple tables, effectively ensuring the reliability of the message push.
[0068] In one embodiment, Figure 3 As shown, the above method also includes:
[0069] Step S301: acquiring an access terminal identifier of a push access terminal according to the sign-in information of the push access terminal.
[0070] Specifically, the server can maintain the sign-in information of each push access terminal according to each push access terminal connected to it. The sign-in information may include the access terminal identifier of the push access terminal. In this step, the server can obtain the access terminal identifier of the push access terminal by querying the sign-in information.
[0071] Step S302: According to the access terminal identifier, a push queue list corresponding to the push access terminal is searched in the memory, and a message sequence number of the message to be pushed is obtained from the push queue list.
[0072] In this step, the server may use the access terminal identifier obtained in step S301 to search the push queue list corresponding to the push access terminal in the memory, and obtain the message sequence number of the message to be pushed in the push queue list.
[0073] Step S303: query the message index in the memory according to the message sequence number of the message to be pushed, and obtain the position information of the message to be pushed in the persistently stored message file according to the message index.
[0074] Step S304: Obtain the message to be pushed from the message file according to the location information.
[0075] Step S305: Push the message to be pushed to the push access terminal.
[0076] Specifically, according to the message sequence number of the message to be pushed obtained in step S302, in step S303, the message index stored in the memory can be further queried, and the position information of the message to be pushed in the message file can be obtained from the message index. Then, in step S304, the corresponding message to be pushed can be obtained from the persistently stored message file using the position information, and pushed to the push access terminal through the network in step S305. In some embodiments, the server can scan the corresponding push queue table in turn according to the access terminal identifier of each push access terminal, and push the message to be pushed to each push access terminal in turn.
[0077] This embodiment can query the push queue table and message index in the memory according to the access terminal identifier of the push access terminal, obtain the position information of the message to be pushed in the message file, and then obtain the message to be pushed from the message file and push it to the push access terminal. Among them, since the access to the push queue table and the message index is performed in the memory, the position information of the message to be pushed can be determined quickly and efficiently, and the corresponding message is obtained in the persistently stored message file, so that the reliability of the message data can be guaranteed.
[0078] In one embodiment, Figure 4 As shown, the step S302 of obtaining the message sequence number of the message to be pushed includes:
[0079] Step S401: acquiring the pushed message sequence number corresponding to the push access terminal according to the sign-in information of the push access terminal.
[0080] Specifically, in this embodiment, the sign-in information of the push access terminal maintained by the server also includes the pushed message sequence number. The pushed message sequence number can be determined according to the message push history of the push access terminal by the server, which is used to indicate the message sequence number of the message that has been pushed to the push access terminal.
[0081] Step S402, obtaining the maximum message sequence number in the push queue list.
[0082] Specifically, in this embodiment, the message sequence number of the published message increases according to its publishing time, and is added to the push queue list in order. Among them, the maximum message sequence number in the push queue list is the message sequence number of the latest message to be pushed corresponding to the push access terminal. The server can directly obtain the maximum message sequence number therein by querying the push queue list.
[0083] Step S403: When the maximum message sequence number is greater than the sequence number of the pushed message, all message sequence numbers in the push queue that are greater than the sequence number of the pushed message are used as the message sequence numbers of the messages to be pushed.
[0084] In this step, the pushed message sequence number can be compared with the maximum message sequence number. If the maximum message sequence number is greater than the pushed message sequence number, it can be considered that there is a message sequence number corresponding to the message that has not been pushed to the push access terminal in the push queue list. Based on this, all message sequence numbers greater than the pushed message sequence number can be obtained in the push queue list and used as the message sequence number of the message to be pushed.
[0085] After the above step S305, in which the message to be pushed is pushed to the push access terminal, the following steps are further included:
[0086] Step S404: update the pushed message sequence number in the sign-in information of the push access terminal according to the message sequence number of the message to be pushed.
[0087] Specifically, in this embodiment, after the message to be pushed is pushed to the push access terminal, the sign-in information of the push access terminal can be updated according to the message sequence number corresponding to the message that has been pushed, and the pushed message sequence number therein is updated to the message sequence number of the pushed message to be pushed.
[0088] In this embodiment, the message sequence number of the message to be pushed is determined by combining the pushed message sequence number of the sign-in information and the maximum message sequence number in the push queue list, and the pushed message sequence number is updated after the message push is completed. This can avoid re-pushing the pushed message, effectively save resources and improve the user experience of the push recipient.
[0089] In one embodiment, Figure 5 As shown, the above method also includes:
[0090] Step S501: updating the confirmation message sequence number in the sign-in information of the push access terminal according to the message confirmation information received from the push access terminal.
[0091] Specifically, in this embodiment, the push access terminal can send a message confirmation message including the message sequence number to the server according to the message sequence number of the received push message. The sign-in information of the push access terminal maintained by the server also includes the confirmation message sequence number. The confirmation message sequence number is used to indicate the message confirmed to be received by the push access terminal. The server can update the confirmation message sequence number in the sign-in information according to the message sequence number included in the message confirmation information received from the push access terminal.
[0092] In the above step S404, when the maximum message sequence number is greater than the sequence number of the pushed message, before the messages corresponding to the message sequence numbers greater than the sequence number of the pushed message in the push queue list are taken as the messages to be pushed, the following further comprises:
[0093] Step S502: acquiring a confirmation message sequence number corresponding to the push access terminal according to the sign-in information of the push access terminal.
[0094] Step S503: When the difference between the pushed message sequence number and the confirmed message sequence number is greater than a preset value, the confirmed message sequence number is used as the pushed message sequence number.
[0095] Specifically, before determining the push message according to the maximum message sequence number and the pushed message sequence number, in this embodiment, the server can also obtain the corresponding confirmation message sequence number from the sign-in information of the push access terminal in step S502, and compare the confirmation message sequence number with the pushed message sequence number in step S503. When the pushed message sequence number is greater than the confirmation message sequence number, it means that there is a message that has been pushed to the push access terminal but has not been confirmed. Considering factors such as communication delay, in this embodiment, a reasonable preset value can be set in advance, and the difference between the pushed message sequence number and the confirmation message sequence number is compared with the preset value. When the difference is greater than the preset value, it can be considered that there is a message that has not been successfully pushed to the push access terminal. In this case, the server can use the confirmation message sequence number as the pushed message sequence number, and then use it to determine the message sequence number of the message to be pushed in the message queue table later.
[0096] In this embodiment, the confirmation message sequence number in the sign-in information is updated according to the message confirmation information received from the push access terminal, and the confirmation message sequence number is compared with the pushed message sequence number. When the difference is too large, the confirmation message sequence number is used as the pushed message sequence number. It can timely discover problems such as loss of message push and re-push the unconfirmed message, which can better ensure the reliability of message push.
[0097] In one embodiment, the method further includes: sending a heartbeat signal to a push access terminal storing sign-in information according to a set first time period; upon receiving a sign-in request sent by the push access terminal, establishing a connection with the push access terminal, and checking whether the sign-in information of the push access terminal is stored; if not, adding the sign-in information of the push access terminal; wherein the sign-in request is sent by a push access terminal that has not sent a sign-in request, or is sent by a push access terminal that has sent a sign-in request but has not received a heartbeat signal and has not received a push message within a second time period.
[0098] Specifically, the server in this embodiment can maintain a long-term connection with the push access terminal and maintain the connection through a heartbeat mechanism. The server can determine the push access terminals with which a connection relationship has been established according to the stored sign-in information, and send a heartbeat signal to these push access terminals according to a set first time period.
[0099] Furthermore, in this embodiment, when the push access terminal needs to obtain a push message and determines that there is no connection relationship between itself and the server, it sends a check-in request to the server to establish a connection relationship with the server. Specifically, the push access terminal can determine whether a connection has been established based on the previous check-in request sending situation. If a check-in request has never been sent to the corresponding server, or if a check-in request is not sent again after sending a check-out request, it can be determined that a connection has not been established with the corresponding server. Furthermore, when the push access terminal has sent a check-in request, it can also determine whether a heartbeat signal or a push message is received from the corresponding server within a second time period. If at least one of the two is not received within the second time period, it can be determined that a connection has not been established with the corresponding server.
[0100] Based on this, when the server receives a sign-in request from a push access terminal, it can establish a connection relationship with the corresponding push access terminal and check whether the sign-in information of the push access terminal is stored. If the corresponding sign-in information is not stored, the corresponding sign-in information can be added.
[0101] In this embodiment, the server can maintain the connection with the push access terminal by sending a heartbeat signal, and can establish a connection relationship with the push access terminal according to the check-in request received from the push access terminal. In this process, on the one hand, the time and resource consumption of establishing multiple connections between the server and the push access terminal can be avoided, and on the other hand, the monitoring result of the heartbeat signal and the push message by the push access terminal can be used to establish a connection with the push access terminal that may be disconnected in time, so as to ensure that the message can be pushed to the push access terminal smoothly, and the reliability of message push can be better guaranteed.
[0102] In one embodiment, the above method also includes: when a sign-out request sent by the push access terminal is received, or when no confirmation information sent by the push access terminal is received within a third time period after the message to be pushed is pushed to the push access terminal, disconnecting from the push access terminal and deleting the sign-in information of the push access terminal.
[0103] Specifically, in this embodiment, the push access terminal can send a sign-off request to the server to instruct the server to disconnect the connection between the two. After receiving the sign-off request, the server can disconnect the connection with the corresponding push access terminal and delete the sign-in information corresponding to the push access terminal.
[0104] On the other hand, for the push access terminal that has not received the sign-out request, the server may also monitor whether a confirmation message is received from the push access terminal within the third time period after pushing the message to be pushed to the push access terminal. If the confirmation message is not received after the third time period, it may be determined that the corresponding push access terminal has a fault or cannot be connected to the push access terminal, and then the server may disconnect the connection with the corresponding push access terminal and delete the sign-in information corresponding to the push access terminal.
[0105] For example, the deletion operation of the sign-in information mentioned in this embodiment may be to mark the corresponding sign-in information for deletion without completely deleting it from the server.
[0106] In this embodiment, the server can disconnect the connection with the corresponding push access terminal and delete its corresponding sign-in information based on the received sign-out request or the monitoring result of the reception of the confirmation information, which can enable the server to save resources used for message processing and push of the push access terminal.
[0107] In order to further illustrate the message processing method of the present application, it is described below through detailed embodiments.
[0108] For example, the message processing method in this embodiment can be applied to Figure 6 In the application environment shown. The application environment may include: a publishing interface application, a persistent data bus, a server, and a push access terminal. Among them, the persistent data bus can be connected to the publishing interface application and the server, and the server can be connected to the push access terminal. Specifically, in this embodiment, the server and the push access terminal can be connected through a communication component on the network.
[0109] Specifically, each push access terminal in this embodiment can subscribe to data of different topics. According to the topic subscription of each push access terminal, the data can be divided into public topic data that can be received by all push access terminals and private topic data corresponding to each push access terminal. Based on the subscription information obtained in advance, the publishing interface application can collect data from the core system, and then filter out the required data, and after classification, add the original data to the topic information and send it to the persistent data bus. The persistent data bus can perform persistent storage on the received published messages. The persistent data bus can be a fault-tolerant bus including master and backup nodes, wherein the master and backup nodes can perform consistent persistent storage on the published messages, and the master node provides services to the server. When the master node fails, the backup node can continue to provide services within seconds and ensure that data is not lost.
[0110] like Figure 6 As shown, the server in this embodiment may include a publishing service and a subscription push service.
[0111] The publishing service may include a main thread, which may receive the published message from the persistent data bus and determine the push access terminal and message sequence number corresponding to the published message. Further, the main thread may persistently store the published message in the message file of the server, and write a corresponding record in the message index table of the memory database according to the message sequence number corresponding to the published message and the position in the message file, generate a message index, and add the message sequence number of the published message to the push queue table corresponding to the push access terminal in the memory database.
[0112] Specifically, in this embodiment, the server can generate write operation instructions for the message index table and the push queue table respectively according to the above information, and then create a database transaction containing these instructions, submit the above write operations in the database transaction, and then write the information by executing the transaction in the memory database. This can effectively ensure the data consistency of each table in the database.
[0113] The subscription push service may include a main function receiving thread, a request processing thread, a push information scanning thread, a data information push thread, a push message sequence, and a queue sign-in table. The push message sequence is used to store messages to be pushed to the push access terminal, and the queue sign-in table is used to store the sign-in information of the push access terminal. Figure 7 As shown, the sign-in information may include the push message sequence number (MSG_Q_ID[PK]) corresponding to the push access terminal, the access terminal identifier (OPER_ID[IDX]), the access terminal address (OPER_ADDR), the pushed message sequence number (SENT_SEQ), the confirmation message sequence number (ACK_SEQ), and the maximum message sequence number (MAX_SEQ).
[0114] Specifically, the main function receiving thread of the subscription push service can send a heartbeat signal to the push access terminal storing the sign-in information according to the set first time period, and can also receive a sign-in request, a sign-out request and a message confirmation information from the push access terminal, and store the received data in the request instruction sequence.
[0115] The request processing thread for subscribing to the push service can read the data in the request instruction sequence and process it. Among them, when the sign-in request sent by the push access terminal is read, the connection between the server and the push access terminal can be established, and the sign-in information of the push access terminal is checked whether it is stored in the queue sign-in table. If not, the corresponding sign-in information is added therein. The request processing thread can also further establish a push message sequence corresponding to the push access terminal. When the message confirmation information sent by the push access terminal is read, the request processing thread can update the confirmation message sequence number in the sign-in information of the push access terminal. When the sign-out request sent by the push access terminal is read, the request processing thread can disconnect the connection between the server and the corresponding push access terminal and delete the sign-in information corresponding to the push access terminal. In addition, the request processing thread can also monitor whether the confirmation information from the push access terminal is received within the third time length after the server pushes the message to be pushed to the push access terminal. If not, the connection between the server and the corresponding push access terminal can be disconnected and the sign-in information corresponding to the push access terminal can be deleted.
[0116] The push information scanning thread of the subscription push service can obtain the access terminal identifiers of each connected push access terminal according to the check-in information in the queue check-in table, and query the push queue list corresponding to the push access terminal in the memory database according to the access terminal identifier, and obtain the message sequence number of the message to be pushed from the push queue list. Further, the push information scanning thread can also query the message index in the memory database according to the obtained message sequence number of the message to be pushed, and obtain the location information of the message to be pushed in the persistently stored message file according to the message index. Furthermore, the push information scanning thread can obtain the message to be pushed from the message file according to the location information and write it into the push message sequence. In some embodiments, the subscription push service can also obtain the pushed message sequence number and the confirmed message sequence number of the push access terminal in the check-in information, and obtain the maximum message sequence number in the push queue list, and determine the message sequence number of the corresponding message to be pushed in combination with the push message sequence number, the confirmed message sequence number, and the maximum message sequence number.
[0117] The push thread can push the messages to be pushed in the push message sequence to the corresponding push access terminal according to the check-in information in the queue check-in table, and update the pushed message sequence number in the check-in information of the push access terminal after pushing. In some embodiments, the push thread can sequentially check whether there are messages to be pushed in the push message sequence of each push access terminal, and if so, push the messages to be pushed to the corresponding push access terminal until all the messages to be pushed in the push message sequence are pushed or the limit on the number of push packets is reached, and then check the push message sequence of the next push access terminal, so that data can be pushed to each push access terminal in turn, ensuring that data can be pushed to the push access terminal in a relatively fair manner.
[0118] The push access terminal can communicate with the server through the message queue access interface and process the received push messages. Among them, the message queue access interface may include a receiving thread and a detection and resending thread. The receiving thread can receive push messages and heartbeat signals from the server, and store the received push messages in the local message sequence. Among them, when the receiving thread receives the push message, it can also send a message confirmation information to the server, which includes the sequence number of the message received this time. The detection and resending thread can cyclically detect whether a heartbeat signal or a push message from the server is received within the second time period. If neither is received, the push access terminal is instructed to resend the check-in request to the server.
[0119] In this embodiment, the server receives message data from the bus through the publishing service and processes it, compiles the message index and push queue table stored in the memory, and persistently stores the message data in the message file, so that the message data can be efficiently accessed and can meet various access requirements such as sequential reading and random reading. Furthermore, the server accesses the message index and push queue table in the memory in a read-only manner through the subscription push service, which can easily expand the number of subscription push services, thereby meeting the needs of a large number of push access terminals. For the data required by the push access terminal, in this embodiment, it is defined as a queue, supplemented by a topic, which can ensure that the data received by the push access terminal on all subscription push services is consistent. In addition, since the above scheme implements functions such as heartbeat keep-alive, disorder correction, and packet loss retransmission, users only need to pay attention to the data itself without having to spend extra energy on reliability issues.
[0120] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0121] Based on the same inventive concept, the embodiment of the present application also provides a message processing device for implementing the message processing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the one or more message processing device embodiments provided below can refer to the limitations on the message processing method above, and will not be repeated here.
[0122] In one embodiment, Figure 8 As shown, a message processing device 800 is provided, including:
[0123] The message receiving module 801 is used to determine the push access terminal and message sequence number corresponding to the published message according to the published message received from the persistent data bus;
[0124] The message storage module 802 is used to store the published message persistently in a message file;
[0125] An index generating module 803, configured to generate a message index according to the message sequence number corresponding to the published message and the position in the message file, and store the message index in a memory;
[0126] The queue adding module 804 is used to add the message sequence number of the published message to the push queue table corresponding to the push access terminal stored in the memory.
[0127] In one embodiment, the above-mentioned message processing device also includes: an instruction generation module, which is used to generate a database operation instruction according to the message sequence number corresponding to the published message and the position in the message file; a transaction creation module, which is used to create a database transaction containing the database operation instruction; a transaction execution module, which is used to execute the database transaction in the memory database; the index generation module 803 is also used to: when executing the database transaction, write the message sequence number corresponding to the published message and the position in the message file in the message index table in the memory database according to the database operation instruction to form a message index; the queue adding module 804 is also used to: when executing the database transaction, write the message sequence number of the published message into the push queue table corresponding to the push access terminal in the memory database according to the database operation instruction.
[0128] In one embodiment, the above-mentioned message processing device also includes: an access terminal identification acquisition module, which is used to obtain the access terminal identification of the push access terminal according to the sign-in information of the push access terminal; a message sequence number acquisition module, which is used to query the push team list corresponding to the push access terminal in the memory according to the access terminal identification, and obtain the message sequence number of the message to be pushed from the push team list; a location information acquisition module, which is used to query the message index in the memory according to the message sequence number of the message to be pushed, and obtain the location information of the message to be pushed in the persistently stored message file according to the message index; a message to be pushed acquisition module, which is used to obtain the message to be pushed from the message file according to the location information; a message push module, which is used to push the message to be pushed to the push access terminal.
[0129] In one embodiment, the message sequence number acquisition module is further used to: acquire the pushed message sequence number corresponding to the push access terminal according to the sign-in information of the push access terminal; acquire the maximum message sequence number in the push queue list; when the maximum message sequence number is greater than the pushed message sequence number, use all message sequence numbers in the push queue list that are greater than the pushed message sequence number as the message sequence number of the message to be pushed; the message push module is further used to: after pushing the message to be pushed to the push access terminal, update the pushed message sequence number in the sign-in information of the push access terminal according to the message sequence number of the message to be pushed.
[0130] In one embodiment, the above-mentioned message processing device also includes: a confirmation message sequence number updating module, which is used to update the confirmation message sequence number in the sign-in information of the push access terminal according to the message confirmation information received from the push access terminal; the message sequence number acquisition module is also used to: acquire the confirmation message sequence number corresponding to the push access terminal according to the sign-in information of the push access terminal; when the difference between the pushed message sequence number and the confirmation message sequence number is greater than a preset value, use the confirmation message sequence number as the pushed message sequence number.
[0131] In one embodiment, the message processing device further includes: a heartbeat signal sending module, which is used to send a heartbeat signal to a push access terminal that stores the sign-in information according to a set first time period; a sign-in request processing module, which is used to establish a connection with the push access terminal when receiving a sign-in request sent by the push access terminal, and check whether the sign-in information of the push access terminal is stored; if not, add the sign-in information of the push access terminal; wherein the sign-in request is sent by a push access terminal that has not sent the sign-in request, or is sent by a push access terminal that has sent the sign-in request and has not received the heartbeat signal and the push message within the second time period.
[0132] In one embodiment, the above-mentioned message processing device further includes: a connection disconnection module, which is used to disconnect the connection with the push access terminal and delete the sign-in information of the push access terminal when a sign-out request sent by the push access terminal is received, or when no confirmation information sent by the push access terminal is received within a third time period after the message to be pushed is pushed to the push access terminal.
[0133] Each module in the above message processing device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module above.
[0134] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig. 9As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium, and is used to store data such as message indexes, push queue lists, and sign-in information. The database of the computer device is used to store data such as message files. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a message processing method is implemented.
[0135] Those skilled in the art will understand that Fig. 9 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0136] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.
[0137] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0138] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0139] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.
[0140] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0141] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0142] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A message processing method, characterized in that: The method comprises: Determine the push access terminal and message sequence number corresponding to the published message according to the published message received from the persistent data bus; Persistently storing the published message in a message file; Generate a message index according to the message sequence number corresponding to the published message and the position in the message file, and store the message index in a memory; The message sequence number of the published message is added to the push queue table corresponding to the push access terminal stored in the memory.
2. The method according to claim 1, characterized in that: The method further comprises: Generate a database operation instruction according to the message sequence number corresponding to the published message and the position in the message file; Creating a database transaction including the database operation instruction; Execute the database transaction in an in-memory database; The generating a message index according to the message sequence number corresponding to the published message and the position in the message file, and storing the message index in a memory includes: When executing the database transaction, the message sequence number corresponding to the published message and the position in the message file are written into the message index table in the memory database according to the database operation instruction to form a message index; The adding the message sequence number of the published message to the push queue list corresponding to the push access terminal stored in the memory includes: When executing the database transaction, the message sequence number of the published message is written into the push queue table corresponding to the push access terminal in the memory database according to the database operation instruction.
3. The method according to claim 1, characterized in that The method further comprises: According to the sign-in information of the push access terminal, obtaining the access terminal identifier of the push access terminal; According to the access terminal identifier, query the push team list corresponding to the push access terminal in the memory, and obtain the message sequence number of the message to be pushed from the push team list; According to the message sequence number of the message to be pushed, query the message index in the memory, and obtain the position information of the message to be pushed in the persistently stored message file according to the message index; Acquire the message to be pushed from the message file according to the location information; Push the message to be pushed to the push access terminal.
4. The method according to claim 3, characterized in that The step of obtaining the message sequence number of the message to be pushed includes: According to the sign-in information of the push access terminal, obtain the pushed message sequence number corresponding to the push access terminal; Get the maximum message sequence number in the push queue list; In the case where the maximum message sequence number is greater than the pushed message sequence number, all message sequence numbers in the push queue that are greater than the pushed message sequence number are used as the message sequence numbers of the messages to be pushed; After pushing the message to be pushed to the push access terminal, the method further includes: The pushed message sequence number in the sign-in information of the push access terminal is updated according to the message sequence number of the message to be pushed.
5. The method according to claim 4, characterized in that The method further comprises: updating the confirmation message sequence number in the sign-in information of the push access terminal according to the message confirmation information received from the push access terminal; In the case where the maximum message sequence number is greater than the pushed message sequence number, before taking all messages in the push queue list corresponding to message sequence numbers greater than the pushed message sequence number as the push message, the method further includes: According to the sign-in information of the push access terminal, obtaining the confirmation message sequence number corresponding to the push access terminal; When the difference between the pushed message sequence number and the confirmation message sequence number is greater than a preset value, the confirmation message sequence number is used as the pushed message sequence number.
6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: Send a heartbeat signal to the push access terminal storing the sign-in information according to the set first time period; When receiving a sign-in request sent by a push access terminal, establishing a connection with the push access terminal, checking whether the sign-in information of the push access terminal is stored; if not, adding the sign-in information of the push access terminal; The sign-in request is sent by a push access terminal that has not sent the sign-in request, or is sent by a push access terminal that has sent the sign-in request but has not received the heartbeat signal and the push message within the second time period.
7. The method according to claim 6, characterized in that The method further comprises: When a sign-out request sent by the push access terminal is received, or when no confirmation information sent by the push access terminal is received within a third time period after the message to be pushed is pushed to the push access terminal, the connection with the push access terminal is disconnected and the sign-in information of the push access terminal is deleted.
8. A message processing device, characterized in that: The device comprises: A message receiving module, used to determine the push access terminal and message sequence number corresponding to the published message according to the published message received from the persistent data bus; A message storage module, used for persistently storing the published message in a message file; An index generating module, used to generate a message index according to the message sequence number corresponding to the published message and the position in the message file, and store the message index in a memory; The queue adding module is used to add the message sequence number of the published message to the push queue table corresponding to the push access terminal stored in the memory.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.