Message processing method and device, distributed instant messaging system, storage medium and program product

By determining the number of messages based on the estimated time spent on the message server's task in a distributed instant messaging system, and prioritizing the allocation of messages to message servers with long connections, the problem of some messages not being promptly pushed when a large number of messages is pushed is solved, and the message is improved Timeliness of push.

CN119484456AActive Publication Date: 2025-02-18E-SURFING DIGITAL LIFE TECH CO LTD
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
CN202411658407.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-19
Publication Date
2025-02-18
Estimated Expiration
2044-11-19

AI Technical Summary

Technical Problem

In distributed instant messaging systems, when a large number of messages are pushed, the even division of the number of message servers may make it difficult to push some messages in a timely manner.

Method used

By estimating the time spent on the current task reported by the receiving message set and each message server, determine the number of messages to be processed by each message server, and assign messages according to priority, ensuring that there is a long connection with the target message client that receives the message. The message server is preferred. Process a type of message.

Benefits of technology

It effectively avoids the problem of not pushing messages in time due to equal division, improves the timeliness of message push, and reduces the situation where the message server needs to establish a long connection when pushing messages.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119484456A_ABST
    Figure CN119484456A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of instant messaging, provides a message processing method and device, a distributed instant messaging system, a storage medium and a program product, and can push a large number of messages to a message client in time as much as possible. According to the invention, the number of messages needing to be processed by each message server is determined according to the relative size of the current task pre-estimated spent time of each message server and the total number of messages included in the message set, and the target message client is obtained according to the message client currently having long connection with each message server. The method comprises the following steps: determining messages sent to a target message client in a message set, obtaining a first-class message set and a second-class message set, preferentially distributing the first-class message to a message server having long connection with the target message client receiving the first-class message, and combining the number of messages needing to be processed by each message server to obtain a first-class message set and a second-class message set; and distributing a first-class message set and a second-class message set to obtain a target message set of each message server, and pushing the target message set to a message client.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of instant messaging technology, and in particular to a message processing method, device, distributed instant messaging system, storage medium and computer program product. Background Art

[0002] With the rapid development of mobile Internet, distributed instant messaging systems have become an indispensable part of people's daily lives.

[0003] With the help of the message server of the distributed instant messaging system, a message sent by a message client can be pushed to another message client. The distributed instant messaging system sometimes faces the situation of needing to push a large number of messages. At this time, in order to push a large number of messages in a timely manner, the large number of messages can be split into multiple parts and sent to multiple message servers for pushing.

[0004] However, when a large number of messages are split into multiple parts, they are generally evenly divided according to the number of message servers. In some scenarios, some messages are difficult to push out in time. Summary of the invention

[0005] Based on this, it is necessary to provide a message processing method, device, distributed instant messaging system, storage medium and computer program product to address the above technical problems.

[0006] The present application provides a message processing method, the method comprising:

[0007] Receive the message set and the estimated time of the current task reported by each message server;

[0008] Determine the number of messages that each message server needs to process based on the relative size of the estimated time taken for the current task reported by each message server and the total number of messages included in the message set;

[0009] According to the message clients that currently have a long connection with each of the message servers, a number of target message clients are obtained;

[0010] Determine the messages in the message set that are sent to the target message client to obtain a first-category message set, and obtain a second-category message set based on the messages in the message set except for the first-category message set;

[0011] The first category message set and the second category message set are allocated in a manner that preferentially allocates the first category messages to the message server that has a long connection with the target message client that receives the first category messages, and in combination with the number of messages that each message server needs to process, to obtain the target message set of each message server; the target message set is sent by the message server to the message client via a long connection.

[0012] In one embodiment, the number of messages to be processed by each message server is determined according to the relative size of the estimated time taken for the current task reported by each message server and the total number of messages included in the message set, including:

[0013] According to the relative size of the estimated time taken for the current task reported by each message server, the ratio of the number of messages between the message servers is obtained;

[0014] The number of messages that each message server needs to process is determined according to the message number ratio relationship and the total number of messages included in the message set.

