Instant messaging group message sending method and server system
By combining and sending messages in the connection service component of the instant messaging server, the problems of network resource occupation and message delay in traditional instant messaging group chats when the number of users increases significantly, and more efficient message sending is achieved.
Patent Information
- Application Number
- CN202510085960.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-20
- Publication Date
- 2025-04-25
AI Technical Summary
When the number of users increases significantly, traditional instant messaging group chats can easily lead to excessive consumption of network resources during peak message sending and delays during low message sending.
By receiving messages in real-time in the connection service component of the instant communication server, the number of messages and time intervals after the previous message is sent are obtained. When the preset conditions are met, messages are merged and sent at one time to reduce network resource usage and control message delay.
It effectively reduces the use of network resources during the peak period of message sending, and reduces the delay in the trough period of message sending, improving the efficiency and performance of message sending.
Smart Images

Figure CN119892772A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of instant messaging technology, and in particular to an instant messaging group message sending method and a server system. Background Art
[0002] In the traditional sense, instant messaging group chats usually involve a relatively small number of users. With the rapid development of business, group chats with a small number of users can no longer meet the needs of many business scenarios. Significantly increasing the number of participants in group chats has considerable advantages for many business scenarios, but the accompanying technical challenges are also quite difficult. When the number of participants in group chat services increases significantly, there will inevitably be peak periods and trough periods for message sending in group chats. If traditional group chat technology is used, it is easy to cause excessive occupation of network input and output port resources during peak periods of message sending, and during the trough period of message sending, it is easy to cause delayed message sending. Summary of the invention
[0003] The instant communication group message sending method and server system provided by the present invention can control message sending, reduce resource occupation of network input and output ports during message sending peak period and reduce message sending delay during message sending trough period.
[0004] In a first aspect, the present invention provides a method for sending an instant messaging group message, which is executed in a connection service component of an instant messaging service end, and the method comprises:
[0005] Receive messages sent by the message service component in real time;
[0006] Obtain the number of messages received from the message service component after the last message was sent to the target user, and obtain the time interval from the last message was sent to the target user to the current time;
[0007] When the number of messages meets the preset number of messages or when the time interval meets the preset time interval, the message received from the message service component after the last message was sent to the user is sent to the target user.
[0008] Optionally, the method further comprises:
[0009] In response to a persistent connection request initiated by a target client, the persistent connection information is stored in a database.
[0010] Optionally, the method further comprises:
[0011] In response to a message sent by the target client through the long connection, the message is sent to a message queue component, so that the message queue component sends the message to the message service component in sequence.
[0012] Optionally, the method further comprises:
[0013] The preset number of messages and / or the preset time interval are determined according to the number of the target customers.
[0014] Optionally, the method further comprises:
[0015] The preset number of messages and / or the preset time interval are determined according to the historical frequency of the target customer sending messages.
[0016] Optionally, sending the message received from the message service component after the message was previously sent to the user to the target user comprises:
[0017] Merging the messages received from the message service component after the last message was sent to the target user to form a message to be sent;
[0018] The message to be sent is sent to the target user who has a long connection relationship with the current connection service component.
[0019] In a second aspect, the present invention further provides a method for sending an instant messaging group message, which is executed in a message service component of an instant messaging service end, and the method comprises:
[0020] Get the message that needs to be forwarded from the message queue component;
[0021] Obtain the connection service component corresponding to the target user of the message that needs to be forwarded to establish a long connection;
[0022] The message obtained from the message queue component is sent to the corresponding connection service component, so that the connection service component executes any of the instant communication group message sending methods described above to send the message to the target user.
[0023] Optionally, the step of obtaining a connection service component corresponding to establishing a long connection for a target user corresponding to the message currently to be forwarded includes:
[0024] Obtaining the online status of the target user;
[0025] According to the persistent connection information stored in the database, a connection service component corresponding to when the target user in an online state establishes a persistent connection is obtained.
[0026] Optionally, after sending the message obtained from the message queue component to the corresponding connection service component, the method further includes:
[0027] Return to the step of obtaining the message currently to be forwarded from the message queue component.
[0028] In a third aspect, the present invention further provides an instant messaging group message service end system, comprising:
[0029] A connection service component, wherein the message service component is used to execute any one of the instant communication group message sending methods executed on the connection service component;
[0030] A message queue component, the message queue component is in communication with the connection service component, the message queue component is used to receive messages sent by the connection service component and output them in a first-in-first-out manner;
[0031] A message service component, wherein the message service component is communicatively connected with the message queue component, and the message service component is used to execute any of the instant messaging group message sending methods executed on the message service component as described above.
[0032] In the technical solution provided by the present invention, the connection service component obtains the number of messages received after the previous message was sent and the time interval to the current time. When one of the two conditions, that is, the number of messages reaches the preset number of messages and the time interval reaches the preset time interval, is met, the message received after the previous message was sent is sent to the target user. The data received after the previous message was sent is sent at one time, which reduces the resource occupation of the input and output ports of the network, and the setting of the preset time interval ensures that the maximum delay of a single message will not exceed the preset time interval, effectively reducing the delay in message sending. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 This is a flow chart of a method for sending an instant messaging group message according to an embodiment of the present invention;
[0034] Figure 2 This is a flowchart of a method for sending an instant messaging group message according to another embodiment of the present invention;
[0035] Figure 3 The figure is a schematic diagram of the interaction between the components in the instant messaging group message service end system in another embodiment of the present invention. DETAILED DESCRIPTION
[0036] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0037] The embodiment of the present invention provides a method for sending an instant messaging group message, which is executed in a connection service component of an instant messaging service end, such as Figure 1 As shown, the method includes:
[0038] Receive messages sent by the message service component in real time;
[0039] In some embodiments, the connection service component receives messages sent by the service component in real time. After receiving a message each time, the received message is merged with the historical message received after the previous message was sent to the target user, so that the merged message can be sent out at one time, reducing the occupation of the network's input and output port resources. The connection service component is used to establish and maintain a long connection between the client and the server, and save the relevant long connection to the database. The reception and delivery of messages are completed by the connection service component. Specifically, the client sends a message to the connection service component, the connection service component sends the message to the message queue component, the message service component consumes the message in the message queue component and sends the message to the connection service component, and the connection service component sends it to the client through the long connection.
[0040] Obtain the number of messages received from the message service component after the last message was sent to the target user, and obtain the time interval from the last message was sent to the target user to the current time;
[0041] In some embodiments, the limit on the number of messages is to merge as many messages as possible, so that during the peak period of message sending, the input and output port resources of the network can be occupied as little as possible, and the time interval is limited to reduce the message sending delay as much as possible, so that the messages can be sent out as quickly as possible during the trough period of message sending.
[0042] When the number of messages meets the preset number of messages or when the time interval meets the preset time interval, the message received from the message service component after the last message was sent to the user is sent to the target user.
[0043] In some embodiments, the number of messages and the time interval are two independent conditions. If the message number requirement is met, the currently merged messages to be sent will be sent. If the time interval requirement is met, the currently merged messages to be sent will also be sent.
[0044] In the technical solution provided by the embodiment of the present invention, the connection service component obtains the number of messages received after the previous message was sent and the time interval to the current time. When one of the two conditions, that is, the number of messages reaches the preset number of messages and the time interval reaches the preset time interval, is met, the message received after the previous message was sent is sent to the target user. The received data after the previous message was sent is sent at one time, which reduces the resource occupation of the input and output ports of the network, and the setting of the preset time interval ensures that the maximum delay of a single message will not exceed the preset time interval, effectively reducing the delay in message sending.
[0045] As an optional implementation, the method further includes:
[0046] In response to a persistent connection request initiated by a target client, the persistent connection information is stored in a database.
[0047] As an optional implementation, the method further includes:
[0048] In response to a message sent by the target client through the long connection, the message is sent to a message queue component, so that the message queue component sends the message to the message service component in sequence.
[0049] As an optional implementation, the method further includes:
[0050] The preset number of messages and / or the preset time interval are determined according to the number of the target customers.
[0051] In some embodiments, the target client refers to a client that may send a message. It should be understood that the more clients that may send messages, the more likely it is to usher in a peak period of message sending. Therefore, the higher the preset number of messages needs to be set to reduce the occupation of the input and output port resources of the network. The fewer the number of clients that may send messages, the more likely it is to usher in a trough period of message sending. Therefore, the fewer the preset number of messages needs to be set to reduce the delay in message sending. Similarly, the more clients that may send messages, the more likely it is to usher in a peak period of message sending. Therefore, the longer the time interval needs to be set to reduce the occupation of the input and output port resources of the network. The fewer the number of clients that may send messages, the more likely it is to usher in a trough period of message sending. Therefore, the shorter the time interval needs to be set to reduce the delay in message sending. The setting of the preset number of messages and the setting of the preset time interval are not necessarily related. The preset number of messages can be set separately according to the number of target clients, and the preset time interval can also be set separately according to the number of target clients.
[0052] As an optional implementation, the method further includes:
[0053] The preset number of messages and / or the preset time interval are determined according to the historical frequency of the target customer sending messages.
[0054] In some embodiments, the historical frequency of a target client sending a message refers to the ratio of the sum of messages sent by the target client corresponding to the currently connected service component before the current time to the time corresponding to sending all messages. It should be understood that the higher the historical frequency, the greater the possibility that the current frequency of sending messages is higher. Therefore, it is necessary to set the preset number of messages higher and / or the preset time interval longer. Similarly, the lower the historical frequency, the lower the preset number of messages and / or the preset time interval. There is no necessary correlation between the setting of the preset number of messages and the setting of the preset time interval. The preset number of messages can be set based on the historical frequency alone, or the preset time interval can be set based on the historical frequency alone.
[0055] As an optional implementation manner, sending the message received from the message service component after the previous message was sent to the user to the target user includes:
[0056] Merge the messages received from the message service component after the previous message was sent to the target user to form a message to be sent;
[0057] The message to be sent is sent to a target user who has a long connection relationship with the current connection service component.
[0058] In some embodiments, the received messages are merged and sent to the target user, which only requires occupying the input and output ports of the network once, thereby increasing the efficiency of message sending and improving the performance of message receiving.
[0059] The embodiment of the present invention also provides an instant messaging group message sending method, which is executed in a message service component of an instant messaging service end, such as Figure 2 As shown, the method includes:
[0060] Get the message that needs to be forwarded from the message queue component;
[0061] In some embodiments, the message queue component is a component that provides a "first-in, first-out" data structure service in the basic data structure, which can be used to decouple asynchronous messages, decouple message sending and message processing. The message queue component requires a message provider and a message consumer, and both the message provider and the consumer will establish a connection with the message queue component. The message provider is used to send messages to the message queue component. For example, the connection service component can be used as a message provider; the message consumer is used to asynchronously receive messages sent from the message queue component. For example, the message service component can be used as a message consumer.
[0062] Obtain the connection service component corresponding to the long connection established by the target user corresponding to the message currently to be forwarded;
[0063] In some embodiments, the message service component consumes messages in the message queue component, obtains the corresponding relationship between the target user and the message service component, and sends the message obtained from the message queue component to the connection service component according to the obtained corresponding relationship. Since there are multiple connection service components on the instant messaging service end, different users will establish long connections through different connection service components. Therefore, it is necessary to send messages according to the corresponding relationship in order to send them to the correct target user.
[0064] The message obtained from the message queue is sent to the corresponding connection service component, so that the connection service component executes any of the instant communication group message sending methods described above to send the message to the target user.
[0065] In some embodiments, after the message service component sends the message to the corresponding connection service component, the connection service component will send the data to the corresponding target user according to the corresponding execution process. The target user refers to the user who needs to receive the message.
[0066] As an optional implementation manner, the acquiring the connection service component corresponding to the target user establishing a long connection corresponding to the message currently to be forwarded includes:
[0067] Obtaining the online status of the target user;
[0068] According to the persistent connection information stored in the database, a connection service component corresponding to when the target user in an online state establishes a persistent connection is obtained.
[0069] In some embodiments, the target user needs to establish a persistent connection with the connection service component when going online, so the online status of the target user needs to be obtained first. At the same time, since different users will establish connections with different connection service components, the corresponding relationship between the target user and the connection service component needs to be obtained.
[0070] As an optional implementation manner, after sending the message obtained from the message queue component to the corresponding connection service component, the method further includes:
[0071] Return to the step of obtaining the message that currently needs to be forwarded from the message queue component.
[0072] The embodiment of the present invention also provides an instant messaging group message service end system, such as Figure 3 As shown, including:
[0073] A connection service component, wherein the message service component is used to execute any one of the instant communication group message sending methods executed on the connection service component;
[0074] A message queue component, the message queue component is in communication with the connection service component, the message queue component is used to receive messages sent by the connection service component and output them in a first-in-first-out manner;
[0075] A message service component, wherein the message service component is communicatively connected with the message queue component, and the message service component is used to execute any of the instant messaging group message sending methods executed on the message service component as described above.
[0076] In the attached Figure 3 The interactive process between the components of the instant messaging group message server system is shown in the following example:
[0077] The target customer's client initiates a long connection request to the connection service component, and the connection service component saves the long connection information to the database;
[0078] The target client sends the message to the connection service component on the server side through the persistent connection in the previous step;
[0079] The connection service component acts as a message provider. After receiving the message, it sends the message to the message queue component MQ for decoupling and peak shaving.
[0080] The message service component acts as a message consumer and asynchronously receives messages sent from the message queue component MQ;
[0081] The message service component uses the online status data of group members, which includes the online status and the corresponding relationship with the connection service component. The online status data is used to lock the target users to whom the message should be distributed;
[0082] The message service component sends messages to the corresponding connection service component one by one according to the online status data;
[0083] After the connection service component receives the message, it merges the messages once according to the preset number of messages, such as 1,000, and the preset time interval, such as 2 seconds. Specifically, 1,000 messages are merged into one network IO transmission and sent to the target customer's client. If the merged messages reach 1,000, they are immediately sent to the target customer's client. If the messages are less than 1,000 but the waiting time has reached 2 seconds, the messages received within 2 seconds are merged into one network IO transmission and sent to the target customer's client.
[0084] Those skilled in the art can understand that all or part of the processes in the above method embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes in the above method embodiments. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0085] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for sending an instant communication group message, characterized in that: Executed in a connection service component of an instant messaging server, the method includes: Receive messages sent by the message service component in real time; Obtain the number of messages received from the message service component after the last message was sent to the target user, and obtain the time interval from the last message was sent to the target user to the current time; When the number of messages meets the preset number of messages or when the time interval meets the preset time interval, the message received from the message service component after the last message was sent to the user is sent to the target user.
2. The method according to claim 1, characterized in that The method further comprises: In response to a persistent connection request initiated by a target client, the persistent connection information is stored in a database.
3. The method according to claim 2, characterized in that The method further comprises: In response to a message sent by the target client through the long connection, the message is sent to a message queue component, so that the message queue component sends the message to the message service component in sequence.
4. The method according to claim 3, characterized in that The method further comprises: The preset number of messages and / or the preset time interval are determined according to the number of the target customers.
5. The method according to claim 3, characterized in that: The method further comprises: The preset number of messages and / or the preset time interval are determined according to the historical frequency of the target customer sending messages.
6. The method according to claim 1, characterized in that The sending of the message received from the message service component after the previous message was sent to the user to the target user comprises: Merging the messages received from the message service component after the last message was sent to the target user to form a message to be sent; The message to be sent is sent to the target user who has a long connection relationship with the current connection service component.
7. A method for sending an instant communication group message, characterized in that: Executed in a message service component of an instant messaging server, the method comprises: Get the message that needs to be forwarded from the message queue component; Obtain the connection service component corresponding to the target user of the message that needs to be forwarded to establish a long connection; The message obtained from the message queue component is sent to the corresponding connection service component, so that the connection service component executes the instant communication group message sending method according to any one of claims 1 to 6 to send the message to the target user.
8. The method according to claim 7, characterized in that The connection service component corresponding to establishing a long connection with the target user corresponding to the message currently to be forwarded includes: Obtaining the online status of the target user; According to the persistent connection information stored in the database, a connection service component corresponding to when the target user in an online state establishes a persistent connection is obtained.
9. The method according to claim 7, characterized in that: After sending the message obtained from the message queue component to the corresponding connection service component, the method further includes: Return to the step of obtaining the message currently to be forwarded from the message queue component.
10. An instant messaging group message service end system, characterized in that: include: A connection service component, wherein the message service component is used to execute the instant messaging group message sending method according to any one of claims 1 to 6; A message queue component, the message queue component is in communication with the connection service component, the message queue component is used to receive messages sent by the connection service component and output them in a first-in-first-out manner; A message service component, wherein the message service component is communicatively connected to the message queue component, and the message service component is used to execute the instant messaging group message sending method as described in any one of claims 7-9.