Message transmission method and device, computer equipment and readable storage medium
By using the sequential sequence collection and the receiver message list in the instant messaging system, the problem of message storage pressure of multiple terminal devices is solved, synchronous storage and notification of messages are realized, and system stability is improved.
Patent Information
- Application Number
- CN202411702052.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-02-25
- Estimated Expiration
- 2044-11-26
AI Technical Summary
The instant messaging system needs to record the messages to be transmitted for multiple terminal devices, resulting in an increase in storage pressure and affecting system stability.
By determining the sequence sequence associated with the receiver identification of the receiver's receiver in the sequential sequence set, a receiver record corresponding to the message is generated, and a message record is added to the receiver's message list, synchronous storage and notification of messages are realized.
The storage pressure of the instant messaging system is reduced, the stability of the system is improved, so that each receiving device can synchronize messages in a timely manner, and only a message record of each message sent by the receiving party is required to store in the message list of the receiver.
Smart Images

Figure CN119520456A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the fields of Internet and computer technology, and in particular to a message transmission method, apparatus, computer equipment, and readable storage medium. Background Art
[0002] With the development of internet technology, instant messaging (IM) applications are becoming increasingly widespread. IM applications can provide users with communication capabilities such as text, image, voice, and video in single or group chats. As the variety of terminal devices continues to expand, IM applications are now available in different versions to accommodate different types of devices, such as mobile terminals and personal computers. IM systems can support the sending and receiving of messages on different types of terminal devices using the corresponding versions of IM applications.
[0003] In related technologies, an instant messaging system needs to record messages to be transmitted for various terminal devices respectively, which increases the storage pressure of the instant messaging system and thus affects the stability of the instant messaging system. Summary of the Invention
[0004] Based on this, it is necessary to provide a message transmission method, device, computer equipment, computer-readable storage medium and computer program product that can improve the stability of the instant messaging system in response to the above technical problems.
[0005] On the one hand, the present application provides a message transmission method, comprising: receiving a first message sent by a sending device of a sender, determining a receiver identifier of a receiver of the first message, wherein the first message is triggered by a target session of a social application; determining a sequence sequence associated with the receiver identifier of the receiver from a sequence sequence set, generating a first receiver record corresponding to the first message, adding the first receiver record to the sequence sequence associated with the receiver identifier, wherein the receiver records in the sequence sequence are arranged in an order of addition, and the first receiver record is used to indicate the first message and the receiver identifier; reading a second receiver record from the sequence sequence associated with the receiver identifier records, the reading order of the recipient records in the sequential sequence is consistent with the adding 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, a message record associated with the recipient identifier is added to the recipient message list, the message record contains a 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 records; a message arrival notification is sent to multiple receiving devices of the recipient that are running the social application, and the message arrival notification is used to notify each of the receiving devices to obtain a message from the recipient message list based on the local maximum message number.
[0006] On the other hand, the present application also provides a message transmission device, including: a message receiving module, used to receive a first message sent by a sending device of a sender, determine a receiver identifier of a receiver of the first message, wherein the first message is triggered by a target session of a social application; a receiver record adding module, used to determine a sequential sequence associated with the receiver identifier of the receiver from a sequential sequence set, generate a first receiver record corresponding to the first message, add the first receiver record to the sequential sequence associated with the receiver identifier, the receiver records in the sequential sequence are arranged in an order of addition, and the first receiver record is used to indicate the first message and the receiver identifier; a receiver record reading module, used to determine a sequential sequence associated with the receiver identifier from a sequential sequence set, generate a first receiver record corresponding to the first message, and add the first receiver record to the sequential sequence associated with the receiver identifier, wherein the receiver records in the sequential sequence are arranged in an order of addition, and the first receiver record is used to indicate the first message and the receiver identifier; Read the second recipient record, the reading order of the recipient records in the sequential sequence is consistent with the adding order of the recipient records, and the second recipient record is used to indicate the second message and the recipient identifier; a message record adding module is used to add a message record associated with the recipient identifier in the recipient message list based on the second recipient record, and 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 records; a notification sending module is used to send message arrival notifications to multiple receiving devices of the recipient that are running the social application, and the message arrival notification is used to notify each of the receiving devices to obtain messages from the recipient message list based on the local maximum message number.
[0007] On the other hand, the present application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps in the above-mentioned message transmission method when executing the computer program.
[0008] On the other hand, the present application also provides a computer-readable storage medium having a computer program stored thereon, which implements the steps in the above-mentioned message transmission method when executed by a processor.
[0009] On the other hand, the present application also provides a computer program product, including a computer program, which implements the steps in the above-mentioned message transmission method when executed by a processor.
[0010] The message transmission method, apparatus, computer device, computer-readable storage medium, and computer program product described above receive a first message sent by a sending device of a sender, determine a recipient identifier of a recipient of the first message, wherein the first message is triggered by a target session of a social application, determine a sequence sequence associated with the recipient identifier of the recipient from a set of sequence sequences, add a first recipient record corresponding to the first message to the sequence sequence associated with the recipient identifier, wherein the recipient records in the sequence sequence are arranged in the order in which they are added, and the first recipient record is used to indicate the first message and the recipient identifier. A second recipient record is read from the sequence sequence associated with the recipient identifier, wherein the reading order of the recipient records in the sequence sequence is consistent with the order in which the recipient records are added, and the second recipient record is used to indicate the second message and the recipient identifier. Based on the second recipient record, a message record associated with the recipient identifier is added to the recipient message list, wherein the message record includes a message number corresponding to the second message, and the message number in the message record is used to indicate the order in which the message records are written. A message arrival notification is sent to each of the recipient's multiple receiving devices running the social application, wherein the message arrival notification is used to notify each receiving device to obtain a message from the recipient message list based on the local maximum message number. Therefore, when social applications are running on multiple receiving devices of the recipient, each receiving device can synchronize messages in a timely manner based on the local maximum message number. It is only necessary to store a message record of each message sent to the recipient in the recipient's message list, without having to store messages separately for each type of receiving device. This reduces the storage pressure of the instant messaging system and helps improve system stability. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following briefly introduces the drawings required for use in the embodiments of the present application or related technical descriptions. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying any creative work.
[0012] FIG1 is a diagram illustrating an application environment of a message transmission method in some embodiments;
[0013] FIG2 is a schematic diagram of a flow chart of a message transmission method in some embodiments;
[0014] FIG3 is a schematic diagram of a recipient message list in some embodiments;
[0015] FIG4 is a schematic diagram illustrating the process from sending a message to receiving a message in some embodiments;
[0016] FIG5 is a schematic diagram illustrating the process from sending a message to writing the message into a database in some embodiments;
[0017] FIG6 is a structural block diagram of a message transmission apparatus in some embodiments;
[0018] FIG7 is a diagram illustrating the internal structure of a computer device in some embodiments;
[0019] FIG8 is a diagram illustrating the internal structure of a computer device in some embodiments. DETAILED DESCRIPTION
[0020] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0021] The message transmission method provided in the embodiment of the present application can be applied to the application environment shown in Figure 1, which includes a sending device 102, a server 104 and a receiving device 106. Among them, the sending device 102, the server 104 and the receiving device 106 can communicate with each other through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The data storage system can be any type of database. The data storage system and the server belong to an instant messaging system. The server 104 is the background server of the instant messaging application. The server 104 provides the function of registering sessions and can also provide some common functions of instant messaging, such as establishing groups, adding friends, chatting and transferring files. The server 104 can be, but is not limited to, an Openfire server. The Openfire server is an open source, real-time collaboration server based on the Extensible Messaging and Presence Protocol (XMPP) and developed in the Java programming language.
[0022] The sending device 102 and the receiving device 106 can be the same type of terminal devices, for example, a mobile terminal. The sending device 102 and the receiving device 106 can also be different types of terminal devices, for example, the sending device 102 is a mobile terminal and the receiving device is a personal computer.
[0023] Server 104 is deployed with a distributed messaging middleware, which can be, but is not limited to, RocketMQ (Rocket Message Queue) or Kafka. When server 104 starts, a set of sequential sequences, or queues, is initialized by default. The number of sequential sequences can be preset and adjusted based on actual needs through configuration, for example, to 128. Sequences can be understood as topics in the distributed messaging middleware.
[0024] Specifically, a social application is running on sending device 102 and receiving device 106. Sending device 102 can display a session interface for a target session in the social application. The target session can be any session created in the social application. When an operation to initiate a first message to the target session is triggered in the session interface, sending device 102 sends the first message to server 104 and determines the recipient identifier of the recipient of the first message. Server 104 determines a sequence associated with the recipient identifier from a set of sequence sequences 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 sequence are arranged in the order of addition, and the first recipient record is used to indicate the first message and the recipient identifier. Server 104 can consume messages in the sequence sequence. Consuming messages means storing the messages in a data storage system, such as a database. The server 104 can read the second recipient record from the sequential sequence associated with the recipient identifier. The reading order of the recipient records in the sequential sequence is consistent with the order in which the recipient records are added. The second recipient record is used to indicate the second message and the recipient identifier. Based on the second recipient record, a message record associated with the recipient identifier is added to the recipient message list. The message record includes a 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. A message arrival notification is sent to multiple receiving devices of the recipient that are running a social application. The message arrival notification is used to notify each receiving device to obtain a message from the recipient message list based on the local maximum message number.
[0025] The sending device 102 and receiving device 104 may be, but are not limited to, desktop computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices may include smart speakers, smart TVs, smart air conditioners, smart car devices, projectors, and the like. Portable wearable devices may include smart watches, smart bracelets, head-mounted devices, and the like. Head-mounted devices may include virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, and the like. Server 104 may be a standalone physical server, a server cluster or distributed system consisting of multiple physical servers, or a cloud server providing cloud computing services. Cloud servers are used to provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDNs (Content Delivery Networks), and big data and artificial intelligence platforms. The sending device 102, server 104, and receiving device 106 may be connected directly or indirectly via wired or wireless communication, which is not limited in this application.
[0026] In some embodiments, as shown in FIG2 , a message transmission method is provided. The method can be executed by a terminal or a server, or can be executed by both the terminal and the server. The method is described by taking the application of the method to the server 104 in FIG1 as an example, and includes the following steps 202 to 206. Among them:
[0027] Step 202: Receive a first message sent by a sending device of a sender, determine a recipient identifier of a recipient of the first message, and the first message is triggered by a target session of a social application.
[0028] The social application can be any instant messaging application. The target session can be any session established in 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, and 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 recipient identifiers used to identify different recipients, meaning that 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 sequential sequence associated with the receiver identifier of the receiver from the sequential sequence set, generate a first receiver record corresponding to the first message, and add the first receiver record to the sequential sequence associated with the receiver identifier. The receiver records in the sequential sequence are arranged in the order of addition, and the first receiver record is used to indicate the first message and the receiver identifier.
[0030] One receiver identifier is associated with, that is, corresponds to, one sequential sequence, and one sequential sequence can be associated with, that is, corresponds to, one or more receiver identifiers, and multiple means at least two.
[0031] Recipient records are used to record the recipient's identifier and message identifier. For example, a recipient record can be represented as Message{"userId":user_1,"packet":p1}, where userId is the user identifier (recipient identifier), packet is the message identifier, user_1 is the recipient identifier, and p1 is the message identifier. The first recipient record can contain the message identifier of the first message and the recipient identifier. A sequential sequence is a sequential queue. Recipient records in a sequential sequence are arranged in the order they are added. Recipient records in a sequential sequence are first in, first out (FIFO), meaning that the first recipient record added to the sequence is removed first. A consumer on a server, such as an Openfire service in an Openfire service cluster, can store the contents of a recipient record in the sequential sequence in the database, thereby consuming the recipient records in the sequential sequence. A recipient record in the sequential sequence can only be consumed by one consumer at a time. After successfully consuming a recipient record, the consumer can proceed to consume the next recipient record. This ensures the order of messages for the same recipient in the database.
[0032] Specifically, the server may generate a message identifier of the first message, and may associate the first message and the first message identifier and store them in a message storage list, so that the first message may be retrieved from the message storage list according to the message identifier of the first message.
[0033] In some embodiments, the message storage list may store messages in an encrypted manner. Specifically, the server may encrypt the first message to obtain an encrypted message of the first message, and then associate the encrypted message of the first message with the message identifier of the first message and store it in the message storage list.
[0034] Step 206: read a second recipient record from the sequential sequence associated with the recipient identifier. The reading order of the recipient records in the sequential sequence is consistent with the order in which the recipient records are added. The second recipient record is used to indicate the second message and the recipient 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 consistent with the order in which it is added: recipient records added to the sequence are prioritized, while those read from the sequence are prioritized, i.e., first-in, first-out. Similarly, the second recipient record may include the message identifier of the second message and the recipient identifier of the recipient of the second message.
[0036] Specifically, the sequence sequence has a head and a tail. The recipient record in the sequence sequence is removed from the head and added to the tail, thereby implementing first-in, first-out. The second recipient record is the recipient record at the head of the sequence sequence. The server can read the recipient record from the head of the sequence sequence to obtain the second recipient record.
[0037] Step 208: Based on the second recipient record, a message record associated with the recipient identifier is added to the recipient message list. The message record includes a message number corresponding to the second message. The message number in the message record is used to indicate the writing order of the message records.
[0038] The message record includes the message number, recipient ID, and message ID. The message record added based on the second recipient record includes the message number of the second message, the message ID of the second message, and the recipient ID of the recipient of the second message. Of course, it can also include other information such as the unique ID of the message record or information related to the transaction.
[0039] The message number in the message record written first to the recipient's message list is smaller than the message number in the message record written later. The recipient's message list can store message records associated with different recipient identifiers. Figure 3 shows the recipient's message list. Because the message number in a message record indicates the order in which the message records are written, the message number can also be called a sequence offset.
[0040] Specifically, the recipient message list is stored in a database. The server first writes the second recipient record into the consumption queue associated with the recipient identifier. The recipient records in the consumption queue also meet the first-in-first-out principle. The server can extract the first recipient record in the consumption queue and send it to the database. The database adds a new message record associated with the recipient identifier to the recipient message list based on the recipient record. If the new message record is successfully added, the server again executes the step of extracting the first recipient record in the consumption queue and sending it to the database, thereby adding new message records to the recipient message list in sequence.
[0041] Step 210: Send a message arrival notification to each of the multiple receiving devices of the recipient that are running a social application. The message arrival notification is used to notify each receiving device to obtain a message from the recipient's message list based on the local maximum message number.
[0042] Wherein, in the case where the server is an Openfire server, the message arrival notification may be an XMPP signaling. The local maximum message number is the largest message number among the message numbers of the messages 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 identifies, from the recipient's message list, each message record associated with the recipient's identifier and whose message number is greater than the local maximum message number. The server then returns the message and message number in each identified message record, i.e., the target message record, to the receiving device.
[0044] In the above-mentioned message transmission method, a first message sent by a sending device of a sender is received, a receiver identifier of a receiver of the first message is determined, the first message is triggered by a target session of a social application, a sequence sequence associated with the receiver identifier of the receiver is determined from a sequence sequence set, a 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 order in which the receiver records are added, 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 a 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 records, and a message arrival notification is sent to multiple receiving devices of the receiver running the social application, the message arrival notification is used to notify each receiving device to obtain a message from the receiver message list based on the local maximum message number. Therefore, when social applications are running on multiple receiving devices of the recipient, each receiving device can synchronize messages in a timely manner based on the local maximum message number. It is only necessary to store a message record of each message sent to the recipient in the recipient's message list, without having to store messages separately for each type of receiving device. This reduces the storage pressure of the instant messaging system and helps improve system stability.
[0045] The message transmission method provided in the present application realizes multi-terminal message synchronization of an instant messaging system, i.e., a social application, based on a sequence. The recipient message list can be stored in a database. In the database, only one message record is saved for a single user of a single message, without distinguishing between different client types of users, thereby having 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 maximum message number among the message numbers respectively contained in each message record in the recipient's message list; incrementing the maximum message number to obtain the message number corresponding to the second message.
[0047] For example, there are 100 message records in the recipient message list, and the largest message number among these 100 message records is 100. Then the largest message number is 100, and the increment can be an addition operation, 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, so that the message number can reflect the order in which the message records are written into the recipient's message list. The larger the message number, the later it is written, so the recipient can actively pull the message according to 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 carries a recipient identifier and a 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 is associated with the recipient identifier, and the message number in the target message record is greater than the local maximum message number; and returning the message and message number represented by the message identifier in the target message record to the receiving device.
[0050] After receiving a message arrival notification, the receiving device sends a message retrieval request to the server. The local maximum message number is the highest message number currently received by the receiving device. After receiving the message number returned by the server, the receiving device updates the local maximum message number. For example, if the local maximum message number is 100 and the target message record contains message number 101, 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 highest message number among the message numbers contained in each target message record.
[0051] Specifically, in response to the message retrieval request, the server determines from the recipient message list each message record associated with the recipient identifier and whose message number is greater than the local maximum message number, and returns each determined message record, i.e., the message corresponding to the message identifier in the target message record and the message number in the target message record, to the receiving device.
[0052] In some embodiments, the server obtains a message identifier from the target message record as the target message identifier, then searches a message storage list for the message associated with the target message identifier, 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. If the message storage list contains an encrypted message, the encrypted message can be sent to the receiving device, which can then decrypt the encrypted message. Alternatively, the encrypted message can be decrypted before being sent to the receiving device.
[0053] In this embodiment, the receiving device retrieves messages with a message number greater than the local maximum message number based on the local maximum message number. This allows each receiving device to synchronize messages in a timely manner based on the local maximum message number, even if social applications are running on multiple receiving devices. The database only needs to store one message record for each message sent to a recipient in the recipient's message list, rather than storing messages separately for each type of receiving device. This reduces the storage pressure 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 user identifier list associated with the session identifier, where the users represented by the user identifiers in the user identifier list are users participating in the target session; determining a recipient identifier of a recipient of the first message, including: using the user identifier in the user identifier list as the recipient identifier of the recipient of the first message.
[0055] Each user ID in the user ID list represents a recipient. Each user ID is a recipient ID, and for each recipient, the above steps 202-210 can be used to implement message transmission.
[0056] In this embodiment, the sender identifier can be quickly determined through the user identifier list associated with the session identifier.
[0057] In some embodiments, determining a sequential sequence associated with a receiver identifier of a receiver from a sequential sequence set includes: performing a hash calculation on the receiver identifier to obtain a hash value corresponding to the receiver identifier; using the number of sequential sequences in the sequential sequence set as the number of sequences; determining a target sequence identifier based on the hash value and the number of sequences; and determining the sequential sequence represented by the target sequence identifier in the sequential sequence set as the sequential sequence associated with the receiver identifier.
[0058] Specifically, the sequence identifiers of the sequential sequences in the sequential sequence set are continuously increasing values. For example, if the sequential sequence set includes 128 sequential sequences, the sequence identifiers can range from 0 to 127 or from 1 to 128. The server can perform a modulo operation on 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 thus the target sequence identifier is 80.
[0059] In this embodiment, the target sequence identifier is determined based on the hash value and the sequence number, so that messages sent to the same recipient can be written into the same sequential sequence to ensure that the messages are consumed in order.
[0060] In some embodiments, generating a first recipient record corresponding to a first message includes: determining a message identifier of the first message; and generating a first recipient record corresponding to the first message based on the message identifier of the first message and a recipient identifier of a recipient of the first message.
[0061] The first recipient record includes 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 recipient identifier are recorded in the first recipient record, and the amount of recorded data is relatively small, thereby reducing the occupation of storage resources.
[0063] Figure 4 shows a schematic diagram of the process from sending to receiving messages. The sender has sending devices 1 and 2, and the receiver has receiving devices 1 and 2. Social applications are running on all three devices. The sender sends a message to the receiver via the social application on sending device 1. The message is first stored in a database by the server. The server then notifies receiving devices 1 and 2 to initiate a data retrieval request. After receiving the 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, after receiving the 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 figure, 1. Send a message; 2. Save the encrypted message and the recipient's message list; 3. Notify the recipient to retrieve messages; 4. The receiving device actively retrieves messages; and 5. The server queries for messages with a specified user ID (recipient ID) and a message number greater than the local maximum message number.
[0064] As shown in Figure 5, a schematic diagram is provided for the process from sending a message to writing it to the database. A sending device sends two messages, p1 and p2, to a group chat of n users. These two messages are sent sequentially. For each user, the user ID and p1 form a recipient record for that user, and the user ID and p2 form another recipient record for that user. These two recipient records for that user are written to a sequence associated with that user's ID. For example, in Figure 5, there are m sequence sequences in the server, namely sequence 1 through sequence m. User_1 through user_n are the user IDs of the n users, respectively. User_k represents the user ID of the kth user, where 1 ≤ k ≤ n. UserId is the user ID field, and packet is the message ID field. User_1 is associated with sequence 1. Message {"userId":user_1, "packet":p1} is a recipient record for the user represented by user_1, and Message {"userId":user_1, "packet":p2} is another recipient record for the user represented by user_1.
[0065] A server can have multiple consumers, and the number of consumers can be consistent with or different from the number of sequential sequences. For example, consumers can correspond one-to-one with sequential sequences. Consumers can retrieve recipient records from the corresponding sequential sequence and write them to the consumption queue associated with the corresponding recipient identifier. For example, the recipient record associated with user_1 is written to user_1's consumption queue. User_1's consumption queue can be represented as: "user_1: [Message{"userId":user_1, "packet":p1}, Message{"userId":user_1, "packet":p2}]". The consumer can then retrieve the recipient record from the consumption queue and write the message to the database according to the userId, generating a message record in the database containing the userId and the message.
[0066] The message transmission method provided by this application saves only one record of the message recipient in the backend in the form of a sequence, and different clients of the recipient (or different types of terminal devices) will request messages from the backend and update the local maximum message number based on the condition of the maximum message number in the local cache. In order to reduce the storage and access pressure of the database, enhance the scalability of the recipient client type, thereby improving the stability of the system, and can quickly support multiple types of recipient clients without affecting the stability of existing production business. And because each message and each recipient only needs to save one recipient record, it reduces the large amount of message diffusion writes generated by the client type, 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 various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above can include multiple steps or multiple stages, and these steps or stages are not necessarily executed and completed 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 portion of steps or stages in other steps.
[0068] Based on the same inventive concept, embodiments of the present application also provide a message transmission device for implementing the aforementioned message transmission method. The implementation solution provided by this device is similar to the implementation solution described in the aforementioned method. Therefore, the specific limitations of one or more message transmission device embodiments provided below can be found in the above-mentioned limitations of the message transmission method and will not be repeated here.
[0069] In some embodiments, as shown in FIG6 , a message transmission device is provided, including: a message receiving module 602, a recipient record adding module 604, a recipient record reading module 606, a message record adding module 608, and a notification sending module 610, wherein:
[0070] The message receiving module 602 is configured to receive a first message sent by a sending device of a sender, and determine a receiver identifier of a receiver of the first message, where the first message is triggered by a target session of a social application.
[0071] The receiver record adding module 604 is used to determine the sequential sequence associated with the receiver identifier of the receiver from the sequential sequence set, generate the first receiver record corresponding to the first message, and add the first receiver record to the sequential sequence associated with the receiver identifier. The receiver records in the sequential sequence are arranged in the order of addition, and the first receiver record is used to indicate the first message and the receiver identifier.
[0072] The recipient record reading module 606 is used to read the second recipient record from the sequential sequence associated with the recipient identifier. The reading order of the recipient records in the sequential sequence is consistent with the order in which the recipient records are added. The second recipient record is used to indicate the second message and the recipient identifier.
[0073] The message record adding module 608 is used to add a message record associated with the recipient identifier in the recipient message list based on the second recipient record. 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.
[0074] The notification sending module 610 is used to send a message arrival notification to multiple receiving devices of the recipient that are running a social application. The message arrival notification is used to notify each receiving device to obtain a message from the recipient's message list based on the local maximum message number. In some embodiments,
[0075] In some embodiments, the device also includes a message number determination module, which is used to determine the maximum message number among the message numbers contained in each message record in the recipient's message list; increment the maximum 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 device also includes a request response module, which is used to receive a message acquisition request sent by a receiving device, and the message acquisition request carries the recipient identifier and the local maximum message number of the receiving device; in response to the message acquisition request, the target message record is determined from the recipient message list, the target message record is associated with the recipient identifier, and the message number in the target message record is greater than the local maximum message number; and the message represented by the message number and message identifier in the target message record is returned to the receiving device.
[0077] In some embodiments, the first message carries a session identifier of the target session, and the message receiving module is further used to determine a user identifier list associated with the session identifier, where the users represented by the user identifiers in the user identifier list are users participating in the target session; and the user identifiers in the user identifier list are used as the recipient identifier of the recipient of the first message.
[0078] In some embodiments, the recipient record adding module 604 is further used to perform hash calculation on the recipient identifier to obtain a hash value corresponding to the recipient identifier; use the number of sequential sequences in the sequential sequence set as the number of sequences; determine the target sequence identifier based on the hash value and the number of sequences; and determine the sequential sequence represented by the target sequence identifier in the sequential sequence set as the sequential sequence associated with the recipient identifier.
[0079] In some embodiments, the recipient record adding module 604 is further used to determine the message identifier of the first message; and generate a first recipient record corresponding to the first message according to the message identifier of the first message and the recipient identifier of the recipient of the first message.
[0080] Each module in the above-mentioned message transmission device can be implemented in whole or in part through software, hardware, or a combination thereof. Each module can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory of the computer device in software form, so that the processor can call and execute the corresponding operations of each module.
[0081] In some embodiments, a computer device is provided, which may be a server, and its internal structure diagram may be shown in Figure 7. The computer device includes a processor, memory, an input / output (I / O) interface, and a communication interface. The processor, memory, and I / O interface are connected via a system bus, and the communication interface is connected to the system bus via the I / O interface. 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 computer program in the non-volatile storage medium. The database of the computer device is used to store data involved in a message transmission method. The I / O 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 via a network connection. When executed by the processor, the computer program implements a message transmission method.
[0082] In some embodiments, a computer device is provided, which may be a terminal. Its internal structure may be as shown in Figure 8. The computer device includes a processor, memory, an input / output interface, a communication interface, a display unit, and an input device. The processor, memory, and input / output interface are connected via a system bus, and the communication interface, display unit, and input device are connected to the system bus via the input / output interface. The processor of the computer device provides computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operating system and computer program stored in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals via wired or wireless means. The wireless means may be implemented via Wi-Fi, a mobile cellular network, near-field communication (NFC), or other technologies. When executed by the processor, the computer program implements a message transmission method. The display unit of the computer device is used to produce a visually visible image and may be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device casing, or an external keyboard, touchpad or mouse.
[0083] Those skilled in the art will understand that the structures shown in Figures 7 and 8 are merely block diagrams of partial structures related to the solution of the present application, and do 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 shown in the figures, or combine certain components, or have a different component arrangement.
[0084] In some embodiments, 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 message transmission method when executing the computer program.
[0085] In some embodiments, 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 message transmission method are implemented.
[0086] In some embodiments, a computer program product is provided, comprising a computer program, which implements the steps in the above-mentioned message transmission method when executed by a processor.
[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, 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 regulations.
[0088] Those skilled in the art will understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. 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. In particular, any reference to memory, database, 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 various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The databases involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the various embodiments provided herein may be, but are not limited to, general-purpose processors, central processing units (CPUs), graphics processing units (GPUs), digital signal processors (DSPs), programmable logic devices (PLDs), quantum computing-based data processing logic devices, artificial intelligence (AI) processors, and the like.
[0089] The technical features of the above embodiments can be combined arbitrarily. In order 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 application.
[0090] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.
Claims
1. A message transmission method, characterized in that: The method comprises: receiving a first message sent by a sending device of a sender, and determining a receiver identifier of a receiver of the first message, wherein the first message is triggered by a target session of a social application; Determine, from the sequence sequence set, a sequence sequence associated with the receiver identifier of the receiver, generate a first receiver record corresponding to the first message, add the first receiver record to the sequence sequence associated with the receiver identifier, the receiver records in the sequence sequence are arranged in the order of addition, and the first receiver record is used to indicate the first message and the receiver identifier; Reading a second recipient record from the sequential sequence associated with the recipient identifier, wherein the reading order of the recipient records in the sequential sequence is consistent with the adding order of the recipient records, and the second recipient record is used to indicate the second message and the recipient identifier; Based on the second recipient record, a message record associated with the recipient identifier is added to the recipient message list, wherein the message record contains a message number corresponding to the second message, and the message number in the message record is used to indicate the writing order of the message records; A message arrival notification is sent to each of the plurality of receiving devices of the receiving party running the social application, wherein the message arrival notification is used to notify each of the receiving devices to obtain a message from the receiving party message list based on a local maximum message number.
2. The method according to claim 1, characterized in that The step of determining a message number corresponding to the second message includes: Determine the maximum message number among the message numbers respectively included in each message record in the recipient message list; The maximum message number is incremented to obtain a message number corresponding to the second message.
3. The method according to claim 2, characterized in that The message record includes a message identifier, and the method further includes: Receiving a message acquisition request sent by the receiving device, wherein the message acquisition request carries the recipient identifier and the local maximum message number of the receiving device; In response to the message acquisition request, determine a target message record from the recipient message list, the target message record is associated with the recipient identifier, and a message number in the target message record is greater than the local maximum message number; The message represented by the message number and the 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 a session identifier of the target session, and the method further includes: Determine a user identification list associated with the session identification, wherein users represented by user identifications in the user identification list are users participating in the target session; The determining a recipient identifier of a recipient of the first message includes: The user identifier in the user identifier list is used as the recipient 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 sequential sequence associated with the receiver identification of the receiver from the sequential sequence set includes: Performing a hash calculation on the recipient identifier to obtain a hash value corresponding to the recipient identifier; Taking the number of sequential sequences in the sequential sequence set as the number of sequences; Determine a target sequence identifier according to the hash value and the number of sequences; The sequential sequence represented by the target sequence identifier in the sequential sequence set is determined as the sequential sequence associated with the receiver identifier.
6. The method according to any one of claims 1 to 4, characterized in that: The generating a first recipient record corresponding to the first message includes: determining a message identifier of the first message; A first recipient record corresponding to the first message is generated according to the message identifier of the first message and the recipient identifier of the recipient of the first message.
7. A message transmission device, characterized in that: The device comprises: a message receiving module, configured to receive a first message sent by a sending device of a sender, and determine a receiver identifier of a 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, from a sequence sequence set, a sequence sequence associated with a receiver identifier of the receiver, generate a first receiver record corresponding to the first message, and add the first receiver record to the sequence sequence associated with the receiver identifier, wherein the receiver records in the sequence sequence are arranged in an order of addition, and the first receiver record is used to indicate the first message and the receiver identifier; A receiver record reading module, configured to read a second receiver record from a sequential sequence associated with the receiver identifier, wherein the reading order of the receiver records in the sequential sequence is consistent with the adding order of the receiver records, and the second receiver record is used to indicate a second message and the receiver identifier; A message record adding module, configured to add a message record associated with the recipient identifier in the recipient message list based on the second recipient record, wherein the message record includes a message number corresponding to the second message, and the message number in the message record is used to indicate the writing order of the message records; A notification sending module is used to send message arrival notifications to multiple receiving devices of the receiving party running the social application, respectively, and the message arrival notification is used to notify each of the receiving devices to obtain a message from the receiving party 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, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. 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 6 are implemented.
10. A computer program product, comprising a computer program, 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 6 are implemented.
Citation Information
Patent Citations
Message synchronization method and device, storage medium and electronic equipment
CN109617949A
Message processing method and device, electronic equipment and storage medium
CN116055431A
Session message processing method and device
CN117411843A
Proxied Outgoing Message Transmission
US20130157624A1