Message transmission method, apparatus, computer equipment and readable storage medium
By introducing sequential sequence and local message number synchronization mechanisms into the instant messaging system, the storage pressure problem of multiple terminal devices is solved, the system stability and database performance are improved, and fast message synchronization of various clients is supported.
Patent Information
- Application Number
- CN202411702052.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2044-11-26
AI Technical Summary
Instant messaging systems need to record messages to be transmitted for various terminal devices, which increases storage pressure and affects system stability.
By introducing sequential sequences into the instant messaging system, a receiver record is generated, and messages are synchronized on the receiver device based on the local maximum message number. This reduces the need for separate storage for each terminal device, storing only one message record in the receiver's message list.
It improves the stability of the instant messaging system, reduces storage pressure, enhances database access performance and scalability, and supports rapid synchronization for various recipient client types.
Smart Images

Figure CN119520456B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of Internet and computer technology, and in particular to a message transmission method, apparatus, computer device and readable storage medium. Background Technology
[0002] With the development of internet technology, instant messaging (IM) applications are becoming increasingly widespread. IM applications provide users with communication functions such as text, images, voice, and video in one-on-one or group chats. As the variety of terminal devices continues to increase, IM applications can have different versions to adapt to different types of terminal devices, such as mobile terminals or personal computers. Instant messaging systems can support sending and receiving messages on different types of terminal devices using the corresponding version of the IM application.
[0003] In related technologies, instant messaging systems need to record messages to be transmitted separately for various terminal devices, which increases the storage pressure on instant messaging systems and thus affects their stability. Summary of the Invention
[0004] Therefore, it is necessary to provide a message transmission method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can improve the stability of instant messaging systems in response to the above-mentioned technical problems.
[0005] On one hand, this application provides a message transmission method, including: receiving a first message sent by a sending device of a sender; determining a receiver identifier of the receiver of the first message, wherein the first message is triggered by a target session of a social application; determining a sequence associated with the receiver identifier of the receiver from a sequence set; generating a first receiver record corresponding to the first message; adding the first receiver record to the sequence associated with the receiver identifier, wherein the receiver records in the sequence are arranged in the order of addition, and the first receiver record is used to indicate the first message and the receiver identifier; and reading a second receiver from the sequence associated with the receiver identifier. The process involves several steps: First, the order in which the receiver records are read is consistent with the order in which they are added. Second, the receiver record is used to indicate the second message and the receiver identifier. Based on the second receiver record, a new message record associated with the receiver identifier is added to the receiver message list. This message record contains the message number corresponding to the second message, and the message number in the message record is used to characterize the writing order of the message record. Third, message arrival notifications are sent to multiple receiving devices of the receiver running the social application. These notifications notify each receiving device to retrieve a message from the receiver message list based on its local maximum message number.
[0006] On the other hand, this application also provides a message transmission device, including: a message receiving module, configured to receive a first message sent by a sender's sending device, determine a receiver identifier of the receiver of the first message, wherein the first message is triggered by a target session of a social application; a receiver record adding module, configured to determine a sequence associated with the receiver identifier of the receiver from a sequence set, generate a first receiver record corresponding to the first message, add the first receiver record to the sequence associated with the receiver identifier, wherein the receiver records in the sequence are arranged in the order of addition, and the first receiver record is used to indicate the first message and the receiver identifier; and a receiver record reading module, configured to read from the sequence associated with the receiver identifier... The system reads a second receiver record, wherein the reading order of the receiver records in the sequence is consistent with the addition order of the receiver records. The second receiver record is used to indicate the second message and the receiver identifier. A message record addition module is used to add a message record associated with the receiver identifier to the receiver message list based on the second receiver record. The message record contains a message number corresponding to the second message, and the message number in the message record is used to characterize the writing order of the message record. A notification sending module is used to send message arrival notifications to multiple receiving devices of the receiver running the social application, respectively. The message arrival notification is used to notify each receiving device to retrieve a message from the receiver message list based on its local maximum message number.
[0007] On the other hand, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described message transmission method.
[0008] On the other hand, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the above-described message transmission method.
[0009] On the other hand, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps in the above-described message transmission method.
[0010] The aforementioned message transmission method, apparatus, computer device, computer-readable storage medium, and computer program product receive a first message sent by a sending device of a sender; determine the recipient identifier of the first message; the first message is triggered by a target session of a social application; determine the sequence associated with the recipient identifier of the recipient from a sequence sequence set; add a first recipient record corresponding to the first message to the sequence associated with the recipient identifier; the recipient records in the sequence are arranged in the order of addition; the first recipient record is used to indicate the first message and the recipient identifier; read a second recipient record from the sequence associated with the recipient identifier; the reading order of the recipient records in the sequence is consistent with the addition order of the recipient records; the second recipient record is used to indicate the second message and the recipient identifier; based on the second recipient record, add a message record associated with the recipient identifier to the recipient message list; the message record contains a message number corresponding to the second message; the message number in the message record is used to characterize the writing order of the message record; and send message arrival notifications to multiple receiving devices of the recipient running social applications, respectively; the message arrival notifications are used to notify each receiving device to retrieve a message from the recipient message list based on its local maximum message number. Therefore, when multiple receiving devices on the recipient are running social applications, each receiving device can synchronize messages in a timely manner based on the local maximum message number. Only one message record of each message sent to the recipient needs to be stored in the recipient's message list, instead of storing messages separately for each type of receiving device. This reduces the storage pressure on the instant messaging system and helps improve system stability. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is a diagram illustrating the application environment of the message transmission method in some embodiments;
[0013] Figure 2 This is a flowchart illustrating the message transmission method in some embodiments;
[0014] Figure 3 This is a schematic diagram of the recipient message list in some embodiments;
[0015] Figure 4 This is a schematic diagram illustrating the process from sending a message to receiving a message in some embodiments;
[0016] Figure 5This is a schematic diagram illustrating the process from sending a message to writing it to the database in some embodiments;
[0017] Figure 6 This is a structural block diagram of the message transmission device in some embodiments;
[0018] Figure 7 These are internal structural diagrams of the computer device in some embodiments;
[0019] Figure 8 This is a diagram showing the internal structure of a computer device in some embodiments. Detailed Implementation
[0020] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0021] The message transmission method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, the environment includes a sending device 102, a server 104, and a receiving device 106. The sending device 102, server 104, and receiving device 106 can communicate via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated onto server 104 or located on a cloud or other network server. The data storage system can be any type of database. The data storage system and server belong to an instant messaging system. Server 104 is the backend server for the instant messaging application. Server 104 provides the function of registering sessions and can also provide some common instant messaging functions, such as creating groups, adding friends, chatting, and transferring files. Server 104 can be, but is not limited to, an Openfire server. Openfire is an open-source real-time collaboration server developed using the Java programming language based on the Extensible Messaging and Presence Protocol (XMPP).
[0022] The transmitting device 102 and the receiving device 106 can be the same type of terminal device, such as a mobile terminal. Alternatively, the transmitting device 102 and the receiving device 106 can be different types of terminal devices, such as a mobile terminal for transmitting device 102 and a personal computer for receiving device 106.
[0023] Server 104 deploys a distributed message middleware, which can be, but is not limited to, RocketMQ (Rocket Message Queue) or Kafka. When server 104 starts, it initializes a set of sequential sequences (sequential queues) by default. The number of sequential sequences can be preset and adjusted through configuration according to actual needs, for example, to 128. Sequential sequences can be understood as topics in the distributed message middleware.
[0024] Specifically, both the sending device 102 and the receiving device 106 run social applications. The sending device 102 can display the session interface of the target session in the social application. The target session can be any session created within the social application. When an operation to initiate a first message to the target session is triggered in the session interface, the sending device 102 sends the first message to the server 104 and determines the recipient identifier of the first message. The server 104 determines the sequence associated with the recipient identifier from the sequence set and adds the first recipient record corresponding to the first message to the sequence associated with the recipient identifier. The recipient records in the sequence are arranged in the order of addition, and the first recipient record is used to indicate the first message and the recipient identifier. The server 104 can consume messages in the sequence. Consuming messages means storing the messages in a data storage system such as a database. Server 104 can read the second receiver record from the sequence associated with the receiver identifier. The reading order of the receiver records in the sequence is consistent with the addition order of the receiver records. The second receiver record is used to indicate the second message and the receiver identifier. Based on the second receiver record, a new message record associated with the receiver identifier is added to the receiver message list. The message record contains the message number corresponding to the second message. The message number in the message record is used to represent the writing order of the message record. Message arrival notifications are sent to multiple receiving devices of the receiver running social applications. The message arrival notification is used to notify each receiving device to retrieve the message from the receiver message list based on the local maximum message number.
[0025] The transmitting device 102 and receiving device 104 can be, but are not limited to, desktop computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, and projection devices. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted displays. Head-mounted displays can be virtual reality (VR) devices, augmented reality (AR) devices, and smart glasses. Server 104 can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. Cloud servers provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The transmitting device 102, server 104, and receiving device 106 can be directly or indirectly connected via wired or wireless communication, which is not limited herein.
[0026] In some embodiments, such as Figure 2 As shown, a message transmission method is provided. This method can be executed by a terminal or a server, or by both a terminal and a server. This method can be applied to... Figure 1 Taking server 104 as an example, the explanation includes the following steps 202 to 206. Wherein:
[0027] Step 202: Receive the first message sent by the sender's sending device, determine the recipient identifier of the first message, and the first message is triggered through the target session of the social application.
[0028] The social application can be any instant messaging application. The target session can be any session established within the social application. The target session can be a session involving two users or a group chat. The first message can be any message sent through the social application; the message can be a request. The first message can carry a recipient identifier, which is used to uniquely identify the recipient. The first message can carry multiple recipient identifiers, with different identifiers used to identify different recipients, meaning the first message has multiple recipients. The first message also carries content entered by the user into the target session, which can be, but is not limited to, text, images, or videos.
[0029] Step 204: Determine the sequence associated with the receiver identifier from the sequence set, generate the first receiver record corresponding to the first message, and add the first receiver record to the sequence associated with the receiver identifier. The receiver records in the sequence are arranged in the order of addition. The first receiver record is used to indicate the first message and the receiver identifier.
[0030] One receiver identifier is associated with one sequence, and one sequence can be associated with one or more receiver identifiers. Multiple means at least two.
[0031] The receiver record is used to record the receiver identifier and message identifier. For example, a receiver record can be represented as Message{“userId”:user_1,“packet”:p1}, where userId is the user identifier (i.e., the receiver identifier), packet is the message identifier, user_1 is the receiver identifier, and p1 is the message identifier. The first receiver record can contain the message identifier of the first message, and can also contain the receiver identifier. The sequence is a sequential queue. Receiver records in the sequence are arranged in the order they were added, and they follow a first-in, first-out (FIFO) principle; that is, the receiver record added to the sequence first is retrieved first. Consumers in the server, such as an Openfire service in an Openfire service cluster, can store the contents of the receiver records in the sequence to the database, thereby consuming the receiver records in the sequence. At any given time, only one consumer can consume a receiver record in the sequence. Only after one receiver record has been successfully consumed can the next receiver record be consumed. This ensures the orderliness of messages from the same receiver in the database.
[0032] Specifically, the server can generate a message identifier for the first message and associate the first message with the first message identifier in a message storage list, so that the first message can be retrieved from the message storage list based on the message identifier of the first message.
[0033] In some embodiments, messages may be stored in the message storage list in an encrypted manner. Specifically, the server may encrypt the first message to obtain an encrypted first message, and then associate the encrypted first message with the message identifier of the first message and store it in the message storage list.
[0034] Step 206: Read the second receiver record from the sequence associated with the receiver identifier. The order in which the receiver records are read is the same as the order in which they are added. The second receiver record is used to indicate the second message and the receiver identifier.
[0035] The second message and the first message may or may not be the same message. The second message is also sent to the same recipient. The reading order is the same as the addition order: recipient records added to the sequence are read first from the sequence, i.e., first-in, first-out (FIFO). Similarly, the second recipient record may contain the message identifier of the second message and the recipient identifier of the recipient of the second message.
[0036] Specifically, the sequential sequence has a head and a tail. Receiver records are taken from the head and added from the tail, thus achieving first-in, first-out (FIFO). The second receiver record is the receiver record at the head of the sequential sequence. The server can obtain the second receiver record by reading the receiver record from the head of the sequential sequence.
[0037] Step 208: Based on the second receiver record, add a new message record associated with the receiver identifier in the receiver message list. The message record contains the message number corresponding to the second message. The message number in the message record is used to represent the writing order of the message records.
[0038] The message record contains a message number, a recipient identifier, and a message identifier. A message record added based on the second recipient record contains the message number of the second message, the message identifier of the second message, and the recipient identifier of the second message's recipient. It may also include other information such as a unique identifier for the message record or transaction-related information.
[0039] The message number in the message record in the recipient's message list that is less than the message number in the message record that is written later in the recipient's message list is written first. The recipient's message list can store message records associated with different recipient identifiers. For example... Figure 3 The image shows the list of messages received. Since the message number in a message record is used to characterize the writing order of the message record, the message number can also be called the sequence offset.
[0040] Specifically, the list of recipient messages is stored in the database. The server first writes the second recipient record into the consumption queue associated with the recipient identifier, and the recipient records in the consumption queue also follow a first-in, first-out (FIFO) principle. The server can retrieve the recipient record at the head of the consumption queue and send it to the database. Based on this recipient record, the database adds a new message record associated with the recipient identifier to the recipient message list. If the new message record is successfully added, the server repeats the step of retrieving the recipient record at the head of the consumption queue and sending it to the database, so as to add new message records to the recipient message list sequentially.
[0041] Step 210: Send message arrival notifications to multiple receiving devices running social applications on the recipient side. The message arrival notifications are used to notify each receiving device to retrieve the message from the recipient's message list based on the local maximum message number.
[0042] In the case of an Openfire server, message arrival notification can be XMPP signaling. The local maximum message number is the largest message number among all the message numbers currently received by the receiving device.
[0043] Specifically, after receiving a message arrival notification, the receiving device sends a message retrieval request to the server. In response to the message retrieval request, the server determines each message record associated with the recipient identifier and whose message number is greater than the local maximum message number from the recipient's message list, and returns the message and message number of each determined message record (i.e., the target message record) to the receiving device.
[0044] In the above message transmission method, a first message sent by the sending device of the receiving party is received. The receiver identifier of the first message is determined. The first message is triggered by a target session of a social application. From the sequence sequence set, the sequence sequence associated with the receiver identifier of the receiver is determined. The first receiver record corresponding to the first message is added to the sequence sequence associated with the receiver identifier. The receiver records in the sequence sequence are arranged in the order of addition. The first receiver record is used to indicate the first message and the receiver identifier. A second receiver record is read from the sequence sequence associated with the receiver identifier. The reading order of the receiver records in the sequence sequence is consistent with the addition order of the receiver records. The second receiver record is used to indicate the second message and the receiver identifier. Based on the second receiver record, a message record associated with the receiver identifier is added to the receiver message list. The message record contains the message number corresponding to the second message. The message number in the message record is used to represent the writing order of the message record. Message arrival notifications are sent to multiple receiving devices of the receiver running social applications. The message arrival notifications are used to notify each receiving device to retrieve the message from the receiver message list based on the local maximum message number. Therefore, when multiple receiving devices on the recipient are running social applications, each receiving device can synchronize messages in a timely manner based on the local maximum message number. Only one message record of each message sent to the recipient needs to be stored in the recipient's message list, instead of storing messages separately for each type of receiving device. This reduces the storage pressure on the instant messaging system and helps improve system stability.
[0045] The message transmission method provided in this application realizes multi-terminal message synchronization of instant messaging systems, i.e., social applications, based on sequences. The message list of the recipient can be stored in a database. In the database, only one message record is saved for a single user for a single message, without distinguishing between different client types of users, thereby achieving higher database access performance and stronger scalability.
[0046] In some embodiments, the step of determining the message number corresponding to the second message includes: determining the largest message number among the message numbers contained in each message record in the recipient's message list; and incrementing the largest message number to obtain the message number corresponding to the second message.
[0047] For example, if there are 100 message records in the receiver's message list, and the largest message number among these 100 message records is 100, then the largest message number is 100. Incrementing can be done by adding 1, so the message number corresponding to the second message is 101.
[0048] In this embodiment, the maximum message number is incremented to obtain the message number corresponding to the second message. This allows the message number to reflect the order in which message records are written to the receiver's message list. The larger the message number, the later it is written. Thus, the receiver can actively retrieve messages based on the message number.
[0049] In some embodiments, the message record includes a message identifier, and the method further includes: receiving a message retrieval request sent by a receiving device, the message retrieval request carrying a recipient identifier and the local maximum message number of the receiving device; in response to the message retrieval request, determining a target message record from the recipient message list, the target message record being associated with the recipient identifier and the message number in the target message record being greater than the local maximum message number; and returning the message represented by the message identifier in the target message record and the message number to the receiving device.
[0050] Upon receiving a message arrival notification, the receiving device sends a message retrieval request to the server. The local maximum message number is the largest message number currently received by the receiving device. After receiving the message number returned by the server, the receiving device updates its local maximum message number. For example, if the local maximum message number is 100 and the message number in the target message record is 101, then the local maximum message number is updated to 101. If there are multiple target message records, the local maximum message number is updated to the largest message number contained in each target message record.
[0051] Specifically, in response to a message retrieval request, the server determines each message record associated with the recipient identifier and whose message number is greater than the local maximum message number from the recipient message list, and returns the message corresponding to the message identifier in each determined message record (i.e., the target message record) and the message number in the target message record to the receiving device.
[0052] In some embodiments, the server retrieves a message identifier from the target message record as the target message identifier, then queries the message associated with the target message identifier from the message storage list, returns the message associated with the target message identifier to the receiving device, and returns the message number corresponding to the message to the receiving device. The message storage list is stored in a database. When the message storage list contains encrypted messages, the encrypted messages can be sent to the receiving device, which can then decrypt them. Alternatively, the encrypted messages can be decrypted first and then sent to the receiving device.
[0053] In this embodiment, the receiving device retrieves messages with message numbers greater than its local maximum message number based on the local maximum message number. This allows for timely message synchronization across multiple receiving devices running social applications, ensuring each device can synchronize messages promptly based on its local maximum message number. The database only needs to store one record of each message sent to the recipient in the recipient's message list, eliminating the need to store messages separately for each type of receiving device. This reduces the storage burden on the instant messaging system and helps improve system stability.
[0054] In some embodiments, the first message carries a session identifier of the target session, and the method further includes: determining a list of user identifiers associated with the session identifier, wherein the user identifiers in the user identifier list represent users participating in the target session; and determining the recipient identifier of the recipient of the first message, including: using the user identifiers in the user identifier list as the recipient identifier of the recipient of the first message.
[0055] In this list of user identifiers, each user identifier represents a receiver. Each user identifier is a receiver identifier, and for each receiver, steps 202-210 described above can be used to transmit messages.
[0056] In this embodiment, the sender's identifier can be quickly determined by the user identifier list associated with the session identifier.
[0057] In some embodiments, determining the sequence associated with the receiver identifier from the sequence sequence set includes: performing a hash calculation on the receiver identifier to obtain a hash value corresponding to the receiver identifier; taking the number of sequence sequences in the sequence sequence set as the sequence number; determining the target sequence identifier based on the hash value and the sequence number; and determining the sequence sequence represented by the target sequence identifier in the sequence sequence set as the sequence associated with the receiver identifier.
[0058] Specifically, the sequence identifiers of the sequential sequences in the sequence set are continuously increasing values. For example, if the sequence set includes 128 sequential sequences, the sequence identifiers can be 0~127 or 1~128. The server can perform a modulo operation between the hash value and the number of sequences, and use the result of the modulo operation as the target sequence identifier. For example, if the hash value is 80, then 80 / 128=80, and therefore the target sequence identifier is 80.
[0059] In this embodiment, the target sequence identifier is determined based on the hash value and the number of sequences, so that messages sent to the same recipient can be written into the same sequential sequence to ensure that messages are consumed in order.
[0060] In some embodiments, generating a first recipient record corresponding to a first message includes: determining a message identifier for the first message; and generating a first recipient record corresponding to the first message based on the message identifier of the first message and the recipient identifier of the recipient of the first message.
[0061] The first recipient record contains the message identifier of the first message and the recipient identifier of the recipient of the first message.
[0062] In this embodiment, the message identifier and the receiver identifier are recorded in the first receiver record. The amount of recorded data is small, which reduces the occupation of storage resources.
[0063] like Figure 4The diagram illustrates the principle of message sending and receiving. The sender has sending device 1 and sending device 2, and the receiver has receiving device 1 and receiving device 2. Social applications run on sending device 1, sending device 2, receiving device 1, and receiving device 2. The sender sends a message to the receiver through the social application on sending device 1. The message is first stored in a database by a server. The server then notifies receiving devices 1 and 2 to actively initiate data retrieval requests. Upon receiving a message retrieval request from receiving device 1, the server retrieves the corresponding message and message number from the database and returns it to receiving device 1. Similarly, upon receiving a message retrieval request from receiving device 2, the server retrieves the corresponding message and message number from the database and returns it to receiving device 2. For example, in the diagram: 1. Send message; 2. Save encrypted messages and the recipient's message list; 3. Notify the receiver to retrieve messages; 4. Receiving devices actively retrieve messages; 5. The server queries messages with a specified user identifier (receiver identifier) whose message number is greater than the local maximum message number.
[0064] like Figure 5 The diagram illustrates the process from sending a message to writing it to the database. The sending device sends two messages, p1 and p2, to a group chat of n users, sequentially. For each user, the user's identifier and p1 form one receiver record, and the user's identifier and p2 form another receiver record. These two receiver records are then written into the sequential sequence associated with the user's identifier. For example... Figure 5 In the server, there are m sequential sequences, namely sequential sequence 1 to sequential sequence m, user_1 to user_n are the user identifiers of these n users, user_k represents the user identifier of the kth user, 1≤k≤n, userId is the user identifier field, packet is the message identifier field, user_1 is associated with sequential sequence 1, Message{“userId”:user_1,“packet”:p1} is a receiver record of the user represented by user_1, and Message{“userId”:user_1,“packet”:p2} is another receiver record of the user represented by user_1.
[0065] A server can have multiple consumers. The number of consumers may or may not match the number of sequential sequences; for example, consumers can correspond one-to-one with sequential sequences. A consumer can retrieve a receiver record from the corresponding sequential sequence and write it to the consumption queue associated with the corresponding receiver identifier. For example, receiver records related to user_1 are written to user_1's consumption queue, which can be represented as: "user_1: [Message{"userId":user_1,"packet":p1}, Message{"userId":user_1,"packet":p2}]". Then, the consumer can retrieve the receiver record from the consumption queue and write the message to the database according to the userId, thus generating a message record in the database containing the userId and the message.
[0066] The message transmission method provided in this application stores only one record of the message receiver in the backend in the form of a sequence. Different clients (or different types of terminal devices) of the receiver request messages from the backend and update their local maximum message number based on the maximum message number cached locally. This reduces the storage and access pressure on the database, enhances the scalability of receiver client types, and thus improves system stability. It can quickly support multiple receiver client types without affecting the stability of existing production operations. Furthermore, since each receiver only needs to store one receiver record for each message, it reduces the large number of writes generated by different client types, reduces the number of records in the database, and improves the access performance of the database interface.
[0067] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0068] Based on the same inventive concept, this application also provides a message transmission apparatus for implementing the message transmission method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more message transmission apparatus embodiments provided below can be found in the limitations of the message transmission method described above, and will not be repeated here.
[0069] In some embodiments, such as Figure 6 As shown, a message transmission device is provided, including: a message receiving module 602, a receiver record adding module 604, a receiver record reading module 606, a message record adding module 608, and a notification sending module 610, wherein:
[0070] The message receiving module 602 is used to receive the first message sent by the sending device of the sender, determine the recipient identifier of the first message, and the first message is triggered by the target session of the social application.
[0071] The receiver record addition module 604 is used to determine the sequence associated with the receiver identifier of the receiver from the sequence sequence set, generate the first receiver record corresponding to the first message, and add the first receiver record to the sequence associated with the receiver identifier. The receiver records in the sequence are arranged in the order of addition. The first receiver record is used to indicate the first message and the receiver identifier.
[0072] The receiver record reading module 606 is used to read a second receiver record from a sequence associated with a receiver identifier. The reading order of the receiver records in the sequence is consistent with the addition order of the receiver records. The second receiver record is used to indicate the second message and the receiver identifier.
[0073] The message record adding module 608 is used to add a message record associated with the receiver identifier to the receiver message list based on the second receiver record. The message record contains the message number corresponding to the second message, and the message number in the message record is used to represent the writing order of the message record.
[0074] The notification sending module 610 is used to send message arrival notifications to multiple receiving devices running social applications on the receiving party. The message arrival notifications are used to instruct each receiving device to retrieve the message from the receiving party's message list based on its local maximum message number. In some embodiments,
[0075] In some embodiments, the apparatus further includes a message number determination module, which is used to determine the largest message number among the message numbers contained in each message record in the receiver's message list; and increment the largest message number to obtain the message number corresponding to the second message.
[0076] In some embodiments, the message record includes a message identifier, and the apparatus further includes a request-response module. The request-response module is configured to receive a message retrieval request sent by a receiving device, the message retrieval request carrying a recipient identifier and the receiving device's local maximum message number; in response to the message retrieval request, determine a target message record from the recipient message list, the target message record being associated with the recipient identifier and the message number in the target message record being greater than the local maximum message number; and return the message represented by the message number and message identifier in the target message record to the receiving device.
[0077] In some embodiments, the first message carries a session identifier of the target session. The message receiving module is further configured to determine a list of user identifiers associated with the session identifier, wherein the user identifiers in the user identifier list represent users participating in the target session; and use the user identifiers in the user identifier list as the receiver identifiers of the receivers of the first message.
[0078] In some embodiments, the receiver record adding module 604 is further configured to perform a hash calculation on the receiver identifier to obtain a hash value corresponding to the receiver identifier; take the number of sequential sequences in the sequential sequence set as the sequence number; determine the target sequence identifier based on the hash value and the sequence number; and determine the sequential sequence represented by the target sequence identifier in the sequential sequence set as the sequential sequence associated with the receiver identifier.
[0079] In some embodiments, the receiver record adding module 604 is further configured to determine the message identifier of the first message; and generate a first receiver record corresponding to the first message based on the message identifier of the first message and the receiver identifier of the receiver of the first message.
[0080] Each module in the aforementioned message transmission device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of a computer device in hardware form or independent of it, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0081] In some embodiments, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 7As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores data involved in message transmission methods. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a message transmission method.
[0082] In some embodiments, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 8 As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When the computer program is executed by the processor, it implements a message transmission method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0083] Those skilled in the art will understand that Figure 7 and Figure 8The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0084] In some embodiments, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the message transmission method described above.
[0085] In some embodiments, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the message transmission method described above.
[0086] In some embodiments, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the message transmission method described above.
[0087] 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, data stored, data displayed, 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 the relevant data must comply with relevant regulations.
[0088] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory 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), magnetic 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. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0089] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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 application.
[0090] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A message transmission method, characterized in that, The method includes: Receive a first message sent by the sender's sending device, determine the recipient identifier of the first message, and the first message is triggered by a target session of a social application; From the sequence set, determine the sequence associated with the receiver identifier of the receiver, generate the first receiver record corresponding to the first message, and add the first receiver record to the sequence associated with the receiver identifier. The receiver records in the sequence are arranged in the order of addition. The first receiver record is used to indicate the first message and the receiver identifier. A second receiver record is read from the sequential sequence associated with the receiver identifier, wherein the reading order of the receiver records in the sequential sequence is consistent with the addition order of the receiver records, and the second receiver record is used to indicate the second message and the receiver identifier; Based on the second receiver record, a new message record associated with the receiver identifier is added to the receiver message list. The message record contains the message number corresponding to the second message, and the message number in the message record is used to represent the writing order of the message record. A message arrival notification is sent to each of the recipient's multiple receiving devices running the social application. The message arrival notification is used to notify each receiving device to retrieve a message from the recipient's message list based on its local maximum message number.
2. The method according to claim 1, characterized in that, The steps for determining the message number corresponding to the second message include: Determine the largest message number among the message numbers contained in each message record of the recipient's message list; The message number corresponding to the second message is obtained by incrementing the maximum message number.
3. The method according to claim 2, characterized in that, The message record contains a message identifier, and the method further includes: Receive a message retrieval request sent by the receiving device, wherein the message retrieval request carries the receiver identifier and the local maximum message number of the receiving device; In response to the message retrieval request, a target message record is determined from the recipient message list, the target message record being associated with the recipient identifier, and the message number in the target message record being greater than the local maximum message number; The message represented by the message number and message identifier in the target message record is returned to the receiving device.
4. The method according to claim 1, characterized in that, The first message carries the session identifier of the target session, and the method further includes: Determine a list of user identifiers associated with the session identifier, wherein the user identifiers in the list represent users who are participating in the target session; The process of determining the recipient identifier of the first message includes: The user identifier in the user identifier list is used as the receiver identifier of the recipient of the first message.
5. The method according to any one of claims 1 to 4, characterized in that, Determining the sequence associated with the receiver's identifier from the sequence set includes: Perform a hash calculation on the receiver identifier to obtain the hash value corresponding to the receiver identifier; The number of sequential sequences in the set of sequential sequences is taken as the number of sequences; The target sequence identifier is determined based on the hash value and the number of sequences; The sequence represented by the target sequence identifier in the sequence set is determined as the sequence associated with the receiver identifier.
6. The method according to any one of claims 1 to 4, characterized in that, The generation of the first receiver record corresponding to the first message includes: Determine the message identifier of the first message; Based on the message identifier of the first message and the receiver identifier of the receiver of the first message, a first receiver record corresponding to the first message is generated.
7. A message transmission device, characterized in that, The device includes: The message receiving module is used to receive the first message sent by the sender's sending device, determine the recipient identifier of the first message, and the first message is triggered by the target session of the social application. The receiver record addition module is used to determine the sequence associated with the receiver identifier of the receiver from the sequence set, generate the first receiver record corresponding to the first message, and add the first receiver record to the sequence associated with the receiver identifier. The receiver records in the sequence are arranged in the order of addition. The first receiver record is used to indicate the first message and the receiver identifier. The receiver record reading module is used to read a second receiver record from the sequential sequence associated with the receiver identifier, wherein the reading order of the receiver records in the sequential sequence is consistent with the addition order of the receiver records, and the second receiver record is used to indicate the second message and the receiver identifier; The message record adding module is used to add a message record associated with the receiver identifier to the receiver message list based on the second receiver record. The message record contains the message number corresponding to the second message, and the message number in the message record is used to represent the writing order of the message record. The notification sending module is used to send message arrival notifications to multiple receiving devices of the recipient running the social application, respectively. The message arrival notification is used to notify each receiving device to retrieve a message from the recipient's message list based on the local maximum message number.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Message synchronization method and device, storage medium and electronic equipment
CN109617949A
Proxied Outgoing Message Transmission
US20130157624A1