[0015] In one embodiment, the first-class message set and the second-class message set are allocated in a manner of preferentially allocating the first-class message to the message server that has a persistent connection with the target message client that receives the first-class message, combined with the number of messages to be processed by each message server, to obtain the target message set of each message server, including:

[0016] Aggregating the messages of the type directed to the same target message client in the message set to obtain a subset of the messages of the type for each target message client;

[0017] Allocating a message subset of each target message client to a message server that has established a persistent connection with the target message client, to obtain a preliminary message set for each message server;

[0018] Based on the preliminary message sets of each message server, the second type of message sets are allocated to obtain the target message sets of each message server; the allocation of the second type of message sets makes the target message sets of each message server match the number of messages to be processed.

[0019] In one embodiment, based on the preliminary message sets of each of the message servers, before allocating the second type of message sets, the method further comprises:

[0020] Determining whether the number of messages in the preliminary message set of each of the message servers does not exceed the number of messages to be processed by each of the message servers;

[0021] If the number of messages in the preliminary message set of one of the message servers exceeds the number of messages to be processed, then obtaining a message quantity excess value according to the number of messages in the preliminary message set of the message server and the number of messages to be processed;

[0022] If the message quantity excess value exceeds the excess threshold, a message subset of at least one target client is removed from the preliminary message set of the message server, so that the number of messages in the preliminary message set of the message server after removal does not exceed the excess threshold;

[0023] The first-category message subset of the removed target client is added to the second-category message set.

[0024] In one embodiment, based on the preliminary message set of each message server, the second type of message set is allocated, including:

[0025] If the number of messages in the preliminary message sets of each of the message servers does not exceed the number of messages to be processed, the second type of message sets are allocated based on the preliminary message sets of each of the message servers;

[0026] or,

[0027] If the message quantity excess value does not exceed the excess threshold, the second type of message set is allocated based on the preliminary message set of each message server.

[0028] In one embodiment, according to the message clients that currently have a long connection with each of the message servers, several target message clients are obtained, including:

[0029] Obtain the long connection information reported by each message server;

[0030] According to the persistent connection information, the message clients that currently have persistent connections with each of the message servers are determined, and a number of target message clients are obtained.

[0031] The present application provides a message processing device, the device comprising:

[0032] An information receiving module is used to receive message sets and the estimated time required for the current task reported by each message server;

[0033] A quantity determination module, used to determine the number of messages to be processed by each message server according to the relative size of the estimated time taken for the current task reported by each message server and the total number of messages included in the message set;

[0034] A target message client determination module, used to obtain a number of target message clients according to message clients that currently have a long connection with each of the message servers;

[0035] A message classification module, used for determining the messages in the message set sent to the target message client to obtain a first-class message set, and obtaining a second-class message set based on the messages in the message set except the first-class message set;

[0036] A message allocation module is used to allocate the first category of messages to the message server that has a long connection with the target message client that receives the first category of messages, in combination with the number of messages that each message server needs to process, to obtain the target message set of each message server; the target message set is sent by the message server to the message client through a long connection.

[0037] The present application provides a distributed instant messaging system, the system comprising a gateway and a message server;

[0038] The gateway is used to execute the above method;

[0039] The message server is used to receive the corresponding target message set and send the target message set to the message client through a long connection.

[0040] The present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to execute the above method.

[0041] The present application provides a computer program product, on which a computer program is stored, and the computer program is executed by a processor to perform the above method.

