CN112653625A - Message routing method and device - Google Patents

Message routing method and device Download PDF

Info

Publication number
CN112653625A
CN112653625A CN201910958272.5A CN201910958272A CN112653625A CN 112653625 A CN112653625 A CN 112653625A CN 201910958272 A CN201910958272 A CN 201910958272A CN 112653625 A CN112653625 A CN 112653625A
Authority
CN
China
Prior art keywords
message
target
routed
cluster
identifier
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910958272.5A
Other languages
Chinese (zh)
Inventor
朱亚军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201910958272.5A priority Critical patent/CN112653625A/en
Publication of CN112653625A publication Critical patent/CN112653625A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/302Route determination based on requested QoS
    • H04L45/306Route determination based on the nature of the carried application

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The invention discloses a method and a device for message routing, and relates to the technical field of computers. One embodiment of the method comprises: receiving a message to be routed, acquiring a target message type of the message to be routed, and configuring a target cluster identifier for the message to be routed according to the target message type; generating a target grouping identifier of the message to be routed according to the acquired target message type and the configured target clustering identifier; and according to the target grouping identification, inquiring the target message service to which the message to be routed belongs from the registry, and routing the message to be routed to the target message application corresponding to the target message service. The implementation mode adopts the technical means of configuring the target cluster identifier for the message to be routed and generating the target grouping identifier by combining the specific message type, so that the message to be routed can be routed to the corresponding target message application by utilizing the generated target grouping identifier, and the target message application can independently process the message to be routed.

Description

