Message exchange method and apparatus
Patent Information
- Application Number
- CN202311132751.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-04
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2043-09-04
AI Technical Summary
[0004]然而上述方式,需要消息发送端和消息接收端同时嵌入消息SDK并开发相关代码方可使用,对消息发送端和消息接收端所在的应用系统的代码的侵入性较强
[0021]1. Message exchange between senders and receivers is achieved through an exchange service cluster. During message transmission, network protocols (such as HTTP, TCP, RPC, etc.) can be used, eliminating the need for SDK integration between the sender and receiver, thus reducing code intrusion into the application system. Furthermore, senders and receivers do not need to concern themselves with technical parameters such as message topics; the sender simply sends the message to the exchange service cluster, which routes the message to the corresponding topic based on transaction keywords within the message, further reducing code complexity and ease of use on both the sender and receiver sides. Moreover, using an exchange service cluster for message exchange requires only a simple API (Application Programming Interface) for fast and efficient message sending and querying, resulting in a low barrier to entry and rapid integration into business operations.
Smart Images

Figure CN117061636B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Internet technology, and in particular to a message exchange method and apparatus. Background Technology
[0002] Message middleware is an important component in distributed systems, mainly solving problems such as application coupling, asynchronous messaging, traffic shaping, and log processing, and achieving high-performance, high-availability, scalable, and eventually consistent architectures.
[0003] Currently, message senders (or message producers) send messages to message middleware by integrating a message SDK (Software Development Kit) into their applications, or message receivers (or message consumers) pull or consume messages from message middleware by integrating a message SDK into their applications.
[0004] However, the above method requires both the message sender and the message receiver to embed the message SDK and develop the relevant code before it can be used, which is highly intrusive to the code of the application system where the message sender and the message receiver reside. Summary of the Invention
[0005] This application aims to at least partially address one of the technical problems in the related art.
[0006] One aspect of this application proposes a message exchange method and apparatus to realize message exchange between message senders and message receivers through an exchange service cluster. During message transmission, it can be based on network protocols (such as HTTP, TCP, RPC, etc.) without integrating an SDK between the message sender and receiver, thus reducing the intrusion into the application system's code. Furthermore, the message sender and receiver do not need to concern themselves with technical parameters such as message topics; the message sender only needs to send the message to the exchange service cluster, which routes the message to the corresponding topic based on the transaction keywords in the message, thereby reducing the code complexity and ease of use on both the message sender and receiver sides.
[0007] The first aspect of this application proposes a message exchange method applied to an exchange service cluster, including:
[0008] At least one first message is retrieved from the first message middleware; wherein the first message is routed to the first message middleware by the exchange service cluster after receiving the first message sent by the first message sender;
[0009] For any given first message, the first message is parsed to obtain a first transaction keyword; wherein, the first transaction keyword is used to indicate the service to which the given first message belongs;
[0010] Based on the first transaction keyword, determine the first address information of the first message receiving end;
[0011] Based on the first address information, any one of the first message messages is sent to the first message receiving end.
[0012] A second aspect of this application provides a message exchange apparatus for use in an exchange service cluster, comprising:
[0013] The pull module is used to pull at least one first message from the first message middleware; wherein the first message is routed to the first message middleware by the exchange service cluster after receiving the first message sent by the first message sender;
[0014] The parsing module is used to parse any first message to obtain a first transaction keyword; wherein the first transaction keyword is used to indicate the service to which the first message belongs;
[0015] The determining module is used to determine the first address information of the first message receiving end based on the first transaction keyword;
[0016] The sending module is used to send any of the first message messages to the first message receiving end according to the first address information.
[0017] A third aspect of this application provides an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, it implements the message exchange method as proposed in the first aspect of this application.
[0018] The fourth aspect of this application provides a non-transitory computer-readable storage medium storing a computer program that, when executed by a processor, implements the message exchange method as proposed in the first aspect of this application.
[0019] A fifth aspect of this application provides a computer program product in which, when instructions in the computer program product are executed by a processor, the message exchange method as described in the first aspect of this application is performed.
[0020] The technical solutions provided by the above embodiments of this application bring at least the following beneficial effects:
[0021] 1. Message exchange between senders and receivers is achieved through an exchange service cluster. During message transmission, network protocols (such as HTTP, TCP, RPC, etc.) can be used, eliminating the need for SDK integration between the sender and receiver, thus reducing code intrusion into the application system. Furthermore, senders and receivers do not need to concern themselves with technical parameters such as message topics; the sender simply sends the message to the exchange service cluster, which routes the message to the corresponding topic based on transaction keywords within the message, further reducing code complexity and ease of use on both the sender and receiver sides. Moreover, using an exchange service cluster for message exchange requires only a simple API (Application Programming Interface) for fast and efficient message sending and querying, resulting in a low barrier to entry and rapid integration into business operations.
[0022] 2. Each exchange service in the exchange service cluster only routes message messages sent by message senders that have passed authentication to the message middleware, while directly discarding message messages sent by message senders that have failed authentication, which can improve the security of the business system.
[0023] 3. When message push fails, the message can be pushed to the DB (Database) for persistent storage and retried periodically to improve the success rate of message exchange. After the message push is successful, the message stored in the DB can be deleted to reduce storage overhead. In addition, when a single exchange service in the exchange service cluster fails, the message can be automatically migrated to other available exchange services to improve the success rate of message exchange.
[0024] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0025] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein:
[0026] Figure 1 This is a schematic flowchart of a message exchange method provided in an embodiment of this application;
[0027] Figure 2 A flowchart illustrating another message exchange method provided in an embodiment of this application;
[0028] Figure 3 A flowchart illustrating another message exchange method provided in an embodiment of this application;
[0029] Figure 4 A flowchart illustrating another message exchange method provided in an embodiment of this application;
[0030] Figure 5 A flowchart illustrating another message exchange method provided in an embodiment of this application;
[0031] Figure 6 This is a schematic diagram of the system architecture provided in the embodiments of this application;
[0032] Figure 7 This is a schematic diagram of the structure of a message exchange device provided in an embodiment of this application;
[0033] Figure 8 This is a schematic diagram of the structure of an electronic device shown in an exemplary embodiment of this application. Detailed Implementation
[0034] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.
[0035] Message middleware, also known as message queue, mainly solves problems such as application coupling, asynchronous messaging, traffic shaping, and log processing. It is an application that needs to be deployed independently on a server, similar to a database, and provides interfaces for other systems to call.
[0036] Currently, message senders and receivers use message middleware by integrating a message SDK into their applications. This approach requires both the message sender and receiver to embed the message SDK and develop the relevant code, which is highly intrusive to the code of the application system where the message sender and receiver reside.
[0037] To address the aforementioned problems, one aspect of this application proposes a message exchange method and apparatus.
[0038] The message exchange method and apparatus of this application embodiments are described below with reference to the accompanying drawings. Before specifically describing the embodiments of this application, for ease of understanding, commonly used technical terms are first introduced:
[0039] Kafka is a high-throughput distributed publish-subscribe messaging system that can handle all action stream data from consumers (or consumers) on a website.
[0040] RocketMQ is an open-source distributed message middleware.
[0041] ZeroMQ is a lightweight message communication library that is a unique message middleware built on the extension of the traditional standard socket interface.
[0042] IP is an abbreviation for Internet Protocol.
[0043] MQ is an abbreviation for Message Queue.
[0044] MQTT is an abbreviation for Message Queuing Telemetry Transport, which is a "lightweight" communication protocol based on the publish / subscribe model.
[0045] HTTP is an abbreviation for Hypertext Transfer Protocol.
[0046] TCP is an abbreviation for Transmission Control Protocol.
[0047] RPC is an abbreviation for Remote Procedure Call.
[0048] URL is an abbreviation for Uniform Resource Locator.
[0049] Figure 1 This is a flowchart illustrating a message exchange method provided in an embodiment of this application.
[0050] The message exchange method provided in this application embodiment can be applied to an exchange service cluster, for example, it can be applied to any available exchange service (or exchange service node) in the exchange service cluster.
[0051] like Figure 1 As shown, the message exchange method may include the following steps:
[0052] Step S101: Retrieve at least one first message from the first message middleware; wherein the first message is routed to the first message middleware by the exchange service cluster after receiving the first message sent by the first message sender.
[0053] The first message sender can be any message sender (or message producer). The message sender can be a client that produces messages or a client that sends messages. The client can be a software program running on a device to provide services to users, or it can be a program or device using MQTT. The device can be, for example, a personal computer, a mobile terminal, or a server. Mobile terminals can be, for example, mobile phones, tablets, personal digital assistants, wearable devices, intelligent robots, or other hardware devices with various operating systems, touchscreens, and / or displays.
[0054] In this embodiment of the application, the first message sender can send a first message to the exchange service cluster based on a network protocol (such as HTTP, TCP, RPC protocol, etc.) so that the exchange service cluster can route the first message to the first message middleware.
[0055] For example, the first message sender may send a first message to an exchange service in the exchange service cluster (which may be the first exchange service (where the first exchange service may be any available exchange service in the exchange service cluster) or other exchange services in the exchange service cluster other than the first exchange service, in this application, the first exchange service or other exchange services are collectively referred to as the target exchange service) based on the network protocol.
[0056] As an example, taking the HTTP protocol as an example, the first message sender can connect to the HTTP request interface, and the first message sender can send the first message to the target exchange service in the exchange service cluster through the interface.
[0057] In this embodiment of the application, after receiving the first message sent by the first message sender, the target exchange service in the exchange service cluster can route the first message to the first message middleware, for example, route the first message to the first topic of the first message middleware.
[0058] In this embodiment of the application, the exchange service cluster can pull or consume at least one first message from a first message middleware. For example, taking the method applied to a first exchange service in the exchange service cluster as an example, the first exchange service can subscribe to topics in each message middleware, or the first exchange service can subscribe to topics in some message middleware, so that the first exchange service can pull or consume at least one first message from a first topic in the first message middleware. Here, the first topic is the topic subscribed to by the first exchange service.
[0059] The topic is the classification of different business subscriptions in the message middleware, such as accounting notifications and SMS notifications.
[0060] It should be noted that the topics of the messages generated by different message senders may be different. For example, message 1 generated by message sender 1 in the upstream system (or upstream business system) is about accounting notification, while message 2 generated by message sender 2 is about SMS notification. In this case, the exchange service cluster can route message 1 sent by message sender 1 to the accounting notification of the first message middleware, and route message 2 sent by message sender 2 to the SMS notification of the first message middleware.
[0061] Step S102: For any first message, parse the first message to obtain a first transaction keyword, wherein the first transaction keyword is used to indicate the service to which the first message belongs.
[0062] In this embodiment of the application, the first transaction keyword is used to indicate the service to which the corresponding first message belongs. For example, the first transaction keyword can be a field in the first message that has a service-unique characteristic, such as a system number. The system number can be the number of the system to which the first message sender belongs, and this system corresponds to a service.
[0063] In this embodiment of the application, for any first message that is pulled, the exchange service cluster can parse the first message to obtain the transaction keyword (referred to as the first transaction keyword in this application) in the first message.
[0064] Step S103: Determine the first address information of the first message receiver based on the first transaction keyword.
[0065] In this embodiment of the application, the exchange service cluster can determine the address information (referred to as the first address information, such as URL address information) of the first message receiver (e.g., a message receiver subscribing to the first topic) based on the first transaction keyword.
[0066] For example, taking the method as an example when applied to the first exchange service in an exchange service cluster, the first exchange service can determine the first address information of the first message receiver subscribing to the first topic based on the first transaction keyword in the first message.
[0067] In one possible implementation of this application, different mapping relationships (referred to as the second mapping relationship in this application) between transaction keywords and message receiver address information can be pre-configured on each exchange service side in the exchange service cluster. For example, each exchange service (including the first exchange service) can receive configuration instructions triggered by relevant personnel, configure the second mapping relationship between different transaction keywords and message receiver address information according to the configuration instructions, and store the second mapping relationship.
[0068] Therefore, in this application, the first address information of the first message receiver subscribing to the first topic can be determined by querying the second mapping relationship based on the first transaction keyword.
[0069] Step S104: Based on the first address information, send any first message to the first message receiving end.
[0070] In this embodiment of the application, the switching service cluster can send the first message to the first message receiving end based on the first address information.
[0071] The message exchange method of this application embodiment pulls at least one first message from a first message middleware through an exchange service cluster. The first message is routed to the first message middleware by the exchange service cluster after receiving a first message sent by a first message sender. For any first message, it is parsed to obtain a first transaction keyword. The first transaction keyword indicates the service to which the first message belongs. Based on the first transaction keyword, the first address information of the first message receiver is determined. Based on the first address information, the first message is sent to the first message receiver. Therefore, message exchange between the message sender and the message receiver can be achieved through an exchange service cluster. During message transmission, it can be based on network protocols (such as HTTP, TCP, RPC, etc.) without integrating an SDK between the message sender and the message receiver, reducing the intrusion into the application system's code. Furthermore, the message sender and receiver do not need to concern themselves with technical parameters such as message topic. The message sender only needs to send the message to the exchange service cluster, which will then route the message to the corresponding topic based on the transaction keywords in the message. This reduces the code complexity and ease of use on both the message sender and receiver sides.
[0072] To clearly illustrate how the exchange service cluster routes the first message to the first topic of the first message middleware in any embodiment of this application, this application also proposes a message exchange method.
[0073] Figure 2 This is a flowchart illustrating another message exchange method provided in an embodiment of this application.
[0074] like Figure 2 As shown, in Figure 1 Based on the illustrated embodiment, the exchange service cluster (or the target exchange service in the exchange service cluster) can route the first message to the first message middleware through the following steps:
[0075] Step S201: Receive a first message sent by at least one first message sender.
[0076] The number of first message senders can be one or more, and this application does not limit this.
[0077] In this embodiment of the application, the exchange service cluster (or the target exchange service in the exchange service cluster) can receive a first message sent by at least one first message sender.
[0078] As one possible implementation, the first message sender can communicate directly with the target exchange service. In this case, the target exchange service can obtain the first message in the following ways:
[0079] 1. The first message sending end can set or configure the address information of at least one exchange service in the exchange service cluster;
[0080] 2. Before sending the first message, the first message sender may select a target exchange service from at least one exchange service. For example, it may randomly select a target exchange service from at least one exchange service, or it may select the target exchange service with the most recent communication from at least one exchange service, or it may select a target exchange service sequentially from at least one exchange service (for example, if the first message sender last or previously used the Nth exchange service to send a message, then the N+1th exchange service can be used as the target exchange service this time), etc. This application does not impose any limitations on this.
[0081] 3. The first message sender can send the first message to the target exchange service based on the second address information of the target exchange service.
[0082] Correspondingly, the target exchange service can obtain the first message sent by the first message sender.
[0083] As another possible implementation, the first message sender can communicate indirectly with the target exchange service. In this case, the target exchange service can obtain the first message in the following ways:
[0084] 1. The target switching service can receive scheduling information sent by the scheduler in the switching service cluster.
[0085] The scheduling information is generated and sent to the target switching service in the following manner: After receiving a first message from any first message sender, the scheduler determines the target switching service from each switching service based on the load information and status information of each switching service in the switching service cluster, generates scheduling information based on the first message sent by the first message sender, and sends the scheduling information to the target switching service.
[0086] In this embodiment, the status information may include an available status and an unavailable status. For example, the status information of each switching service can be determined using a heartbeat detection algorithm. Specifically, the scheduler can send a data packet for heartbeat detection to each switching service in the switching service cluster. If the scheduler receives a heartbeat response from each switching service in response to the data packet, the scheduler can determine that the status information of each switching service is available. Conversely, if a switching service does not receive a heartbeat response from a certain switching service, it can determine that the status information of that switching service is unavailable.
[0087] In the embodiments of this application, the load information of the switching service can be determined based on the resource (such as CPU, memory and other resources) usage indicators of the switching service. For example, the higher the resource usage indicators (such as the higher the CPU utilization rate and the higher the memory utilization rate), the higher the load of the switching service, and vice versa.
[0088] In this embodiment, the scheduler can determine the target weight of each switching service based on its status and load information, and then determine the target switching service with the highest target weight from among all the switching services. Furthermore, the scheduler can generate scheduling information based on the first message sent by the first message sender and send the scheduling information to the target switching service. Correspondingly, the target switching service can receive the scheduling information.
[0089] As one possible implementation, the target weight of any exchange service can be calculated as follows: A first weight is determined based on the status information of the exchange service, wherein the first weight of an exchange service in an available state is higher than the first weight of an exchange service in an unavailable state; a second weight is determined based on the load information of the exchange service, wherein the second weight is negatively correlated with the load information, i.e., the higher the load, the lower the second weight, and vice versa; the target weight of the exchange service is determined based on the first and second weights.
[0090] As an example, the target weight can be calculated as follows: the sum, mean, and weighted sum of the first and second weights of the exchange service can be used as the target weight of the exchange service.
[0091] As another example, the target weight can be calculated as follows: obtain the hardware performance indicators and response latency (or processing latency, transmission latency) of the switching service, and determine the third weight of the switching service based on the hardware performance indicators and response latency. The third weight is negatively correlated with the response latency (i.e., the shorter the response latency, the higher the third weight, and vice versa). Furthermore, the third weight is positively correlated with the hardware performance indicators (i.e., the lower the hardware performance indicators, the lower the third weight, and vice versa).
[0092] Therefore, in this disclosure, the target weight of the exchange service can be determined based on the first weight, the second weight, and the third weight.
[0093] For example, one of the first weight, second weight, and third weight of the exchange service can be used as the target weight of the exchange service.
[0094] For example, the target weight of the exchange service can be determined based on two of the first, second, and third weights. For instance, the sum of two of these weights, the average of two of these weights, or the weighted sum of two of these weights can be used as the target weight of the exchange service.
[0095] For example, the target weight of an exchange service can be determined simultaneously based on its first, second, and third weights. For instance, the sum, mean, or weighted sum of the first, second, and third weights can be used as the target weight of the exchange service.
[0096] 2. The target exchange service can obtain the first message from the scheduling information.
[0097] In this embodiment of the application, the target switching service can extract the first message from the scheduling information.
[0098] Therefore, the first message can be sent to the target exchange service in the exchange service cluster through different methods, which can improve the flexibility and applicability of the method.
[0099] Step S202: For any first message, parse the first message to obtain the first transaction keyword.
[0100] The first transaction keyword is used to indicate the service to which the arbitrary first message belongs.
[0101] In this embodiment of the application, for any first message, the exchange service cluster (or the target exchange service in the exchange service cluster) can parse the first message to obtain the first transaction keyword in the first message.
[0102] Step S203: Query the first topic and first identifier information that have a mapping relationship with the first transaction keyword.
[0103] In this embodiment of the application, the first identification information is used to uniquely identify the first message middleware. For example, the first identification information can be the name of the first message middleware.
[0104] In this embodiment of the application, the exchange service cluster (or the target exchange service in the exchange service cluster) can query the first topic and the first identifier information that have a mapping relationship with the first transaction keyword.
[0105] As one possible implementation, different mapping relationships (referred to as the first mapping relationship in this application) between transaction keywords, message middleware identification information, and topics (or message topics) can be pre-configured on each exchange service side in the exchange service cluster. For example, each exchange service (including the target exchange service) can receive configuration instructions triggered by relevant personnel, configure different first mapping relationships between transaction keywords, topics, and message middleware identification information according to the configuration instructions, and store the first mapping relationship.
[0106] Therefore, in this application, the target exchange service can query the first mapping relationship based on the first transaction keyword to obtain the first topic and first identification information that have a mapping relationship with the first transaction keyword.
[0107] Therefore, by querying, the message middleware and topic information to which the first message is to be routed can be determined. This operation is simple and easy to implement, and can improve the processing efficiency of the exchange service cluster (or the target exchange service in the exchange service cluster) and improve message exchange efficiency.
[0108] Step S204: Send the arbitrary first message to the first topic in the first message middleware; wherein the first message middleware is at least one message middleware that matches the first identification information.
[0109] In this embodiment of the application, the exchange service cluster (or the target exchange service in the exchange service cluster) can send or route the first message to the first topic in the first message middleware.
[0110] In the message exchange method of this application embodiment, the message sender does not need to pay attention to technical parameters such as message topic. The message sender only needs to send the message to the exchange service cluster. The exchange service cluster routes the message to the corresponding topic according to the transaction keyword in the message, which can reduce the code complexity and usage difficulty of the message sender.
[0111] To clearly illustrate any of the above embodiments, this application also proposes a message exchange method.
[0112] Figure 3 This is a flowchart illustrating another message exchange method provided in an embodiment of this application.
[0113] like Figure 3 As shown, in Figure 1 Based on the illustrated embodiment, the exchange service cluster (or the target exchange service in the exchange service cluster) can route the first message to the first topic of the first message middleware through the following steps:
[0114] Step S301: Receive a first message sent by at least one first message sender.
[0115] Step S302: For any first message, parse the first message to obtain the first transaction keyword and identity authentication information.
[0116] The explanation of steps S301 to S302 can be found in the relevant description in any embodiment of this application, and will not be repeated here.
[0117] In this embodiment of the application, the first message may include not only the first transaction keyword, but also identity authentication information, wherein the identity authentication information may include information used for identity authentication or authorization, such as face authentication information, fingerprint authentication information, and password authentication information.
[0118] Step S303: Based on the identity authentication information, authenticate the identity of the first message sender that sent the arbitrary first message.
[0119] In this embodiment of the application, in order to ensure the security of the business system, not all message messages sent by any message sender can be routed to the message middleware. Instead, only message messages sent by message senders that have passed authentication can be routed to the message middleware.
[0120] Specifically, for any given first message, the exchange service cluster (or the target exchange service within the exchange service cluster) can authenticate the first message sender by using the authentication information in the first message. For example, the permission information (or authentication information) of each authorized message sender can be pre-stored. The exchange service cluster (or the target exchange service within the exchange service cluster) can match the authentication information in the first message with the permission information (or authentication information) of each message sender. If the authentication information in the first message matches one of the permission information (or authentication information), it can be determined that the first message sender that sent the first message has been authenticated. If the authentication information in the first message does not match any of the permission information (or authentication information), it can be determined that the first message sender that sent the first message has failed authentication.
[0121] Step S304: If the authentication of the first message sender fails, the first message is discarded.
[0122] In this embodiment of the application, if the authentication of the first message sender fails when sending the first message, the first message can be discarded.
[0123] Step S305: Query the first topic and first identifier information that have a mapping relationship with the first transaction keyword.
[0124] In this embodiment of the application, when the authentication of the first message sender that sends the first message is successful, the first topic and first identifier information that have a mapping relationship with the first transaction keyword in the first message can be queried so as to send or route the first message to the first topic in the first message middleware.
[0125] Step S306: Send any first message to the first topic in the first message middleware; wherein the first message middleware is at least one message middleware that matches the first identification information.
[0126] It should be noted that steps S304 and S305 to S306 are two parallel implementation methods, and in actual application, only one needs to be executed.
[0127] The explanation of steps S305 to S306 can be found in the relevant description in any embodiment of this application, and will not be repeated here.
[0128] The message exchange method in this application embodiment only routes message messages sent by message senders that have passed authentication to the message middleware, while directly discarding message messages sent by message senders that have failed authentication, which can improve the security of the business system.
[0129] In one possible implementation of this application embodiment, to improve the success rate of pushing the first message, in the event of a failure to push the first message, the first message can be rerouted to the first topic in the first message middleware based on a re-push mechanism. The following is in conjunction with... Figure 4 The above process will be explained in detail.
[0130] Figure 4 This is a flowchart illustrating another message exchange method provided in an embodiment of this application.
[0131] like Figure 4 As shown, in Figure 2 or Figure 3 Based on the illustrated embodiment, after sending any first message to the first topic in the first message middleware, the message exchange method may further include the following steps:
[0132] Step S401: Determine whether the first feedback information sent by the first message middleware has been received within the set time period after the first moment.
[0133] The first feedback information is used to indicate that any first message has been received, and the first moment is the time when the arbitrary first message was sent.
[0134] In this application embodiment, for any first message, the exchange service cluster (or the target exchange service in the exchange service cluster) can store the sending time of the first message (referred to as the first moment in this application) after sending the first message, and determine whether the first feedback information of the first message middleware is received within a set period after the first moment. The first feedback information is used to indicate that the first message middleware has received the first message.
[0135] If the exchange service cluster (or the target exchange service in the exchange service cluster) receives the first feedback information sent by the first message middleware, no processing is required. If the exchange service cluster (or the target exchange service in the exchange service cluster) does not receive the first feedback information sent by the first message middleware, subsequent steps can be executed.
[0136] In step S402, if no first feedback information is received, any first message is stored in the database.
[0137] In this embodiment of the application, if the exchange service cluster (or the target exchange service in the exchange service cluster) does not receive the first feedback information sent by the first message middleware, it indicates that the first message push has failed. At this time, the first message can be stored in the database.
[0138] Step S403: In response to the storage time of any first message in the database reaching the set time, resend any first message in the database to the first topic of the first message middleware.
[0139] In this embodiment of the application, the exchange service cluster (or the target exchange service in the exchange service cluster) can determine whether the storage time of the first message in the database has reached the set time. If the storage time of the first message in the database has reached the set time, the first message in the database can be resent to the first topic of the first message middleware. If the storage time of the first message in the database has not reached the set time, it can continue to wait until the storage time reaches the set time, and then resend the first message in the database to the first topic of the first message middleware.
[0140] Optionally, if the first message is successfully re-pushed, it can be deleted from the database to reduce storage overhead. For example, when the exchange service cluster (or the target exchange service in the exchange service cluster) receives the second feedback information sent by the first message middleware, the first message can be deleted from the database, wherein the second feedback information is used to indicate that the first message middleware has received the re-sent first message.
[0141] Optionally, if the second feedback information sent by the first message middleware is not received within a set period after the first message is resent, the exchange service cluster (or the target exchange service in the exchange service cluster) may wait for a set period of time and then resend the first message in the database to the first topic of the first message middleware until the feedback message sent by the first message middleware is received, and then delete the first message in the database.
[0142] The message exchange method of this application embodiment can improve the success rate of pushing the first message by rerouting the first message to the first topic in the first message middleware based on the re-push mechanism when the first message push fails.
[0143] In one possible implementation of this application's embodiments, to improve the success rate of message exchange, in the event of a failure in a certain exchange service, message packets can be transferred to other available exchange nodes. The following is in conjunction with... Figure 5 The above process will be explained in detail.
[0144] Figure 5 This is a flowchart illustrating another message exchange method provided in an embodiment of this application.
[0145] like Figure 5 As shown, this message exchange method is applied to the first exchange service in the exchange service cluster. Figures 1 to 4 Based on any of the illustrated embodiments, the message exchange method may further include the following steps:
[0146] Step S501: Receive transfer information sent by the scheduler; wherein, the transfer information is generated and sent to the first exchange service by the scheduler after receiving the second message sent by the second message sender, generating second scheduling information based on the second message, and sending it to the second exchange service, and detecting a failure in the second exchange service.
[0147] The second message sender and the first message sender can be the same sender or different senders; this application embodiment does not impose any restrictions on this.
[0148] In this embodiment, after receiving the second message from the second message sender, the scheduler can determine the second exchange service from multiple exchange services based on the load and status information of each exchange service in the exchange service cluster. The method for determining the second exchange service is similar to that for determining the target exchange service, and will not be described in detail here. Then, the scheduler can generate second scheduling information based on the second message and send the second scheduling information to the second exchange service.
[0149] In this embodiment, the scheduler can also monitor the second switching service in real time. If a failure is detected in the second switching service, the scheduler can select a new switching service (e.g., the first switching service) from among multiple switching services based on the load and status information of each switching service in the switching service cluster. Then, it can generate transfer information based on the second message and send the transfer message to the first switching service. Correspondingly, the first switching service can receive the transfer information sent by the scheduler.
[0150] Step S502: Obtain the second message from the transfer information and parse the second message to obtain the second transaction keyword.
[0151] The second transaction keyword is used to indicate the business to which the second message belongs.
[0152] In this embodiment of the application, the first exchange service can extract the second message from the transfer message and parse the second message to obtain the second transaction keyword.
[0153] Step S503: Query the second topic and second identifier information that have a mapping relationship with the second transaction keyword.
[0154] In this embodiment of the application, the first exchange service can query the first mapping relationship based on the second transaction keyword to obtain the second topic and second identification information that have a mapping relationship with the second transaction keyword.
[0155] Step S504: The second message is routed to the second topic in the second message middleware; wherein the second message middleware is at least one message middleware that matches the second identification information.
[0156] The second message middleware can be the same or of the same type as the first message middleware, or they can be different or of different types. For example, the first message middleware can be Kafka, and the second message middleware can be RocketMQ, ZeroMQ, etc. In other words, the exchange service cluster can support or interface with multiple types of message middleware, providing one-to-many message subscription and notification functions.
[0157] In this embodiment of the application, the first exchange service can route the second message to the second topic in the second message middleware.
[0158] The message exchange method of this application embodiment can transfer message packets to other available exchange nodes in the event of a failure of a certain exchange service in the exchange service cluster, thereby improving the success rate of message exchange.
[0159] In any embodiment of this application, sending and receiving messages through a message cluster (including at least one message middleware) can achieve asynchronous decoupling between systems (such as the upstream system where the message sender is located and the downstream system where the message receiver is located). The exchange service acts as a bridge for asynchronous transmission between transmission systems. The system architecture for message exchange implemented through the exchange service can be as follows: Figure 6 As shown.
[0160] As an example, let's take the example of the message sender sending a message to the exchange service in the exchange service cluster via the HTTP protocol. The process of message exchange through the exchange service can mainly include the following steps:
[0161] 1. Before use, each exchange service in the exchange service cluster can configure the mapping relationship between transaction keywords, message middleware identification information and topics.
[0162] 2. The upstream system (the message sending application) connects to the HTTP request interface and sends message messages.
[0163] 3. After receiving a message (it should be noted that the same exchange service can receive messages from multiple applications simultaneously), a specific exchange service in the exchange service cluster can parse the message to obtain the transaction key. Generally, the transaction key can be a field in the message that has unique business characteristics, such as the system number.
[0164] 4. The exchange service queries the identification information and topic that are mapped to the transaction keyword, and sends the message to the topic of the message middleware corresponding to the identification information. For example, taking the system number in the message as the transaction keyword, the initialization configuration can map one system number to one message middleware and one message topic.
[0165] 5. After consuming or retrieving message messages from the message middleware, the exchange service can parse out the transaction keywords in the message messages.
[0166] 6. The exchange service can obtain the URL address information mapped to the downstream system (message receiving application) based on the transaction keywords.
[0167] 7. The exchange service can push message packets to downstream systems based on URL address information, and the downstream systems can perform business processing based on the received message packets.
[0168] Therefore, message exchange can be achieved based on HTTP, solving the problems of high code invasiveness and difficulty in modifying upstream and downstream systems.
[0169] It should be noted that in related technologies, asynchronous message passing using message queues (MQ) typically employs SDK integration. However, this application utilizes an exchange service cluster to achieve asynchronous message passing, enabling rapid integration and resolving cross-language issues. Furthermore, when upstream and downstream systems interface with the exchange service, there is no need to concern themselves with technical parameters such as message topics; they only need to send message messages to the exchange service. Upon receiving the message message, the exchange service routes it to the corresponding topic based on relevant parameters (such as transaction keywords) within the message.
[0170] In summary, the message exchange method provided in this application has at least the following advantages:
[0171] 1. Multi-protocol support: During message exchange, message packets can be sent based on multiple network protocols, namely, HTTP, TCP, RPC and other network protocols, and can be adapted to multiple development languages;
[0172] 2. The exchange service cluster is reliable, scalable, and capable of handling massive amounts of messages. Furthermore, the exchange service cluster can support various types of message middleware, providing one-to-many message subscription and notification functions.
[0173] 3. Simple service: Using the exchange service to exchange messages only requires a simple API to quickly and efficiently send and retrieve messages. The learning curve is low and it can be quickly integrated into business operations.
[0174] 4. Stable and reliable: When message push fails, the message can be pushed to the DB (Database) for persistent storage and retried periodically. After the message push is successful, the message stored in the DB can be deleted to reduce storage overhead. In addition, when a single exchange service in the exchange service cluster fails, the message can be automatically migrated to other available exchange services.
[0175] 5. Security: It allows for flexible configuration of more detailed unified authentication, which can more effectively protect business systems and improve their security.
[0176] With the above Figures 1-5 Corresponding to the message exchange method provided in the embodiments, this application also provides a message exchange apparatus. Since the message exchange apparatus provided in the embodiments of this application is similar to the one described above... Figures 1-5 The message exchange method provided in the embodiments corresponds to the message exchange apparatus provided in the embodiments of this application, and will not be described in detail in the embodiments of this application.
[0177] Figure 7 This is a schematic diagram of the structure of a message exchange device provided in an embodiment of this application.
[0178] like Figure 7 As shown, the message exchange device 700 can be applied to an exchange service cluster and includes: a pull module 710, a parsing module 720, a determination module 730, and a sending module 740.
[0179] The pull module 710 is used to pull at least one first message from the first message middleware; wherein the first message is routed to the first message middleware by the exchange service cluster after receiving the first message sent by the first message sender.
[0180] The parsing module 720 is used to parse any first message to obtain a first transaction keyword; wherein the first transaction keyword is used to indicate the service to which any first message belongs.
[0181] The determination module 730 is used to determine the first address information of the first message receiving end based on the first transaction keyword.
[0182] The sending module 740 is used to send any first message to the first message receiving end according to the first address information.
[0183] As one possible implementation, the first message is routed by the exchange service cluster to the first message middleware through the following modules:
[0184] The receiving module is used to receive a first message sent by at least one first message sender.
[0185] The parsing module 720 is also used to: parse any first message to obtain the first transaction keyword.
[0186] The query module is used to query the first topic and first identifier information that have a mapping relationship with the first transaction keyword.
[0187] The sending module 740 is further configured to: send any first message to a first topic in a first message middleware; wherein the first message middleware is at least one message middleware that matches the first identification information.
[0188] As one possible implementation, the message exchange device 700 may further include:
[0189] The configuration module is used to receive configuration instructions and, in response to the configuration instructions, configure the first mapping relationship between transaction keywords, topics, and the identification information of the message middleware;
[0190] The first storage module is used to store the first mapping relationship.
[0191] As one possible implementation, any first message carries authentication information. The parsing module 720 is specifically used to: authenticate the first message sender that sends any first message based on the authentication information; and parse any first message to obtain transaction keywords if the authentication of the first message sender that sends any first message is successful.
[0192] The message exchange device 700 may also include:
[0193] The discard module is used to discard any first message if the authentication of the first message sender fails.
[0194] As one possible implementation, the message exchange device 700 may further include:
[0195] The judgment module is used to determine whether the first feedback information sent by the first message middleware is received within a set period after the first moment; wherein, the first feedback information is used to indicate that any first message has been received, and the first moment is the time when any first message is sent.
[0196] The second storage module is used to store any first message into the database if no first feedback information is received.
[0197] The sending module 740 is also configured to: in response to any first message being stored in the database for a set duration, resend any first message in the database to the first topic of the first message middleware.
[0198] The deletion module is used to delete any first message from the database if it receives second feedback information sent by the first message middleware, wherein the second feedback information is used to indicate that any retransmitted first message has been received.
[0199] As one possible implementation, the first message is routed from the target exchange service in the exchange service cluster to the first message middleware. The first message sender is configured with the address information of at least one exchange service in the exchange service cluster. The first message sender selects the target exchange service from the at least one exchange service and sends the first message to the target exchange service according to the second address information of the target exchange service.
[0200] As one possible implementation, the first message is routed from the target exchange service in the exchange service cluster to the first message middleware. The exchange service cluster also includes a scheduler and a receiving module, specifically used for: receiving scheduling information sent by the scheduler; wherein, the scheduling information is generated by the scheduler after receiving the first message sent by any first message sender, determining the target exchange service from each exchange service according to the load information and status information of each exchange service in the exchange service cluster, generating and sending the first message to the target exchange service based on the first message sent by any first message sender; and obtaining the first message from the scheduling information.
[0201] As one possible implementation, the target exchange service is determined through the following modules:
[0202] The processing module is configured to, for any given switching service, determine a first weight for any given switching service based on the status information of the given switching service; wherein the status information includes an available state and an unavailable state, and the first weight corresponding to the available state is higher than the first weight corresponding to the unavailable state; determine a second weight for any given switching service based on the load information of the given switching service; wherein the second weight is negatively correlated with the load information; determine a target weight for any given switching service based on the first weight and the second weight; and determine a target switching service from among the various switching services based on the target weights of each switching service.
[0203] As one possible implementation, the processing module is specifically used to: obtain the hardware performance indicators and response latency of any switching service; determine the third weight of any switching service based on the hardware performance indicators and response latency, wherein the third weight is negatively correlated with the response latency and positively correlated with the hardware performance indicators; and determine the target weight of any switching service based on the first weight, the second weight, and the third weight.
[0204] As one possible implementation, the message exchange device 700 is applied to the first exchange service in the exchange service cluster. The exchange service cluster also includes a scheduler and a receiving module, which is further used to: receive transfer information sent by the scheduler; wherein, the transfer information is generated by the scheduler based on the second message sent by the second message sender, generates second scheduling information based on the second message, and sends it to the second exchange service after the scheduler detects a failure in the second exchange service.
[0205] The message exchange device 700 may also include:
[0206] The acquisition module is used to obtain the second message from the transfer information.
[0207] The parsing module 720 is also used to: parse the second message to obtain the second transaction key.
[0208] The query module is also used to: query second topics and second identification information that have a mapping relationship with the second transaction keyword.
[0209] The routing module is used to route the second message to a second topic in the second message middleware; wherein the second message middleware is at least one message middleware that matches the second identification information.
[0210] As one possible implementation, the determining module 730 is specifically used to: query the second mapping relationship based on the first transaction keyword to obtain the first address information; wherein the second mapping relationship is used to indicate the correspondence between the transaction keyword and the address information of the message receiving end.
[0211] The message exchange apparatus of this application embodiment pulls at least one first message from a first message middleware through an exchange service cluster. The first message is routed to the first message middleware by the exchange service cluster after receiving a first message sent by a first message sender. For any given first message, it is parsed to obtain a first transaction keyword. The first transaction keyword indicates the service to which the given first message belongs. Based on the first transaction keyword, the first address information of the first message receiver is determined. Based on the first address information, the given first message is sent to the first message receiver. Therefore, message exchange between the message sender and the message receiver can be achieved through an exchange service cluster. During message transmission, it can be based on network protocols (such as HTTP, TCP, RPC, etc.) without integrating an SDK between the message sender and the message receiver, thus reducing the intrusion into the application system's code. Furthermore, the message sender and receiver do not need to concern themselves with technical parameters such as message topic. The message sender only needs to send the message to the exchange service cluster, which will then route the message to the corresponding topic based on the transaction keywords in the message. This reduces the code complexity and ease of use on both the message sender and receiver sides.
[0212] To implement the above embodiments, this application also proposes an electronic device, wherein the electronic device can be any device with computing capabilities, the electronic device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, it implements the message exchange method proposed in any of the foregoing embodiments of this application.
[0213] As an example, Figure 8 This is a schematic diagram of the structure of an electronic device 800 shown in an exemplary embodiment of this application, as follows: Figure 8 As shown, the above-mentioned electronic device 800 may further include:
[0214] The system includes a memory 810 and a processor 820, and a bus 830 connecting different components (including the memory 810 and the processor 820). The memory 810 stores a computer program, and when the processor 820 executes the program, it implements the message exchange method described in the embodiments of this application.
[0215] Bus 830 represents one or more of several bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. Examples of these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnect (PCI) bus.
[0216] Electronic device 800 typically includes a variety of electronic device readable media. These media can be any available media that can be accessed by electronic device 800, including volatile and non-volatile media, removable and non-removable media.
[0217] The memory 810 may also include computer system readable media in the form of volatile memory, such as random access memory (RAM) 840 and / or cache memory 850. The server 800 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 860 may be used to read and write non-removable, non-volatile magnetic media (…). Figure 8 Not shown; usually referred to as a "hard drive"). Although Figure 8 Not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk") and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to bus 830 via one or more data media interfaces. Memory 810 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of the embodiments of this application.
[0218] A program / utility 880 having a set (at least one) of program modules 870 may be stored in, for example, memory 810. Such program modules 870 include—but are not limited to—an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. Program modules 870 typically perform the functions and / or methods described in the embodiments of this application.
[0219] Electronic device 800 can also communicate with one or more external devices 890 (e.g., keyboard, pointing device, display 891, etc.), and with one or more devices that enable a user to interact with electronic device 800, and / or with any device that enables electronic device 800 to communicate with one or more other computing devices (e.g., network card, modem, etc.). This communication can be performed via input / output (I / O) interface 892. Furthermore, electronic device 800 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 893. As shown, network adapter 893 communicates with other modules of electronic device 800 via bus 830. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 800, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0220] The processor 820 performs various functional applications and data processing by running programs stored in the memory 810.
[0221] It should be noted that the implementation process and technical principles of the electronic device in this embodiment are explained in the foregoing description of the message exchange method in the embodiments of this application, and will not be repeated here.
[0222] To implement the above embodiments, this application also proposes a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the message exchange method as proposed in any of the foregoing embodiments of this application.
[0223] To implement the above embodiments, this application also proposes a computer program product that, when the instructions in the computer program product are executed by a processor, performs the message exchange method as proposed in any of the foregoing embodiments of this application.
[0224] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0225] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0226] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.
[0227] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.
[0228] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0229] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.
[0230] Furthermore, the functional units in the various embodiments of this application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
[0231] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of this application.
Claims
1. A message exchange method, characterized in that, Applied to switching service clusters, including: At least one first message is retrieved from the first message middleware; wherein the first message is routed to the first message middleware by the exchange service cluster after receiving the first message sent by the first message sender; For any first message, the first message is parsed to obtain a first transaction keyword; wherein the first transaction keyword is used to indicate the service to which the first message belongs; Based on the first transaction keyword, a second mapping relationship is queried to determine the first address information of the first message receiving end that has a mapping relationship with the first transaction keyword; wherein, the second mapping relationship is pre-configured and is used to indicate the correspondence between the transaction keyword and the address information of the message receiving end; Based on the first address information, any one of the first message messages is sent to the first message receiving end; The first message is routed to the first message middleware by the exchange service cluster through the following steps: Receive at least one first message sent by a first message sender; For any first message, the first message is parsed to obtain the first transaction keyword; Based on the first transaction keyword, a first mapping relationship is queried to determine a first topic and first identification information that have a mapping relationship with the first transaction keyword; wherein, the first mapping relationship is pre-configured and is used to indicate the correspondence between the transaction keyword and the identification information and topic of the message middleware; Send any first message to a first topic in the first message middleware; wherein the first message middleware is at least one message middleware that matches the first identification information.
2. The method according to claim 1, characterized in that, The first message carries authentication information. The step of parsing any first message to obtain a first transaction keyword includes: Based on the identity authentication information, the first message sender that sends the arbitrary first message is authenticated. If the authentication of the first message sender that sends the arbitrary first message is successful, the arbitrary first message is parsed to obtain the first transaction keyword; Accordingly, after authenticating the first message sender that sends the arbitrary first message based on the identity authentication information, the method further includes: If the authentication of the first message sender fails when sending the arbitrary first message, the arbitrary first message is discarded.
3. The method according to claim 1, characterized in that, After sending the arbitrary first message to the first topic in the first message middleware, the method further includes: Determine whether a first feedback message sent by the first message middleware is received within a set time period after the first moment; wherein, the first feedback message is used to indicate that the arbitrary first message has been received, and the first moment is the time when the arbitrary first message was sent; If the first feedback information is not received, then any first message is stored in the database; In response to the storage time of any first message in the database reaching a set time, the any first message in the database is resent to the first topic of the first message middleware; If a second feedback message is received from the first message middleware, then the arbitrary first message is deleted from the database, wherein the second feedback message is used to indicate that the arbitrary first message has been resent.
4. The method according to claim 1, characterized in that, The first message is routed from the target exchange service in the exchange service cluster to the first message middleware. The first message sender is configured with address information of at least one exchange service in the exchange service cluster. The first message is sent by the first message sender to the target exchange service selected from the at least one exchange service, based on the second address information of the target exchange service.
5. The method according to claim 1, characterized in that, The first message is routed from the target exchange service in the exchange service cluster to the first message middleware. The exchange service cluster also includes a scheduler. The receipt of a first message sent by at least one message sender includes: The scheduler receives scheduling information sent by the scheduler; wherein the scheduling information is generated by the scheduler after receiving a first message sent by any first message sender, based on the load information and status information of each exchange service in the exchange service cluster, determining the target exchange service from each exchange service, and generating and sending it to the target exchange service based on the first message sent by any first message sender. Obtain the first message from the scheduling information.
6. The method according to claim 5, characterized in that, The step of determining the target switching service from among the switching services based on the load information and status information of each switching service in the switching service cluster includes: For any exchange service, a first weight is determined based on the status information of the exchange service; wherein the status information includes an available status and an unavailable status, and the first weight corresponding to the available status is higher than the first weight corresponding to the unavailable status. Based on the load information of any of the switching services, a second weight is determined for each of the switching services; wherein the second weight is negatively correlated with the load information. The target weight of any exchange service is determined based on the first weight and the second weight. The target exchange service is determined from the various exchange services based on the target weight of each of the exchange services.
7. The method according to claim 6, characterized in that, Determining the target weight of any exchange service based on the first weight and the second weight includes: Obtain the hardware performance metrics and response latency of any of the aforementioned switching services; Based on the hardware performance metrics and the response latency, a third weight is determined for any switching service, wherein the third weight is negatively correlated with the response latency and positively correlated with the hardware performance metrics; The target weight of any exchange service is determined based on the first weight, the second weight, and the third weight.
8. The method according to any one of claims 1-7, characterized in that, The method is applied to a first switching service in the switching service cluster, the switching service cluster further includes a scheduler, and the method further includes: The scheduler receives transfer information sent by the scheduler; wherein the transfer information is generated and sent to the first exchange service by the scheduler after receiving a second message from the second message sender, generating second scheduling information based on the second message, and sending it to the second exchange service, and then detecting a failure in the second exchange service. The second message is obtained from the transfer information, and the second message is parsed to obtain the second transaction keyword; Query the second topic and second identifier information that have a mapping relationship with the second transaction keyword; The second message is routed to a second topic in a second message middleware; wherein the second message middleware is at least one message middleware that matches the second identification information.
9. A message exchange device, characterized in that, Applied to switching service clusters, including: The pull module is used to pull at least one first message from the first message middleware; wherein the first message is routed to the first message middleware by the exchange service cluster after receiving the first message sent by the first message sender; The parsing module is used to parse any first message to obtain a first transaction keyword; wherein the first transaction keyword is used to indicate the service to which the first message belongs; The determining module is used to query a second mapping relationship based on the first transaction keyword to determine the first address information of the first message receiving end that has a mapping relationship with the first transaction keyword; wherein, the second mapping relationship is pre-configured and is used to indicate the correspondence between the transaction keyword and the address information of the message receiving end; The sending module is used to send any of the first message messages to the first message receiving end according to the first address information; The first message is routed from the exchange service cluster to the first message middleware via the following modules: The receiving module is used to receive at least one first message sent by a first message sender; The parsing module is further configured to: parse any first message to obtain a first transaction keyword; The query module is used to query a first mapping relationship based on the first transaction keyword to determine a first topic and first identification information that have a mapping relationship with the first transaction keyword; wherein, the first mapping relationship is pre-configured and is used to indicate the correspondence between the transaction keyword and the identification information and topic of the message middleware; The sending module is further configured to: send any first message to a first topic in the first message middleware; wherein the first message middleware is at least one message middleware that matches the first identification information.
Citation Information
Patent Citations
Message middleware multi-target routing and copying technology based on rule
CN103747035A
Message transmission method and device, computer equipment and storage medium
CN109933439A
Message transmission test method and device, electronic equipment and storage medium
CN111740872A