[0042] In the above-mentioned message processing method, device, distributed instant messaging system, storage medium and computer program product, a message set and the estimated time spent on the current task reported by each message server are received; the number of messages to be processed by each message server is determined based on the relative size of the estimated time spent on the current task reported by each message server and the total number of messages included in the message set; a number of target message clients are obtained based on the message clients that currently have a long connection with each message server; the messages sent to the target message clients in the message set are determined to obtain a first-class message set, and a second-class message set is obtained based on the messages in the message set except the first-class message set; the first-class message set and the second-class message set are allocated in a manner of preferentially allocating the first-class messages to the message servers that have a long connection with the target message clients that receive the first-class messages, combined with the number of messages to be processed by each message server, to obtain the target message set of each message server; each message server is also used to receive the corresponding target message set, and send the target message set to the message client through the long connection. In the solution provided by the present application, when dividing the message set, the time spent on the current task to be processed by each message server is taken into consideration. According to the relative size of the estimated time spent on the current task of each message server, the number of messages to be processed by each message server is obtained. By reasonably dividing the message set, it is possible to avoid the situation where some messages are not pushed in time due to equal distribution according to the number of message servers. In addition, the solution provided by the present application also takes into account the message clients that currently have a long connection with each message server, and preferentially allocates the messages sent to the message client to the corresponding message server, thereby minimizing the situation where the message server needs to establish a long connection with the message client when pushing messages, thereby further improving the timeliness of message push. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the drawings required for use in the embodiments or the related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0044] Figure 1 A schematic diagram of a flow chart of a message processing method in an embodiment;

[0045] Figure 2 A schematic diagram of a process for determining the number of messages in one embodiment;

[0046] Figure 3 is a structural block diagram of a message processing device in one embodiment;

[0047] Figure 4 A schematic diagram of devices included in a distributed instant messaging system in one embodiment;

[0048] Figure 5 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0049] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0050] The present application provides a message processing method, the steps of which can be executed by a gateway, including: Figure 1 Steps shown.

[0051] Step S101, receiving a message set and the estimated time required for the current task reported by each message server.

[0052] A message client can send a message to another message client. After each message client sends a message, it can be aggregated to the gateway, and the gateway can get the message set to be pushed. Each message server can get the estimated time of its current task based on its current pending tasks and report it to the gateway.

[0053] Step S102, determining the number of messages that each message server needs to process according to the relative size of the estimated time taken for the current task reported by each message server and the total number of messages included in the message set.

[0054] The longer the estimated time taken by the current task of the message server is, the more time it takes to process the current pending task of the message server. In order to push the messages out in time, the message server may need to push fewer messages.

[0055] The gateway can determine the number of messages that each message server needs to process based on the relative size of the estimated time required for the current task of each message server and the total number of messages included in the message set; wherein, the greater the estimated time required for the current task, the fewer the number of messages that need to be processed.

[0056] Step S103, obtaining a number of target message clients according to the message clients that currently have a long connection with each message server.

[0057] Each message server may currently have a persistent connection with some message clients, and the gateway may determine the message client that has a persistent connection with the message server as the target message client.

[0058] In one embodiment, obtaining a number of target message clients based on message clients that currently have a long connection with each message server in step S103 may include: obtaining long connection information reported by each message server; and determining, based on the long connection information, message clients that currently have a long connection with each message server to obtain a number of target message clients.

[0059] Specifically, each message server forms persistent connection information according to the message clients that establish persistent connection with itself, and reports it to the gateway. After receiving the persistent connection information of the message server, the gateway can determine the message clients that currently have persistent connection with the message server, and determine these message clients as target message clients.

[0060] Step S104, determining the messages in the message set that are sent to the target message client to obtain a first-category message set, and obtaining a second-category message set based on the messages in the message set except for the first-category message set.

[0061] Any message in a message set is associated with the information of the message client that sent the message and the message client that received the message. Therefore, the gateway can determine the message to be sent to the target message client based on the information associated with the message, and treat these messages as a class of messages to form a class of message set.

[0062] The gateway may determine the messages in the message set other than the first-class messages as second-class messages, thereby forming a second-class message set.

[0063] Step S105, in a manner of preferentially allocating Class I messages to message servers that have a persistent connection with target message clients that receive Class I messages, and in combination with the number of messages that each message server needs to process, the Class I message set and the Class II message set are allocated to obtain target message sets for each message server.

[0064] The target message set is sent by the message server to the message client through a persistent connection.

[0065] After the gateway divides the message sets into Class I and Class II, since the target message client receiving Class I messages currently has a long connection with the corresponding message server, Class I messages can be sent to the message server first. The message server can directly send Class I messages based on the established long connection without spending time establishing a long connection, thereby pushing the messages to the target message client in a timely manner.