Message routing method and device
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for message routing.
Background
With the advent of the information-oriented era, the online customer service instant messaging system has become an indispensable tool for serving customers and auxiliary websites. The online customer service instant communication system has a real-time chatting function, a function of actively inviting online users to chat and a file transmission function, can solve problems for the users at the first time, is convenient for website customer service personnel to actively contact the online users, and provides good experience for the users. Meanwhile, in the face of the continuously increasing number of users and the diversified demands of the users, the reliability requirement of the online customer service instant messaging system is high, so that the online customer service instant messaging system needs to process messages with various types and large flow independently without influencing each other.
In the current on-line customer service instant communication system, the received messages are respectively processed with business logic in the same application according to the types of the received messages, namely, the business logic processing is respectively carried out on different message types in the same process of the same set of application codes. However, in the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art: one or more message processing logics are in the same application, the application logic is complex, the service logic is not isolated, and the mutual influence can be caused; and secondly, services cannot be expanded according to the flow size of the message type and needs.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for message routing, which can use a generated target packet identifier to route a message to be routed to a corresponding target message application, so as to implement independent processing of the message to be routed.
To achieve the above object, according to a first aspect of the embodiments of the present invention, a method for message routing is provided.
The message routing method of the embodiment of the invention comprises the following steps: receiving a message to be routed, acquiring a target message type of the message to be routed, and configuring a target cluster identifier for the message to be routed according to the target message type; generating a target grouping identifier of the message to be routed according to the acquired target message type and the configured target clustering identifier; and according to the target grouping identification, inquiring the target message service to which the message to be routed belongs from a registry, and routing the message to be routed to the target message application corresponding to the target message service.
Optionally, the configuring, according to the type of the target message, a target cluster identifier for the message to be routed includes: determining a target thread pool corresponding to the message to be routed according to the type of the target message; acquiring an optional cluster identifier set corresponding to the target thread pool; and based on a cluster configuration balancing principle, selecting one cluster identifier from the selectable cluster identifier set to configure the selected cluster identifier as a target cluster identifier corresponding to the message to be routed.
Optionally, the selecting, based on a cluster configuration balancing principle, one cluster identifier from the selectable cluster identifier set to configure as a target cluster identifier corresponding to the message to be routed includes: acquiring cluster state information corresponding to each cluster identifier in the selectable cluster identifier set; calculating a configurable score of each cluster identifier in the selectable cluster identifier set according to the cluster state information corresponding to each cluster identifier; and determining the cluster identifier with the highest configurable score as the target cluster identifier corresponding to the message to be routed.
Optionally, after obtaining the optional cluster identifier set corresponding to the target thread pool, the method further includes: acquiring a cluster identifier set of traffic to be cut; and filtering the cluster identifications of the traffic to be cut in the optional cluster identification set according to the cluster identification set of the traffic to be cut.
Optionally, before generating the target packet identifier of the message to be routed according to the obtained target message type and the configured target cluster identifier, the method further includes: judging whether the cluster corresponding to the target cluster identifier needs to be switched or not; if yes, obtaining an alternative cluster identifier corresponding to the target cluster identifier, and replacing the target cluster identifier with the alternative cluster identifier.
Optionally, before querying, according to the target packet identifier, a target message service to which the message to be routed belongs from a registry and routing the message to be routed to a target message application corresponding to the target message service, the method further includes: acquiring the registry; wherein, the registry comprises the registration information obtained by the target message application registering the target group identifier and the target message service on a service platform.
Optionally, the registry includes at least one type of message service corresponding to the message type, and the number of the message services corresponding to each type of message type is dynamically set by the message application corresponding to the message service according to the number of the messages of each type of message type.
To achieve the above object, according to a second aspect of the embodiments of the present invention, there is provided an apparatus for message routing.
An apparatus for routing a message according to an embodiment of the present invention includes: the configuration module is used for receiving a message to be routed, acquiring a target message type of the message to be routed, and configuring a target cluster identifier for the message to be routed according to the target message type; a generating module, configured to generate a target group identifier of the message to be routed according to the obtained target message type and the configured target cluster identifier; and the routing module is used for inquiring the target message service to which the message to be routed belongs from a registry according to the target grouping identifier and routing the message to be routed to the target message application corresponding to the target message service.
Optionally, the configuration module is further configured to: determining a target thread pool corresponding to the message to be routed according to the type of the target message; acquiring an optional cluster identifier set corresponding to the target thread pool; and based on a cluster configuration balancing principle, selecting one cluster identifier from the selectable cluster identifier set to configure the selected cluster identifier as a target cluster identifier corresponding to the message to be routed.
Optionally, the configuration module is further configured to: acquiring cluster state information corresponding to each cluster identifier in the selectable cluster identifier set; calculating a configurable score of each cluster identifier in the selectable cluster identifier set according to the cluster state information corresponding to each cluster identifier; and determining the cluster identifier with the highest configurable score as the target cluster identifier corresponding to the message to be routed.
Optionally, the configuration module is further configured to: acquiring a cluster identifier set of traffic to be cut; and filtering the cluster identifications of the traffic to be cut in the optional cluster identification set according to the cluster identification set of the traffic to be cut.
Optionally, the generating module is further configured to: judging whether the cluster corresponding to the target cluster identifier needs to be switched or not; if yes, obtaining an alternative cluster identifier corresponding to the target cluster identifier, and replacing the target cluster identifier with the alternative cluster identifier.
Optionally, the routing module is further configured to: acquiring the registry; wherein, the registry comprises the registration information obtained by the target message application registering the target group identifier and the target message service on a service platform.
Optionally, the registry includes at least one type of message service corresponding to the message type, and the number of the message services corresponding to each type of message type is dynamically set by the message application corresponding to the message service according to the number of the messages of each type of message type.
To achieve the above object, according to a third aspect of embodiments of the present invention, there is provided an electronic apparatus.
An electronic device of an embodiment of the present invention includes: one or more processors; the storage device is used for storing one or more programs, and when the one or more programs are executed by one or more processors, the one or more processors realize the message routing method of the embodiment of the invention.
To achieve the above object, according to a fourth aspect of embodiments of the present invention, there is provided a computer-readable medium.
A computer-readable medium of an embodiment of the present invention has stored thereon a computer program that, when executed by a processor, implements the method of message routing of an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: the technical means of configuring the target cluster identifier for the message to be routed and generating the target grouping identifier by combining with the specific message type is adopted, so that the message to be routed can be routed to the corresponding target message application by utilizing the generated target grouping identifier, and the target message application can independently process the message to be routed, thereby overcoming the technical problems that in the prior art, a plurality of message processing logics are in the same application, and the logics are complex and are not isolated. In addition, in the message routing method of the embodiment of the invention, the cluster identifier of the message to be routed can be switched, and further the flow can be dynamically switched into the message application service of other clusters, so that the main/standby release and disaster recovery switching can be realized. In addition, in the method for configuring the target cluster identifier for the message to be routed according to the embodiment of the present invention, the selectable cluster identifier set is determined according to the type of the target message, and then the target cluster identifier is determined by combining the state information of each selectable cluster, so that the processing speed of the message can be increased, and the user experience can be improved. In addition, the number of the message services contained in the registry is dynamically set according to the number of the message type, so that the services can be expanded according to the flow size of different message types and requirements.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a schematic diagram of the main steps of a method of message routing according to an embodiment of the present invention;
FIG. 2 is a system architecture diagram of a method of message routing according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of the main flow of a method of message routing according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of the main modules of an apparatus for message routing according to an embodiment of the present invention;
FIG. 5 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 6 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
Fig. 1 is a schematic diagram of the main steps of a method of message routing according to an embodiment of the present invention. As a reference embodiment of the present invention, as shown in fig. 1, the main steps of the message routing method of the embodiment of the present invention may include:
step S101: receiving a message to be routed, acquiring a target message type of the message to be routed, and configuring a target cluster identifier for the message to be routed according to the target message type;
step S102: generating a target grouping identifier of the message to be routed according to the acquired target message type and the configured target clustering identifier;
step S103: and according to the target grouping identification, inquiring the target message service to which the message to be routed belongs from the registry, and routing the message to be routed to the target message application corresponding to the target message service.
As can be seen from the foregoing steps S101 to S103, in the message routing method according to the embodiment of the present invention, after receiving the message to be routed, the target message type of the message to be routed is obtained. The message types may include: login, rating, transit, heartbeat (i.e., monitoring online status through a long connection established), chat, and pull roaming (i.e., pulling history), etc. Then, the target cluster identifier may be dynamically configured for the message to be routed by using the obtained target message type. It should be noted here that, in the message routing method according to the embodiment of the present invention, the target cluster identifier is dynamically configured for the message to be routed, the target cluster identifier may be configured for the message to be routed according to the working state of the current cluster, and the configuration of the target cluster identifier will be described in detail in the following description, which is not specifically described here.
In the message routing method of the embodiment of the invention, the target cluster identifier can be dynamically configured, namely, the message can be dynamically allocated to a certain cluster, so that the message flow can be dynamically switched to the message application of each cluster. After the target message type and the target cluster identifier are obtained, a target group identifier of the message to be routed can be generated. Therefore, in step S103, the generated target packet identifier may be used to query the registry for the target message service to which the message to be routed belongs, so that the message to be routed may be directly allocated to the target message application corresponding to the target message service.
It should be noted that, in the message routing method according to the embodiment of the present invention, the corresponding relationship between the message service and the packet identifier may be queried in the registry. Therefore, a registry needs to be acquired in advance. The registry of the embodiment of the invention can be registration information obtained by the message application registering the packet identifier and the message service provided by the message application on the service platform. For example, there are 5 message applications, the 5 messages all belong to the same cluster, and when the 5 applications start, the message type processing services that they can provide are registered on the service platform, the service interface names are uniform, and the group identifier of the service may be the cluster identifier plus the message type. Specifically, when the 5 applications are started, each logic processing class of a local message processor is scanned, and the scanned logic processing classes are put into a local cache according to the message type and the logic processing class, and are registered in the service registration center according to the current cluster identifier and the message type. Therefore, when the message application receives the message, the specified message processing class can be inquired according to the message type, and corresponding service logic processing is carried out.
Therefore, in the message routing method according to the embodiment of the present invention, the registry includes message services corresponding to at least one type of message type, for example, the message type includes login, evaluation, forwarding, heartbeat, chat, and pull roaming, and the registry includes message services corresponding to the message types. The message service refers to a service that can be supported by the message application, for example, if a certain message application registers a login message service corresponding to a login message type on the service platform, it indicates that the message application can provide the login message service, that is, a message with a message type of login can be distributed to the message application. Therefore, the message application can dynamically set the number of the message services corresponding to the message type according to the message type, that is, the number of application instances of the message service of the message type is deployed according to the number of times of different message type requests. It is also noted here that the service platform only registers the message service, and does not actually store the implementation of the service, such as the registration of a certain interface com.
As mentioned above, in the message routing method according to the embodiment of the present invention, the target cluster identifier can be dynamically configured for the message to be routed according to the type of the target message, and the specific implementation method may include:
step S1011: determining a target thread pool corresponding to the message to be routed according to the type of the target message;
step S1012: acquiring an optional cluster identifier set corresponding to a target thread pool;
step S1013: based on the cluster configuration balancing principle, one cluster identifier is selected from the selectable cluster identifier sets and configured as a target cluster identifier corresponding to the message to be routed.
In the message routing method provided in the embodiment of the present invention, each message type corresponds to a separate thread pool for processing, and each thread pool corresponds to an optional cluster, for example, the message type is login and evaluation, the login corresponds to a first thread pool, the evaluation corresponds to a second thread pool, cluster identifiers of the optional clusters corresponding to the first thread pool are A, B, C and D, and optional cluster identifiers corresponding to the second thread pool are B, E and F, which indicates that machines in clusters A, B, C and D can provide login service, and machines in clusters B, E and F can provide evaluation service. Therefore, in the embodiment of the present invention, when configuring the target cluster identifier for the information to be routed, the target thread pool may be determined according to the target message type of the message to be routed, then the cluster identifier set of the selectable cluster is determined according to the target thread pool, and finally one cluster identifier is selected from the selectable cluster identifier set as the target cluster identifier of the message to be routed, so that which cluster the message to be routed may be routed to is determined.
From the above description, it can be obtained that the message type is an important basis for configuring the cluster identifier. Therefore, in the embodiment of the present invention, the message type field must be carried in the message, and in order to quickly and accurately extract the message type of the message to be routed, formats of all messages may be unified, for example, unified into a Json format (JavaScript Object notification, a lightweight data exchange format), so that an effect of improving message routing efficiency may be achieved. In addition, the message may further include a message unique identifier and a message body, and different message body formats may be defined according to different message types, which is not described in detail in the present invention.
After the optional cluster identifier set corresponding to the target thread pool is obtained in step S1012, a target cluster identifier needs to be selected from the optional cluster identifier set, so as to serve as a further reference embodiment of the present invention, step S1013 is to select one cluster identifier from the optional cluster identifier set based on a cluster configuration balancing principle, where the cluster identifier is configured as a target cluster identifier corresponding to the message to be routed, and the method may include: acquiring cluster state information corresponding to each cluster identifier in the optional cluster identifier set; calculating a configurable score of each cluster identifier in the selectable cluster identifier set according to the cluster state information corresponding to each cluster identifier; and determining the cluster identifier with the highest configurable score as the target cluster identifier corresponding to the message to be routed.
After the optional cluster identifier set corresponding to the target thread pool is obtained, an optimal cluster identifier needs to be selected from the optional cluster identifier set as a target cluster identifier of the information to be routed. Specifically, it is necessary to obtain state information of a cluster corresponding to each cluster identifier in the optional cluster identifier set, for example, working state information of the cluster (including but not limited to a busy state and an idle state), distance information of the cluster (i.e., a distance between the cluster and a message to be routed), capacity information of the cluster (i.e., a number of message applications included in the cluster), and the like; then, according to the acquired cluster state information of each cluster, calculating a configurable score of each cluster (that is, a score which can be configured as a target cluster identifier is higher, which indicates that the probability of configuring the cluster as the target cluster identifier is higher); and finally, selecting the cluster identifier with the highest configuration score as the target cluster identifier.
In the message routing method of the embodiment of the invention, in the process of configuring the target cluster identifier for the target routing message, the cluster state information and the cluster of the flow to be switched are considered. In practical applications, a situation that the cluster needs to split traffic may occur, for example, in order to increase the message processing speed of the cluster a or a fault occurs in the cluster a, a situation that the traffic of the cluster a needs to be split may occur. Therefore, as another referential embodiment of the present invention, after obtaining the optional cluster identifier set corresponding to the target thread pool, the method for message routing may further include: acquiring a cluster identifier set of traffic to be cut; and filtering the cluster identifications of the traffic to be cut in the optional cluster identification set according to the cluster identification set of the traffic to be cut. That is, the optional cluster identifier set and the cluster identifier set of the traffic to be cut are obtained, then whether the optional cluster identifier set includes the cluster identifier of the traffic to be cut is judged, if the optional cluster identifier set includes the cluster identifier of the traffic to be cut, the cluster identifiers of the traffic to be cut need to be deleted, and then the target cluster identifier is selected from the rest optional cluster identifiers.
In the message routing method according to the embodiment of the present invention, in addition to filtering the selectable cluster identifier set, before generating the target group identifier of the message to be routed according to the acquired target message type and the configured target cluster identifier, the target cluster identifier may be determined, specifically: judging whether the cluster corresponding to the target cluster identifier needs to be switched or not; if yes, obtaining an alternative cluster identifier corresponding to the target cluster identifier, and replacing the target cluster identifier with the alternative cluster identifier. It should be noted that the relationship of each cluster identifier needs to be preset, that is, the candidate cluster identifier corresponding to the target cluster identifier is set, where both the target cluster identifier and the cluster corresponding to the candidate cluster identifier can provide the message service of the message to be routed. For example, if the target cluster identifier is a, the candidate cluster identifier is B, and the message type of the message to be routed is evaluation, the cluster corresponding to a can provide evaluation service, and the cluster corresponding to B can also provide evaluation service. Therefore, in the embodiment of the present invention, alternative clusters may be preset, the alternative clusters may provide message services corresponding to each message type, and when a target cluster fails, the alternative cluster may be used to replace the target cluster to process a message to be routed.
In summary, in the message routing method according to the embodiment of the present invention, the cluster identifier of the message to be routed can be switched, and further, the flow can be dynamically switched to the message application service of other clusters, so that the active/standby distribution and the disaster recovery switching can be implemented.
For convenience of understanding, the main steps of the message routing method according to the embodiment of the present invention are described with reference to fig. 2, where fig. 2 is a system architecture diagram of the message routing method according to the embodiment of the present invention, and the JSF platform in fig. 2 belongs to a service platform, which supports inter-call between applications, although other service platforms may be used in the embodiment of the present invention, which is not limited to this.
The TCP access point in fig. 2 is used for TCP connection point application, and is mainly used for TCP communication with the client through the TCP connection point. As can be seen from fig. 2, after receiving the message through the TCP access point, the TCP access point needs to forward the message to the Route application (i.e., routing application), where each message type in the Route application corresponds to a single thread pool for processing, and each message type can be forwarded to each type of message application according to different message types, thereby realizing that each type of message can be processed independently. Each message type corresponds to a single thread pool for processing, can be assembled into a group identification through a configured group name (namely, a group identification) and a message type in a received message, then queries a corresponding message service on a service platform through a uniform interface and the group identification, and finally forwards the message route to a message application to which the message belongs. And according to the judgment of the message type field of the message, if the message type field is evaluation and the configured cluster identifier is dd _ mjq, searching for the service corresponding to dd _ mjq _ evaluation. Because the Route application can dynamically configure the cluster identifier, the traffic can be dynamically switched to the message application service of each cluster. If the machine deploying the cluster dd _ mjq message service needs to dynamically change the cluster identifier of the routing application of dd _ mjq to dd _ lf, the cluster identifier is mapped to the message type service of dd _ lf _ xx, and the traffic is switched to another cluster.
In addition, when the message one, two, and three application services in fig. 2 are started, the message type service processing service is dynamically registered to the service platform, the service interface names are uniform, and the group identifier of the service is composed of a cluster name (i.e., a cluster identifier) and a message type. That is, when the application is started, each logic processing class of the local message processor is scanned, and is put into the local cache according to the message type and the logic processing class, and is registered to the service platform according to the cluster identifier and the message type. Therefore, when the message application receives the message, the specified message processing class can be inquired according to the message type field, and corresponding service logic processing is carried out. As can also be seen from fig. 2, the message routing method according to the embodiment of the present invention can perform routing processing on multiple messages in parallel, respectively obtain message types of the multiple messages, match the cluster identifiers for the message types, then generate the packet identifiers, finally query message services corresponding to the multiple messages according to the packet identifiers, and then route the multiple messages to corresponding message applications through the routing services.
Fig. 3 is a schematic diagram of a main flow of a method of message routing according to an embodiment of the present invention. As shown in fig. 3, the main flow of the message routing method according to the embodiment of the present invention may include:
step S301: receiving a message to be routed, and acquiring a target message type of the message to be routed;
step S302: determining a target thread pool corresponding to the message to be routed according to the type of the target message;
step S303: acquiring an optional cluster identifier set corresponding to a target thread pool and a cluster identifier set of flow to be cut;
step S304: according to the cluster identifier set of the traffic to be cut, filtering the cluster identifiers of the traffic to be cut in the optional cluster identifier set:
step S305: acquiring cluster state information corresponding to each cluster identifier in the optional cluster identifier set;
step S306: calculating a configurable score of each cluster identifier in the selectable cluster identifier set according to the cluster state information corresponding to each cluster identifier;
step S307: determining the cluster identifier with the highest configurable score as a target cluster identifier corresponding to the message to be routed;
step S308: judging whether the cluster corresponding to the target cluster identifier needs to be switched, if so, executing the step S309;
step S309: acquiring an alternative cluster identifier corresponding to the target cluster identifier, and replacing the target cluster identifier with the alternative cluster identifier;
step S310: generating a target grouping identifier of the message to be routed according to the acquired target message type and the configured target clustering identifier;
step S311: and according to the target grouping identification, inquiring the target message service to which the message to be routed belongs from the registry, and routing the message to be routed to the target message application corresponding to the target message service.
It should be noted that, before step S311, the registry needs to be acquired. The information in the registry is registered by the messaging application on the service platform. The registry may include registration information obtained by the message application registering the group identifier and the message service on the service platform, and the registry includes at least one type of message service corresponding to the message type, and the number of the message services corresponding to each type of message type is dynamically set by the message application corresponding to the message service according to the number of the messages of each type of message type, which has been explained in detail above, and is not described here again.
According to the technical scheme of the message routing, the technical means of configuring the target cluster identifier for the message to be routed and generating the target grouping identifier by combining the specific message type are adopted, so that the message to be routed can be routed to the corresponding target message application by utilizing the generated target grouping identifier, and the target message application can independently process the message to be routed, and the technical problem that in the prior art, a plurality of message processing logics are in the same application, and the logics are complex and not isolated is solved. In addition, in the message routing method of the embodiment of the invention, the cluster identifier of the message to be routed can be switched, and further the flow can be dynamically switched into the message application service of other clusters, so that the main/standby release and disaster recovery switching can be realized. In addition, in the method for configuring the target cluster identifier for the message to be routed according to the embodiment of the present invention, the selectable cluster identifier set is determined according to the type of the target message, and then the target cluster identifier is determined by combining the state information of each selectable cluster, so that the processing speed of the message can be increased, and the user experience can be improved. In addition, the number of the message services contained in the registry is dynamically set according to the number of the message type, so that the services can be expanded according to the flow size of different message types and requirements.
Fig. 4 is a schematic diagram of the main modules of an apparatus for message routing according to an embodiment of the present invention. As shown in fig. 4, the apparatus 400 for message routing according to the embodiment of the present invention mainly includes the following modules: a configuration module 401, a generation module 402 and a routing module 403.
The configuration module 401 may be configured to receive a message to be routed, obtain a target message type of the message to be routed, and configure a target cluster identifier for the message to be routed according to the target message type; the generating module 402 may be configured to generate a target group identifier of a message to be routed according to the obtained type of the target message and the configured target cluster identifier; the routing module 403 may be configured to query, according to the target packet identifier, a target message service to which the message to be routed belongs from the registry, and route the message to be routed to a target message application corresponding to the target message service.
In this embodiment of the present invention, the configuration module 401 may further be configured to: determining a target thread pool corresponding to the message to be routed according to the type of the target message; acquiring an optional cluster identifier set corresponding to a target thread pool; based on the cluster configuration balancing principle, one cluster identifier is selected from the selectable cluster identifier sets and configured as a target cluster identifier corresponding to the message to be routed.
In this embodiment of the present invention, the configuration module 401 may further be configured to: acquiring cluster state information corresponding to each cluster identifier in the optional cluster identifier set; calculating a configurable score of each cluster identifier in the selectable cluster identifier set according to the cluster state information corresponding to each cluster identifier; and determining the cluster identifier with the highest configurable score as the target cluster identifier corresponding to the message to be routed.
In this embodiment of the present invention, the configuration module 401 may further be configured to: acquiring a cluster identifier set of traffic to be cut; and filtering the cluster identifications of the traffic to be cut in the optional cluster identification set according to the cluster identification set of the traffic to be cut.
In this embodiment of the present invention, the generating module 402 may further be configured to: judging whether the cluster corresponding to the target cluster identifier needs to be switched or not; if yes, obtaining an alternative cluster identifier corresponding to the target cluster identifier, and replacing the target cluster identifier with the alternative cluster identifier.
In this embodiment of the present invention, the routing module 403 may further be configured to: and acquiring a registry. The obtained registry may include registration information obtained by the target message application registering the target group identifier and the target message service on the service platform.
In the embodiment of the present invention, the registry may include at least one type of message service corresponding to the message type, and the number of the message services corresponding to each type of message type is dynamically set by the message application corresponding to the message service according to the number of the messages of each type of message type.
As can be seen from the above description, the message routing apparatus in the embodiment of the present invention can adopt a technical means of configuring a target cluster identifier for a message to be routed, and generating a target packet identifier in combination with a specific message type, so that the message to be routed can be routed to a corresponding target message application by using the generated target packet identifier, so that the target message application can independently process the message to be routed, and therefore, the technical problem in the prior art that a plurality of message processing logics are in the same application, and the logics are complex and not isolated is solved. In addition, in the message routing method of the embodiment of the invention, the cluster identifier of the message to be routed can be switched, and further the flow can be dynamically switched into the message application service of other clusters, so that the main/standby release and disaster recovery switching can be realized. In addition, in the method for configuring the target cluster identifier for the message to be routed according to the embodiment of the present invention, the selectable cluster identifier set is determined according to the type of the target message, and then the target cluster identifier is determined by combining the state information of each selectable cluster, so that the processing speed of the message can be increased, and the user experience can be improved. In addition, the number of the message services contained in the registry is dynamically set according to the number of the message type, so that the services can be expanded according to the flow size of different message types and requirements.
Fig. 5 illustrates an exemplary system architecture 500 of a message routing method or apparatus to which embodiments of the invention may be applied.
As shown in fig. 5, the system architecture 500 may include terminal devices 501, 502, 503, a network 504, and a server 505. The network 504 serves to provide a medium for communication links between the terminal devices 501, 502, 503 and the server 505. Network 504 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal devices 501, 502, 503 to interact with a server 505 over a network 504 to receive or send messages or the like. The terminal devices 501, 502, 503 may have installed thereon various communication client applications, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 501, 502, 503 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 505 may be a server providing various services, such as a background management server (for example only) providing support for shopping websites browsed by users using the terminal devices 501, 502, 503. The backend management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (for example, target push information, product information — just an example) to the terminal device.
It should be noted that the method for message routing provided by the embodiment of the present invention is generally executed by the server 505, and accordingly, the device for message routing is generally disposed in the server 505.
It should be understood that the number of terminal devices, networks, and servers in fig. 5 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 6, a block diagram of a computer system 600 suitable for use with a terminal device implementing an embodiment of the invention is shown. The terminal device shown in fig. 6 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 6, the computer system 600 includes a Central Processing Unit (CPU)601 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM)602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. In the RAM 603, various programs and data necessary for the operation of the system 600 are also stored. The CPU 601, ROM 602, and RAM 603 are connected to each other via a bus 604. An input/output (I/O) interface 605 is also connected to bus 604.
The following components are connected to the I/O interface 605: an input portion 606 including a keyboard, a mouse, and the like; an output portion 607 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The driver 610 is also connected to the I/O interface 605 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 610 as necessary, so that a computer program read out therefrom is mounted in the storage section 608 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 609, and/or installed from the removable medium 611. The computer program performs the above-described functions defined in the system of the present invention when executed by the Central Processing Unit (CPU) 601.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes a configuration module, a generation module, and a routing module. For example, the configuration module may also be described as a module that receives a message to be routed, acquires a target message type of the message to be routed, and configures a target cluster identifier for the message to be routed according to the target message type.
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: receiving a message to be routed, acquiring a target message type of the message to be routed, and configuring a target cluster identifier for the message to be routed according to the target message type; generating a target grouping identifier of the message to be routed according to the acquired target message type and the configured target clustering identifier; and according to the target grouping identification, inquiring the target message service to which the message to be routed belongs from the registry, and routing the message to be routed to the target message application corresponding to the target message service.
According to the technical scheme of the embodiment of the invention, the technical means of configuring the target cluster identifier for the message to be routed and generating the target grouping identifier by combining the specific message type is adopted, so that the message to be routed can be routed to the corresponding target message application by utilizing the generated target grouping identifier, and the target message application can independently process the message to be routed, thereby overcoming the technical problems that in the prior art, a plurality of message processing logics are in the same application, and the logics are complex and not isolated. In addition, in the message routing method of the embodiment of the invention, the cluster identifier of the message to be routed can be switched, and further the flow can be dynamically switched into the message application service of other clusters, so that the main/standby release and disaster recovery switching can be realized. In addition, in the method for configuring the target cluster identifier for the message to be routed according to the embodiment of the present invention, the selectable cluster identifier set is determined according to the type of the target message, and then the target cluster identifier is determined by combining the state information of each selectable cluster, so that the processing speed of the message can be increased, and the user experience can be improved. In addition, the number of the message services contained in the registry is dynamically set according to the number of the message type, so that the services can be expanded according to the flow size of different message types and requirements.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A method of message routing, comprising:
receiving a message to be routed, acquiring a target message type of the message to be routed, and configuring a target cluster identifier for the message to be routed according to the target message type;
generating a target grouping identifier of the message to be routed according to the acquired target message type and the configured target clustering identifier;
and according to the target grouping identification, inquiring the target message service to which the message to be routed belongs from a registry, and routing the message to be routed to the target message application corresponding to the target message service.
2. The method of claim 1, wherein the configuring the target cluster identifier for the message to be routed according to the target message type comprises:
determining a target thread pool corresponding to the message to be routed according to the type of the target message;
acquiring an optional cluster identifier set corresponding to the target thread pool;
and based on a cluster configuration balancing principle, selecting one cluster identifier from the selectable cluster identifier set to configure the selected cluster identifier as a target cluster identifier corresponding to the message to be routed.
3. The method according to claim 2, wherein the selecting one cluster identifier from the selectable set of cluster identifiers to configure as the target cluster identifier corresponding to the message to be routed based on a cluster configuration balancing principle includes:
acquiring cluster state information corresponding to each cluster identifier in the selectable cluster identifier set;
calculating a configurable score of each cluster identifier in the selectable cluster identifier set according to the cluster state information corresponding to each cluster identifier;
and determining the cluster identifier with the highest configurable score as the target cluster identifier corresponding to the message to be routed.
4. The method of claim 2, wherein after obtaining the set of optional cluster identifiers corresponding to the target thread pool, the method further comprises:
acquiring a cluster identifier set of traffic to be cut;
and filtering the cluster identifications of the traffic to be cut in the optional cluster identification set according to the cluster identification set of the traffic to be cut.
5. The method according to claim 1, wherein before generating the target packet identifier of the message to be routed according to the obtained target message type and the configured target cluster identifier, the method further comprises:
judging whether the cluster corresponding to the target cluster identifier needs to be switched or not;
if yes, obtaining an alternative cluster identifier corresponding to the target cluster identifier, and replacing the target cluster identifier with the alternative cluster identifier.
6. The method according to claim 1, wherein before querying a target message service to which the message to be routed belongs from a registry according to the target packet identifier and routing the message to be routed to a target message application corresponding to the target message service, the method further comprises:
acquiring the registry; wherein the content of the first and second substances,
the registry comprises registration information obtained by the target message application registering the target group identifier and the target message service on a service platform.
7. The method according to claim 1, wherein the registry comprises at least one type of message service corresponding to the message type, and the number of the message services corresponding to each type of message type is dynamically set by the message application corresponding to the message service according to the number of the messages of each type of message type.
8. An apparatus for message routing, comprising:
the configuration module is used for receiving a message to be routed, acquiring a target message type of the message to be routed, and configuring a target cluster identifier for the message to be routed according to the target message type;
a generating module, configured to generate a target group identifier of the message to be routed according to the obtained target message type and the configured target cluster identifier;
and the routing module is used for inquiring the target message service to which the message to be routed belongs from a registry according to the target grouping identifier and routing the message to be routed to the target message application corresponding to the target message service.
9. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-7.
10. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-7.
CN201910958272.5A 2019-10-10 2019-10-10 Message routing method and device Pending CN112653625A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910958272.5A CN112653625A (en) 2019-10-10 2019-10-10 Message routing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910958272.5A CN112653625A (en) 2019-10-10 2019-10-10 Message routing method and device