[0066] When the gateway allocates the first-class message sets and the second-class message sets to form the target message sets of each message server, the allocation principle gives priority to allocating the first-class messages to the message servers that have a long connection with the target message clients that receive the first-class messages. Combined with the number of messages that each message server needs to process, the situation where the message server spends time establishing long connections is reduced as much as possible, thereby improving the timeliness of message push.

[0067] In the above-mentioned message processing method, when dividing the message set, the time spent on the current task to be processed by each message server is taken into consideration. According to the relative size of the estimated time spent on the current task of each message server, the number of messages to be processed by each message server is obtained. By dividing the message set reasonably, it is possible to avoid the situation where some messages are not pushed in time due to equal distribution according to the number of message servers. In addition, the solution provided in the present application also takes into account the message clients that currently have a long connection with each message server, and preferentially allocates the messages sent to the message client to the corresponding message server, thereby minimizing the situation where the message server needs to establish a long connection with the message client when pushing messages, thereby further improving the timeliness of message push.

[0068] In one embodiment, the number of messages to be processed by each message server is determined in step S102 according to the relative size of the estimated time taken for the current task reported by each message server and the total number of messages included in the message set, including: Figure 2 The steps shown are: Step S201, obtaining the message number ratio relationship between the message servers based on the relative size of the current task estimated time reported by each message server; Step S202, determining the number of messages that each message server needs to process based on the message number ratio relationship and the total number of messages included in the message set.

[0069] For example, the estimated time taken for the current tasks of three message servers can be obtained to obtain a time consumption ratio relationship, such as 3:2.5:2. Based on the time consumption ratio relationship, the message number ratio relationship between the message servers can be obtained. The larger the time consumption ratio, the smaller the message number ratio. If the time consumption ratio relationship is 3:2.5:2, the message number ratio can be 2:2.5:3.

[0070] After obtaining the ratio relationship of the number of messages between the message servers, the number of messages that each message server needs to process can be determined based on the total number of messages included in the message set. The larger the ratio of the number of messages, the more messages need to be processed.

[0071] In one embodiment, step S105 allocates the first-class message set and the second-class message set in a manner of preferentially allocating the first-class message to the message server that has a long connection with the target message client that receives the first-class message, combined with the number of messages that each message server needs to process, to obtain the target message set of each message server, including: aggregating the first-class messages in the first-class message set that point to the same target message client to obtain a first-class message subset for each target message client; allocating the first-class message subset for each target message client to the message server that has a long connection with the target message client to obtain a preliminary message set for each message server; allocating the second-class message set on the basis of the preliminary message set of each message server to obtain the target message set of each message server; allocating the second-class message set so that the target message set of each message server matches the number of messages that need to be processed.

[0072] After the gateway divides the first-class message set, the first-class messages sent to the same target message client can be aggregated together to form a first-class message subset of the target message client. By aggregating in this way, the first-class message subsets of several target message clients can be obtained.

[0073] Since the target message client currently has a persistent connection with the corresponding message server, a message subset of the target message client can be allocated to the message server with which the target message client currently has a persistent connection, thereby obtaining a preliminary message set of the message server.

[0074] After obtaining the preliminary message set of each message server, the number of messages included in the preliminary message set of the message server may not match the number of messages that the message server needs to process. Therefore, based on the preliminary message set of each message server, the second type of message set is allocated to obtain the target message set of each message server, so that the number of messages included in the target message set of the message server may match the number of messages that the message server needs to process.

[0075] In this embodiment, considering the message client that currently has a long connection with each message server, the messages sent to the message client are preferentially allocated to the corresponding message server, so as to minimize the situation where the message server needs to establish a long connection with the message client when pushing messages, and further improve the timeliness of message push; the second type of message set is then allocated so that the number of messages included in the target message set of the message server may match the number of messages that the message server needs to process, so that the message server whose current task is estimated to take more time will push fewer messages, and the message server whose current task is estimated to take less time will push more messages.

[0076] In one embodiment, based on the preliminary message sets of each message server, before allocating the second-class message sets, the method provided by the present application also includes: determining whether the number of messages in the preliminary message sets of each message server does not exceed the number of messages to be processed; if the number of messages in the preliminary message sets of one of the message servers exceeds the number of messages to be processed, obtaining an excess value of the number of messages based on the number of messages in the preliminary message set of the message server and the number of messages to be processed; if the excess value of the number of messages exceeds the excess threshold, eliminating a first-class message subset of at least one target client in the preliminary message set of the message server, so that the number of messages in the preliminary message set of the message server after elimination does not exceed the excess threshold; and adding the eliminated first-class message subset of the target client to the second-class message set.

[0077] After the preliminary message sets of each message server are obtained, the number of messages included in the preliminary message sets of the message servers may not match the number of messages that the message servers need to process.

[0078] Therefore, the gateway can determine whether the number of messages in the preliminary message set of each message server does not exceed the number of messages that need to be processed by each server.

[0079] If the number of messages in the preliminary message sets of each message server does not exceed the number of messages to be processed by each message server, the second type of message sets can be directly allocated based on the preliminary message sets of each message server.

[0080] If the number of messages in the preliminary message set of a message server exceeds the number of messages to be processed, the message quantity excess value may be obtained according to the number of messages in the preliminary message set of the message server and the number of messages to be processed.

[0081] The gateway can determine whether the message quantity excess value exceeds the excess threshold.

[0082] If the message quantity excess value does not exceed the threshold, it means that although the number of messages in the preliminary message set exceeds the number of messages to be processed, the excess will not be too much, and the number of messages in the preliminary message set does not need to be reduced; therefore, the second-class message set can be directly allocated based on the preliminary message set of each message server.

[0083] If the message quantity excess value exceeds the excess threshold, it means that the number of messages in the preliminary message set of the message server needs to be reduced to prevent the message server from being overloaded and causing some messages to fail to be pushed in time.

[0084] Since the preliminary message set of the message server is formed according to the first-class message subsets of several target message clients, the first-class message subset of at least one target message client can be eliminated from the preliminary message set so that the number of messages in the preliminary message set after elimination does not exceed the excess threshold. The gateway can treat the first-class messages in the first-class message subset of the eliminated target message client as second-class messages, and add the first-class message subset to the second-class message set, so as to be randomly distributed to any message server along with the second-class message set.

[0085] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0086] Based on the same inventive concept, the embodiment of the present application also provides a message processing device for implementing the message processing method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in the one or more message processing device embodiments provided below can refer to the limitations on the message processing method above, and will not be repeated here.

[0087] In one embodiment, Figure 3 As shown, a message processing device is provided, including:

[0088] An information receiving module 301 is used to receive a message set and the estimated time taken for the current task reported by each message server;

[0089] A quantity determination module 302 is used to determine the number of messages that each message server needs to process according to the relative size of the estimated time taken for the current task reported by each message server and the total number of messages included in the message set;

[0090] A target message client determination module 303 is used to obtain a number of target message clients according to message clients that currently have a long connection with each of the message servers;

[0091] The message classification module 304 is used to determine the messages in the message set that are sent to the target message client to obtain a first-class message set, and obtain a second-class message set based on the messages in the message set except the first-class message set;

[0092] The message allocation module 305 is used to allocate the first category of messages to the message server that has a long connection with the target message client that receives the first category of messages, and to obtain the target message set of each message server by allocating the first category of messages to the message server in combination with the number of messages that each message server needs to process; the target message set is sent by the message server to the message client through a long connection.

[0093] In one embodiment, the quantity determination module 302 is also used to: obtain the message number ratio relationship between the message servers based on the relative size of the current task estimated time reported by each message server; determine the number of messages that each message server needs to process based on the message number ratio relationship and the total number of messages included in the message set.

[0094] In one embodiment, the message allocation module 305 is also used to: summarize the first-class messages in the first-class message set that point to the same target message client to obtain a first-class message subset for each of the target message clients; allocate the first-class message subset for each of the target message clients to a message server that has established a long connection with the target message client to obtain a preliminary message set for each message server; allocate the second-class message set based on the preliminary message set for each of the message servers to obtain a target message set for each message server; allocate the second-class message set so that the target message set of each of the message servers matches the number of messages to be processed.

[0095] In one embodiment, based on the preliminary message sets of each of the message servers, before allocating the second-class message sets, the message allocation module 305 is also used to: determine whether the number of messages in the preliminary message sets of each of the message servers does not exceed the number of messages to be processed; if the number of messages in the preliminary message sets of one of the message servers exceeds the number of messages to be processed, obtain an excess value of the number of messages according to the number of messages in the preliminary message set of the message server and the number of messages to be processed; if the excess value of the number of messages exceeds the excess threshold, eliminate a first-class message subset of at least one target client in the preliminary message set of the message server, so that the number of messages in the preliminary message set of the message server after elimination does not exceed the excess threshold; and add the eliminated first-class message subset of the target client to the second-class message set.

[0096] In one embodiment, the message allocation module 305 is also used to: allocate the second category message set based on the preliminary message set of each message server if the number of messages in the preliminary message set of each message server does not exceed the number of messages that need to be processed; or allocate the second category message set based on the preliminary message set of each message server if the excess value of the number of messages does not exceed the excess threshold.

[0097] In one embodiment, the target message client determination module 303 is further used to: obtain the persistent connection information reported by each message server; determine the message clients that currently have persistent connections with each message server according to the persistent connection information, and obtain several target message clients.

[0098] Each module in the above message processing device can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute operations corresponding to each module above.

[0099] The present application provides a distributed instant messaging system, the system comprising a gateway and a message server, such as Figure 4 shown.

[0100] The gateway is used to execute the above method embodiment; the message server is used to receive the corresponding target message set and send the target message set to the message client through a long connection.

[0101] The distributed instant messaging system achieves high efficiency, scalability and maintainability through systematic domain modeling, loosely coupled architecture design, event tracing and the application of CQRS (Command Query Responsibility Segregation) mode, as well as the implementation of a series of high-performance optimization strategies. Specifically, it includes the following three aspects:

[0102] First, through domain-driven design, we can deeply understand and accurately reflect the needs of the business domain to ensure the consistency between the design of the distributed instant messaging system and business needs.

[0103] Second, use microservice architecture and event-driven communication mode to achieve loose coupling between system components and improve the scalability and flexibility of distributed instant messaging systems.

[0104] Third, introduce event tracing and CQRS mode to optimize data storage and access mechanisms, and improve the performance and responsiveness of distributed instant messaging systems.

[0105] Each of these aspects is described in detail below.

[0106] 1. Microservice architecture design and implementation

[0107] 1.1 Microservice Division:

[0108] User service: responsible for user account registration, login, information management and other operations. Message service: handles message sending, receiving, storage and retrieval operations. Group service: manages group creation, member management, group message processing, etc. Other services (such as file services, notification services, etc.): further subdivided according to business needs to ensure that each service has a single and independent responsibility.

[0109] 1.2 Communication protocol selection:

[0110] Each microservice can use a certain communication protocol as the main communication protocol to ensure cross-platform and cross-language interoperability. For internal service-to-service communication with high performance requirements, an efficient communication protocol can be used.

[0111] 1.3 Event-driven communication mode:

[0112] Introduce event bus, which is used for event publishing and subscription between microservices. When key events such as user login and message sending occur, the relevant microservices publish events to the event bus. Microservices that subscribe to these events listen to the event bus and execute corresponding business logic when events occur.

[0113] 1.4 Intelligent message routing application:

[0114] In the microservice architecture, intelligent message routing, as part of the message middleware or service gateway, is responsible for routing messages from clients or external systems to the corresponding microservice instances. Intelligent message routing can achieve the following functions:

[0115] Service discovery and registration: Intelligent message routing can automatically discover and register microservice instances to ensure that messages can be accurately routed to the target service.

[0116] Load balancing and fault tolerance: Based on the load and health status of the microservice instances, intelligent message routing can dynamically adjust the message routing strategy to achieve load balancing and fault tolerance.

[0117] Message filtering and conversion: During the message routing process, messages can be filtered and converted to meet the processing requirements of different microservice instances.

[0118] Security and authentication: Intelligent message routing can integrate security authentication mechanisms to ensure the security and integrity of messages during transmission.

[0119] 2. Domain Modeling and Aggregation Design

[0120] 2.1 Domain Modeling:

[0121] Through close cooperation with the business team, we can deeply understand the business needs and processes of the social platform. We can identify key entities such as users, messages, groups, and value objects such as user status and message content. We can define the relationship between entities, such as the send / receive relationship between users and messages, and the membership relationship between users and groups.

[0122] 2.2 Aggregation Design:

[0123] Design clear aggregate boundaries for each microservice. For example, in a user service, users and their associated information (such as user status and user preferences) constitute a user aggregate. Specify the aggregate root as the only entry point for external access to the aggregate to ensure the consistency and encapsulation of data within the aggregate. Implement business logic within the aggregate to ensure that all necessary changes and verifications are completed within the aggregate.

[0124] 2.3 Domain Modeling and Microservice Division Implementation:

[0125] Organize a cross-functional team, including business analysts, architects, developers, etc., to jointly conduct domain modeling and microservice division. Use auxiliary modeling tools to ensure that all key entities and relationships are accurately identified. Based on the division results, create an independent code base and deployment environment for each microservice.

[0126] 2.4 Aggregation design and implementation:

[0127] In each microservice, implement the corresponding aggregates and aggregate roots according to the aggregation design principles. Use object-oriented programming techniques to ensure close association and consistency between entities within the aggregate. Implement the business logic of the aggregate root, including data validation, business rule execution, etc. Introduce event tracing mechanism in the message service to record the historical records of key events such as message sending and receiving. Implement the CQRS mode to separate the message sending (command) and receiving (query) operations into different models. Use event storage and projection mechanisms to ensure that the data of the query model is consistent with the command model.

[0128] 2.5 Optimized implementation of intelligent message routing:

[0129] Dynamically adjust routing strategies: Dynamically adjust routing strategies based on the system's real-time load and message processing requirements to improve the overall performance of the system.

[0130] Introduce a cache mechanism: For frequently accessed routing information, a cache mechanism can be introduced to reduce the number of database accesses and response time.

[0131] Monitoring and logging: Real-time monitoring and logging of the operation of intelligent message routing to detect and resolve problems in a timely manner.

[0132] Continuous optimization and iteration: Based on the system operation status and user feedback, the design and implementation of intelligent message routing are continuously optimized to improve the stability and performance of the system.

[0133] 2.6 High-performance optimization strategy implementation:

[0134] Deploy multi-level cache in the system, including local cache and distributed cache. Use message queue to implement asynchronous processing mechanism to handle time-consuming operations such as message sending and user status update. Deploy load balancer to evenly distribute requests to each microservice node according to request type and load condition.

[0135] 2.7 Security and reliability assurance implementation:

[0136] Use encrypted transmission to ensure the security of data transmission. Introduce identity authentication mechanism to verify and authorize user identity. Regularly back up system data and set up disaster recovery and failover mechanisms to ensure high availability of the system and data security.

[0137] In an exemplary embodiment, the message server can be implemented by a computer device. The internal structure diagram of the computer device can be as follows: Figure 5 As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store data involved in the above method. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a message processing method is implemented.

[0138] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0139] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0140] In one embodiment, a computer program product is provided, on which a computer program is stored, and the computer program is used by a processor to execute the steps in the above-mentioned various method embodiments.

[0141] 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.

[0142] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present 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. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0143] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0144] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A message processing method, characterized in that: The method comprises: Receive the message set and the estimated time of the current task reported by each message server; Determine the number of messages that each message server needs to process based on the relative size of the estimated time taken for the current task reported by each message server and the total number of messages included in the message set; According to the message clients that currently have a long connection with each of the message servers, a number of target message clients are obtained; Determine the messages in the message set that are sent to the target message client to obtain a first-category message set, and obtain a second-category message set based on the messages in the message set except for the first-category message set; The first category message set and the second category message set are allocated in a manner that preferentially allocates the first category messages to the message server that has a long connection with the target message client that receives the first category messages, and in combination with the number of messages that each message server needs to process, to obtain the target message set of each message server; the target message set is sent by the message server to the message client via a long connection.

2. The method according to claim 1, characterized in that: Determine the number of messages to be processed by each message server according to the relative size of the estimated time taken for the current task reported by each message server and the total number of messages included in the message set, including: According to the relative size of the estimated time taken for the current task reported by each message server, the ratio of the number of messages between the message servers is obtained; The number of messages that each message server needs to process is determined according to the message number ratio relationship and the total number of messages included in the message set.

3. The method according to claim 1, characterized in that In a manner of preferentially allocating the first-class messages to the message servers that have a persistent connection with the target message clients that receive the first-class messages, the first-class message set and the second-class message set are allocated in combination with the number of messages to be processed by each message server, so as to obtain the target message set of each message server, including: Aggregating the messages of the type directed to the same target message client in the message set to obtain a subset of the messages of the type for each target message client; Allocating a message subset of each target message client to a message server that has established a persistent connection with the target message client, to obtain a preliminary message set for each message server; Based on the preliminary message sets of each message server, the second type of message sets are allocated to obtain the target message sets of each message server; the allocation of the second type of message sets makes the target message sets of each message server match the number of messages to be processed.

4. The method according to claim 3, characterized in that Based on the preliminary message sets of each of the message servers, before allocating the second type of message sets, the method further comprises: Determining whether the number of messages in the preliminary message set of each of the message servers does not exceed the number of messages to be processed by each of the message servers; If the number of messages in the preliminary message set of one of the message servers exceeds the number of messages to be processed, then obtaining a message quantity excess value according to the number of messages in the preliminary message set of the message server and the number of messages to be processed; If the message quantity excess value exceeds the excess threshold, a message subset of at least one target client is removed from the preliminary message set of the message server, so that the number of messages in the preliminary message set of the message server after removal does not exceed the excess threshold; The first-category message subset of the removed target client is added to the second-category message set.

5. The method according to claim 4, characterized in that Based on the preliminary message sets of each of the message servers, the second message sets are allocated, including: If the number of messages in the preliminary message sets of each of the message servers does not exceed the number of messages to be processed, the second type of message sets are allocated based on the preliminary message sets of each of the message servers; or, If the message quantity excess value does not exceed the excess threshold, the second type of message set is allocated based on the preliminary message set of each message server.

6. The method according to claim 1, characterized in that According to the message clients that currently have a long connection with each of the message servers, several target message clients are obtained, including: Obtain the long connection information reported by each message server; According to the persistent connection information, the message clients that currently have persistent connections with each of the message servers are determined, and a number of target message clients are obtained.

7. A message processing device, characterized in that: The device comprises: An information receiving module is used to receive message sets and the estimated time required for the current task reported by each message server; A quantity determination module, used to determine the number of messages to be processed by each message server according to the relative size of the estimated time taken for the current task reported by each message server and the total number of messages included in the message set; A target message client determination module, used to obtain a number of target message clients according to message clients that currently have a long connection with each of the message servers; A message classification module, used for determining the messages in the message set sent to the target message client to obtain a first-class message set, and obtaining a second-class message set based on the messages in the message set except the first-class message set; A message allocation module is used to allocate the first category of messages to the message server that has a long connection with the target message client that receives the first category of messages, in combination with the number of messages that each message server needs to process, to obtain the target message set of each message server; the target message set is sent by the message server to the message client through a long connection.

8. A distributed instant messaging system, characterized in that: The system includes a gateway and a message server; The gateway is used to execute the method according to any one of claims 1 to 6; The message server is used to receive the corresponding target message set and send the target message set to the message client through a long connection.

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 method according to any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Method and server for communicating with client

    CN102932352A

  • Load balancing method and system for message servers

    CN104243587A

  • Distributed message push system and method

    CN104717133A

  • Method and device for pushing instant message

    CN106533932A

  • Long connection based message pushing system and method

    CN107395767A