Publications (1)

Publication Number Publication Date
CN112653625A true CN112653625A (en) 2021-04-13

Family

ID=75342595

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910958272.5A Pending CN112653625A (en) 2019-10-10 2019-10-10 Message routing method and device

Country Status (1)

Country Link
CN (1) CN112653625A (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2001013228A2 (en) * 1999-08-13 2001-02-22 Sun Microsystems, Inc. Graceful distribution in application server load balancing
US6993034B1 (en) * 1998-10-15 2006-01-31 International Business Machines Corporation Cluster destination address table—IP routing for clusters
CN105991408A (en) * 2015-02-12 2016-10-05 腾讯科技(深圳)有限公司 Message processing method, message processing device and processing server
CN106407011A (en) * 2016-09-20 2017-02-15 焦点科技股份有限公司 A routing table-based search system cluster service management method and system
CN108737270A (en) * 2018-05-07 2018-11-02 北京京东尚科信息技术有限公司 A kind of method for managing resource and device of server cluster
CN109144744A (en) * 2017-06-28 2019-01-04 北京京东尚科信息技术有限公司 Task processing system, method and apparatus
CN109492013A (en) * 2018-11-02 2019-03-19 北京京东金融科技控股有限公司 Data processing method, device and system applied to data-base cluster
CN109660607A (en) * 2018-12-05 2019-04-19 北京金山云网络技术有限公司 A kind of service request distribution method, method of reseptance, device and server cluster

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6993034B1 (en) * 1998-10-15 2006-01-31 International Business Machines Corporation Cluster destination address table—IP routing for clusters
WO2001013228A2 (en) * 1999-08-13 2001-02-22 Sun Microsystems, Inc. Graceful distribution in application server load balancing
CN105991408A (en) * 2015-02-12 2016-10-05 腾讯科技(深圳)有限公司 Message processing method, message processing device and processing server
CN106407011A (en) * 2016-09-20 2017-02-15 焦点科技股份有限公司 A routing table-based search system cluster service management method and system
CN109144744A (en) * 2017-06-28 2019-01-04 北京京东尚科信息技术有限公司 Task processing system, method and apparatus
CN108737270A (en) * 2018-05-07 2018-11-02 北京京东尚科信息技术有限公司 A kind of method for managing resource and device of server cluster
CN109492013A (en) * 2018-11-02 2019-03-19 北京京东金融科技控股有限公司 Data processing method, device and system applied to data-base cluster
CN109660607A (en) * 2018-12-05 2019-04-19 北京金山云网络技术有限公司 A kind of service request distribution method, method of reseptance, device and server cluster

Similar Documents

Publication Publication Date Title
US10397120B2 (en) Service link selection control method and device
CN111711663A (en) Processing method and device for publishing and subscribing services and electronic equipment
AU2014415653A1 (en) Application service delivery through an application service avatar
US9722890B2 (en) Integrated incident management for hybrid landscapes
CN111934840A (en) Communication method of client and server, gateway, electronic equipment and storage medium
CN110321252B (en) Skill service resource scheduling method and device
WO2017174026A1 (en) Client connection method and system
CN107395686B (en) The method, apparatus and system of the long connection of switching
CN111181765A (en) Task processing method and device
CN109753424B (en) AB test method and device
CN111984234A (en) Method and device for processing work order
CN110798495B (en) Method and server for end-to-end message push in cluster architecture mode
CN112653632A (en) Flow control realization method and device
CN110620722B (en) Order processing method and device
CN111555894B (en) Data processing method, device, equipment and storage medium
CN113452600A (en) Cross-region message communication method and device, electronic equipment and storage medium
CN112948138A (en) Method and device for processing message
CN110247847B (en) Method and device for back source routing between nodes
CN112653625A (en) Message routing method and device
CN106533891A (en) Information processing method based on groups and device
CN106408793B (en) A kind of Service Component sharing method and system suitable for ATM business
CN114896244A (en) Method, device and equipment for configuring database table and computer readable medium
CN112688982B (en) User request processing method and device
CN112836201A (en) Method, device, equipment and computer readable medium for multi-platform information intercommunication
CN113556370A (en) Service calling method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination