Message queue management method and electronic device implemented based on multiple computer rooms

By directly writing to the local room queue in a multi-computer room environment and determining the target room using configuration metadata, the problem of cross-computer room transmission delay is solved, and efficient message queue management is achieved, which is suitable for real-time requirements of complex business scenarios.

CN112052104BActive Publication Date: 2025-07-29ZHANGYUE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202010905108.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-01
Publication Date
2025-07-29
Estimated Expiration
2040-09-01

AI Technical Summary

Technical Problem

In the transmission of messages across computer rooms, the prior art is difficult to effectively solve the problem of how the message production end determines the number of message consumer ends and its computer room in advance, and the data transmission delay caused by network reasons cannot be applied in business scenarios with high real-time requirements.

Method used

In a multi-computer room environment, the message production end directly writes the message data to the message queue of the local room, and configures the metadata to store the queue of the computer room mapping relationship. The consumer end determines the target computer room and message queue based on the configuration metadata, and obtains data asynchronously for consumption, avoiding transmission across computer rooms.

Benefits of technology

It improves the real-time nature of message production, avoids delays caused by network jitter, and is suitable for business scenarios with high real-time requirements, simplifying the cumbersome operations of the number of consumer ends and computer room determination.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112052104B_ABST
    Figure CN112052104B_ABST
Patent Text Reader

Abstract

The present invention discloses a management method and an electronic device for a message queue implemented based on multiple computer rooms. The method includes: a first computer room among multiple computer rooms responds to a message writing request triggered by a message production end corresponding to the first computer room, writes the message data included in the message writing request into the message queue corresponding to the first computer room, and stores the queue-computer room mapping relationship between the message queue corresponding to the first computer room and the first computer room into the configuration metadata; a second computer room among multiple computer rooms responds to a message consumption request triggered by a message consumption end corresponding to the second computer room, determines the message queue corresponding to the message consumption request as the target message queue, determines the computer room where the target message queue is located as the target computer room according to the configuration metadata, and transmits the message data of the target message queue in the target computer room to the second computer room. This method avoids the latency problem caused by cross-computer room message production and is applicable to business scenarios with high real-time requirements.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computers, and particularly to a management method and an electronic device for a message queue implemented based on multiple computer rooms. Background Art

[0002] A message queue is used to store data to be transmitted into a queue. Among them, the service end that writes data into the queue is called the message producer end, and the service end that reads data from the queue is called the message consumer end. Through the message queue, orderly storage of multiple message data can be achieved, which is conducive to realizing reliable transmission of messages.

[0003] With the increasing complexity of business scenarios, many business systems include multiple computer rooms. In the implementation solution across computer rooms, the message producer end needs to pre-determine the computer room where the message consumer end is located. Moreover, when the message consumer end and the message producer end are located in different computer rooms respectively, in order to ensure smooth consumption of the message consumer end, it is necessary to transmit the message data produced by the message producer end in the first computer room to the second computer room where the message consumer end is located for storage.

[0004] However, in the process of implementing the present invention, the inventors found that the above-mentioned solutions in the prior art have at least the following defects: on the one hand, in complex business scenarios, one message producer end may correspond to multiple message consumer ends, and how to pre-determine the number of message consumer ends and the computer rooms where each message consumer end is located has become a technical problem to be solved urgently; on the other hand, the message producer end needs to transmit the generated message data across computer rooms to the computer room where the message consumer end is located. However, due to line reasons or network reasons between the two computer rooms, defects such as data transmission delay may occur, which is not applicable in business scenarios with high real-time requirements. Summary of the Invention

[0005] In view of the above problems, the present invention is proposed to provide a management method and an electronic device for a message queue implemented based on multiple computer rooms that overcome the above problems or at least partially solve the above problems.

[0006] According to one aspect of the present invention, there is provided a management method for a message queue implemented based on multiple computer rooms, including:

[0007] In response to a message writing request triggered by a message producer end corresponding to the first computer room among multiple computer rooms, the first computer room writes the message data included in the message writing request into a message queue corresponding to the first computer room, and stores the queue computer room mapping relationship between the message queue corresponding to the first computer room and the first computer room into configuration metadata;

[0008] In response to a message consumption request triggered by a message consumer corresponding to a second computer room among multiple computer rooms, the second computer room determines a message queue corresponding to the message consumption request as a target message queue, determines the computer room where the target message queue is located as a target computer room according to the configuration metadata, and transfers message data of the target message queue in the target computer room to the second computer room for consumption by the message consumer.

[0009] According to another aspect of the present invention, there is provided an electronic device, including: a processor, a memory, a communication interface, and a communication bus, and the processor, the memory, and the communication interface complete communication with each other through the communication bus;

[0010] The memory is used to store at least one executable instruction, and the executable instruction causes the processor to perform the following operations:

[0011] In response to a message writing request triggered by a message producer corresponding to a first computer room among multiple computer rooms, the first computer room writes the message data included in the message writing request into a message queue corresponding to the first computer room, and stores the queue-computer room mapping relationship between the message queue corresponding to the first computer room and the first computer room into the configuration metadata;

[0012] In response to a message consumption request triggered by a message consumer corresponding to a second computer room among multiple computer rooms, the second computer room determines a message queue corresponding to the message consumption request as a target message queue, determines the computer room where the target message queue is located as a target computer room according to the configuration metadata, and transfers message data of the target message queue in the target computer room to the second computer room for consumption by the message consumer.

[0013] According to still another aspect of the present invention, there is provided a computer storage medium, and at least one executable instruction is stored in the storage medium, and the executable instruction causes the processor to perform the following operations:

[0014] In response to a message writing request triggered by a message producer corresponding to a first computer room among multiple computer rooms, the first computer room writes the message data included in the message writing request into a message queue corresponding to the first computer room, and stores the queue-computer room mapping relationship between the message queue corresponding to the first computer room and the first computer room into the configuration metadata;

[0015] In response to a message consumption request triggered by a message consumer corresponding to a second computer room among multiple computer rooms, the second computer room determines a message queue corresponding to the message consumption request as a target message queue, determines the computer room where the target message queue is located as a target computer room according to the configuration metadata, and transfers message data of the target message queue in the target computer room to the second computer room for consumption by the message consumer.

[0016] In the method and electronic device for managing a message queue implemented based on multiple computer rooms provided by the present invention, message data generated by a message producer is directly written into the local computer room where the message producer is located, without determining the computer room where the message consumer is located, and no cross-computer room data transfer operation needs to be performed during the message production process, thereby improving the real-time performance of the operation and avoiding the impact caused by network jitter; in addition, when the message consumer consumes data, the computer room where the message queue to be consumed is located is determined according to the queue-computer room mapping relationship included in the pre-recorded configuration metadata, so as to asynchronously obtain data for consumption. It can be seen that this method avoids the cumbersome operation of pre-determining the number of consumers and their locations in the computer room, and avoids the delay problem caused by cross-computer room message production, and can be applied to business scenarios with high real-time requirements.

[0017] The above description is only an overview of the technical solution of the present invention. In order to be able to understand the technical means of the present invention more clearly, it can be implemented according to the content of the specification. And in order to make the above and other purposes, features and advantages of the present invention more obvious and understandable, the following specifically illustrates the embodiments of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] By reading the detailed description of the preferred embodiments below, various other advantages and benefits will become clear to those of ordinary skill in the art. The drawings are only for the purpose of showing the preferred embodiments and are not considered to be a limitation of the present invention. And throughout the drawings, the same reference numerals are used to represent the same components. In the drawings:

[0019] Figure 1 Shows a flowchart of a method for managing a message queue implemented based on multiple computer rooms provided by an embodiment of the present invention;

[0020] Figure 2 Shows a flowchart of a method for managing a message queue implemented based on multiple computer rooms provided by another embodiment of the present invention;

[0021] Figure 3 Shows a schematic structural diagram of an electronic device according to another embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0022] Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided so that the present disclosure can be more thoroughly understood and the scope of the present disclosure can be fully communicated to those skilled in the art.

[0023] Embodiment 1

[0024] Figure 1 The flowchart of the management method of the message queue implemented based on multiple computer rooms provided by an embodiment of the present invention is shown. As Figure 1 shown, the method includes the following steps:

[0025] Step S110: In response to a message writing request triggered by a message producer corresponding to the first computer room among multiple computer rooms, the first computer room writes the message data included in the message writing request into the message queue corresponding to the first computer room, and stores the message queue corresponding to the first computer room and the queue-computer room mapping relationship between the first computer room into the configuration metadata.

[0026] Among them, the multiple computer rooms in this embodiment refer to at least two computer rooms. Correspondingly, the first computer room among the multiple computer rooms can be any one of the multiple computer rooms. Specifically, each computer room corresponds to one or more services. Among them, one service may correspond to one project or one application, or may also correspond to a function in an application. The present invention does not limit this. The services corresponding to each computer room may be a message producer, a message consumer, or may also be a message producer and a message consumer at the same time, depending on the business function currently executed by the service.

[0027] When a service is used to generate message data, the service acts as a message producer and sends a message writing request to the computer room corresponding to the service. In this embodiment, the computer room corresponding to the service that sends the message writing request is used as the first computer room. Substantially, for any computer room, as long as the service corresponding to the computer room triggers a message writing request as a message producer, the computer room is called the first computer room.

[0028] After receiving the message writing request sent by the service of its own computer room, the first computer room writes the message data included in the message writing request into the message queue corresponding to the first computer room (i.e., its own computer room), and stores the message queue corresponding to the first computer room and the queue-computer room mapping relationship between the first computer room into the configuration metadata. Thus, it can be seen that after receiving a message writing request, any computer room does not need to determine the corresponding message consumer, and directly writes the received message data into the message queue corresponding to its own computer room. This method does not require a cross-computer room network transmission process, so it can greatly improve the writing efficiency.

[0029] Among them, the message queue corresponding to the first computer room refers to the message queue stored in the storage space corresponding to the first computer room. Among them, the storage space corresponding to the first computer room can be the local storage space of the first computer room or the storage space in the database connected to the first computer room. Specifically, the message queue corresponding to the first computer room can be maintained by the queue server in the first computer room.

[0030] In addition, the queue-computer room mapping relationship is used to store the corresponding relationship between the message queue produced by the message production end and the computer room where the message queue is located. Of course, the queue-computer room mapping relationship can further store the ternary corresponding relationship among the message production end, the message queue produced by the message production end, and the computer room where the message queue is located. The configuration metadata is used to uniformly store the above-mentioned queue-computer room mapping relationship. Among them, the configuration metadata can be uniformly stored in the configuration servers respectively connected to each computer room, or can be respectively stored in each computer room and shared by each computer room.

[0031] Step S120: In response to a message consumption request triggered by a message consumer corresponding to the second computer room among multiple computer rooms, the second computer room determines the message queue corresponding to the message consumption request as the target message queue, determines the computer room where the target message queue is located as the target computer room according to the configuration metadata, and transfers the message data of the target message queue in the target computer room to the second computer room for the message consumer to consume.

[0032] Specifically, the second computer room among multiple computer rooms can be any one of the multiple computer rooms. Since each computer room corresponds to one or more services respectively, when a service is used to consume message data, the service acts as a message consumer and sends a message consumption request to the computer room corresponding to the service. In this embodiment, the computer room corresponding to the service that sends the message consumption request is used as the second computer room. Substantially, for any computer room, as long as the service corresponding to the computer room triggers a message consumption request, the computer room is called the second computer room.

[0033] After the second computer room receives the message consumption request sent by the service in this computer room, first, it determines the message queue corresponding to the message consumption request and determines it as the target message queue; then, it queries the configuration metadata and determines the computer room where the target message queue is located according to the query result, and determines this computer room as the target computer room; finally, it transfers the message data of the target message queue in the target computer room to the second computer room for the message consumer to consume locally. Thus, it can be seen that after any computer room receives a message consumption request, it determines the computer room where the message queue to be consumed is located according to the configuration metadata, and then obtains the data from this computer room.

[0034] Among them, the target computer room can be any one of multiple computer rooms. For example, the target computer room may be the above-mentioned first computer room, or it may be a third computer room different from the first and second computer rooms. Of course, it may also be the second computer room itself. In this case, the message data can be directly obtained inside this computer room. In short, the present invention does not limit the specific locations of the target message queue and the target computer room, which entirely depends on the actual business requirements. In addition, when transmitting the message data of the target message queue in the target computer room to the second computer room, it can be transmitted through the data dedicated line between the two computer rooms.

[0035] In addition, it should be noted that the above-mentioned first computer room and second computer room can be different computer rooms or the same computer room, and the present invention does not make any limitations in this regard.

[0036] Thus, in the message queue management method based on multiple computer rooms provided by the present invention, the message data generated by the message producer is directly written into the local computer room where the message producer is located, without the need to determine the computer room where the message consumer is located, and there is no need to perform cross-computer-room data transmission operations during the message production process, thereby improving the real-time performance of the operation and avoiding the influence caused by network jitter. In addition, when the message consumer consumes data, it determines the computer room where the message queue to be consumed is located according to the queue-computer-room mapping relationship included in the pre-recorded configuration metadata, so as to asynchronously obtain data for consumption. It can be seen that this method avoids the cumbersome operations of pre-determining the number of consumers and their locations in the computer room, and also avoids the delay problem caused by cross-computer-room message production, and can be applied to business scenarios with high real-time requirements.

[0037] Embodiment 2

[0038] Figure 2 shows a flowchart of a message queue management method based on multiple computer rooms provided by another embodiment of the present invention. As Figure 2 shown, the method includes the following steps:

[0039] Step S200: Set up proxy modules in each computer room respectively, and the proxy modules in each computer room jointly maintain the configuration metadata.

[0040] Specifically, a proxy module is respectively set up in each of multiple computer rooms. The proxy modules within each computer room are used to process message writing requests and message consumption requests from various services, and maintain configuration metadata based on the message writing requests and message consumption requests. For example, the message writing request contains the three-way correspondence of the message producer, the message queue to be written, and the computer room where the message producer is located; the message consumption request contains the three-way correspondence of the message consumer, the message queue to be consumed, and the computer room where the message consumer is located. It can be seen that during the process of processing the message writing requests and message consumption requests, the proxy modules in each computer room can establish and maintain a three-way relationship group composed of services (including message producers and message consumers), message queues, and computer rooms, thereby constituting configuration metadata for subsequent processing.

[0041] In specific implementation, the proxy modules in each computer room are used to implement the processing of message writing requests and message consumption requests sent by various services based on an extended protocol, and obtain and dynamically maintain the above-mentioned three-way relationship group by parsing the message content during the processing.

[0042] It should be noted that this step is an optional step. In other embodiments of the present invention, the proxy module may not be set up, and relevant functions such as maintaining configuration metadata may be implemented by modifying the internal source code of the computer room. The present invention does not limit the specific implementation details.

[0043] Step S210: In response to a message writing request triggered by a message producer corresponding to the first computer room among multiple computer rooms, the first computer room writes the message data included in the message writing request into the message queue corresponding to the first computer room, and stores the queue-computer room mapping relationship between the message queue corresponding to the first computer room and the first computer room into the configuration metadata.

[0044] Among them, the multiple computer rooms in this embodiment refer to at least two computer rooms. Correspondingly, the first computer room among the multiple computer rooms can be any one of the multiple computer rooms. Specifically, each computer room corresponds to one or more services. Among them, one service may correspond to a project or an application, or may correspond to a function in an application. The present invention does not limit this. The services corresponding to each computer room may be message producers, message consumers, or may simultaneously serve as message producers and message consumers, specifically depending on the business function currently executed by the service.

[0045] When a service is used to generate message data, the service, as a message producer, sends a message write request to the computer room corresponding to the service. In this embodiment, the computer room corresponding to the service that sends the message write request is regarded as the first computer room. In essence, for any computer room, as long as the service corresponding to the computer room triggers a message write request as a message producer, the computer room is called the first computer room. After receiving the message write request sent by the service in its own computer room, the first computer room writes the message data included in the message write request into the message queue corresponding to the first computer room (i.e., its own computer room), and stores the message queue corresponding to the first computer room and the queue-computer room mapping relationship between the first computer room into the configuration metadata. Thus, it can be seen that after receiving a message write request, any computer room can directly write the received message data into the message queue corresponding to its own computer room without determining the corresponding message consumer. This method does not require a cross-computer room network transmission process, so it can greatly improve the write efficiency. Among them, the message queue corresponding to the first computer room refers to the message queue stored in the storage space corresponding to the first computer room. The storage space corresponding to the first computer room can be the local storage space in the first computer room or the storage space in the database connected to the first computer room. Specifically, the message queue corresponding to the first computer room can be maintained by the queue server in the first computer room.

[0046] In addition, the queue-computer room mapping relationship is used to store the corresponding relationship between the message queue produced by the message producer and the computer room where the message queue is located. Of course, the queue-computer room mapping relationship can further store the ternary corresponding relationship among the message producer, the message queue produced by the message producer, and the computer room where the message queue is located. The configuration metadata is used to uniformly store the above-mentioned queue-computer room mapping relationship.

[0047] Among them, the configuration metadata can be stored in various ways: for example, in an optional implementation, the configuration metadata from each computer room is uniformly stored in the configuration servers respectively connected to each computer room, and the configuration servers uniformly maintain the configuration metadata from each computer room. Correspondingly, the configuration servers can implement functions such as deduplication and verification for the configuration metadata to ensure the accuracy of the configuration metadata. Another example is that in another optional implementation, the configuration metadata generated by each computer room is stored separately in each computer room and shared by each computer room. Among them, in order to facilitate the sharing of the configuration metadata between each computer room, one computer room can request the configuration metadata related to the currently received message consumption request from other computer rooms through a broadcast mechanism.

[0048] Among them, on the premise that a proxy module is set in each computer room, this step is responsible for being executed by the proxy module in the first computer room. Specifically, the proxy module is responsible for parsing the received message writing request, constructing a triple relationship group according to the message producer identifier (i.e., service identifier), the message queue identifier to be written, and the computer room identifier of this computer room included in the parsing result, so as to obtain the corresponding configuration metadata according to the triple relationship group.

[0049] Among them, for the convenience of communication, in this embodiment, each service sends various request data through the computer room where the service is located. Correspondingly, the message writing requests received by each computer room are obviously sent by the services from this computer room. Therefore, when constructing the triple relationship group corresponding to the message writing request, the computer room identifier included in the triple relationship group is the identifier of this computer room, and the message queue is also the message queue of this computer room.

[0050] Step S220: The second computer room among multiple computer rooms responds to the message consumption request triggered by the message consumer corresponding to the second computer room, determines the message queue corresponding to the message consumption request as the target message queue, and determines the computer room where the target message queue is located as the target computer room according to the configuration metadata.

[0051] Specifically, the second computer room among multiple computer rooms can be any one of the multiple computer rooms. Since each computer room corresponds to one or more services respectively, when a service is used to consume message data, the service, as a message consumer, sends a message consumption request to the computer room corresponding to the service. In this embodiment, the computer room corresponding to the service that sends the message consumption request is used as the second computer room. Substantially, for any computer room, as long as the service corresponding to the computer room triggers a message consumption request, the computer room is called the second computer room.

[0052] Among them, on the premise that a proxy module is set in each computer room, this step is responsible for being executed by the proxy module in the second computer room. Specifically, after the proxy module in the second computer room receives the message consumption request sent by the service in this computer room, it performs the following operations:

[0053] First, parse the message consumption request to determine the message queue corresponding to the message consumption request (i.e., the message queue to be consumed), and determine it as the target message queue. Then, query the configuration metadata, and determine the computer room where the target message queue is located according to the query result, and determine this computer room as the target computer room. Since the corresponding relationship between the message queue and the computer room where it is located is recorded in the configuration metadata, based on the configuration metadata, the computer room where the target message queue is located, that is, the target computer room, can be accurately determined.

[0054] Among them, the target computer room can be any computer room among multiple computer rooms. For example, the target computer room may be the first computer room mentioned above, or it may be a third computer room different from the first computer room and the second computer room. Of course, it may also be the second computer room itself (in this case, the message data can be directly obtained inside the second computer room). In short, the present invention does not limit the specific locations of the target message queue and the target computer room, which completely depends on the actual business requirements.

[0055] Step S230: Transmit the message data of the target message queue in the target computer room to the second computer room for consumption by the message consumer.

[0056] Specifically, after determining the target computer room, the message data of the target message queue in the target computer room is transmitted to the second computer room for the message consumer to consume locally. Thus, after any computer room receives a message consumption request, it determines the computer room where the message queue to be consumed is located according to the configuration metadata, and then obtains the data from that computer room.

[0057] In specific implementation, the message data of the target message queue in the target computer room is transmitted to the second computer room through the computer room dedicated line between the target computer room and the second computer room. Among them, any two computer rooms communicate with each other through the computer room dedicated line. Therefore, the message data of the target message queue in the target computer room can be transmitted to the second computer room through the computer room dedicated line between the target computer room and the second computer room.

[0058] Specifically, the data transmission operation can be triggered by the second computer room sending a transmission request to the target computer room. Correspondingly, the target computer room returns the message data in the message queue to the second computer room according to the identifier of the message queue included in the received transmission request.

[0059] Optionally, in this embodiment, in order to improve the transmission efficiency of the message data, synchronization modules are respectively set in each computer room. The synchronization modules in each computer room communicate with the proxy module in the local computer room and can perform data synchronization operations under the control of the proxy module. Correspondingly, when transmitting the message data of the target message queue in the target computer room to the second computer room, the message data of the target message queue in the target computer room is transmitted to the second computer room through the synchronization module in the target computer room.

[0060] In addition, during the implementation of the present invention, the inventor found that there is usually a fixed mapping relationship between the message consumer and the message queue to be consumed. For example, both Service A and Service B act as consumers to consume the messages in the first message queue. As long as the first message queue is updated, Service A and Service B will trigger message consumption requests as consumers. In addition, on the premise that Service A and Service B have not undergone a data center migration, the data centers where Service A and Service B are located are also fixed. For example, Service A is in Data Center 1 and Service B is in Data Center 2. If the first message queue is located in Data Center 3, the content of the first message queue in Data Center 3 needs to be transmitted to Data Center 1 and Data Center 2 respectively. To prevent delays during subsequent transmission, based on the above corresponding relationship, when it is detected that the first message queue in Data Center 3 is updated, the updated first message queue is synchronized to Data Center 1 and Data Center 2 respectively to facilitate subsequent consumption.

[0061] To achieve the above object, in this embodiment, it is necessary to determine the corresponding relationship between each consumer and the message queue to be consumed by it. For this purpose, whenever the second data center in multiple data centers responds to a message consumption request triggered by a message consumer corresponding to the second data center, a set of triple relationship groups are further generated according to the message consumer corresponding to the message consumption request, the target message queue corresponding to the message consumption request, and the second data center identifier corresponding to the message consumer, and the triple relationship groups are added to the configuration metadata. It can be seen that the triple relationship groups generated according to the message consumption request are used to represent the corresponding relationship between the message consumer, the message queue to be consumed, and the data center where the message consumer is located. The subsequent synchronization direction can be determined according to this corresponding relationship.

[0062] Correspondingly, to improve the synchronization efficiency and reduce the transmission delay during subsequent consumption, the synchronization module in any data center is further configured to: determine any message queue in this data center as the message queue to be synchronized, determine the data centers corresponding to each message consumer of the message queue to be synchronized according to the triple relationship groups in the configuration metadata, and synchronize the message data in the message queue to be synchronized to the data centers corresponding to each message consumer. Specifically, the synchronization modules in each data center can periodically poll whether each message queue in this data center is updated, and when any message queue is updated, determine the consumer corresponding to the updated message queue and the data center where it is located according to the triple relationship groups in the configuration metadata, and then synchronize the updated message queue to the data center where the consumer is located.

[0063] In addition, although the above-mentioned triple relationship group can store the corresponding relationship among the message consumer, the message queue to be consumed, and the ID of the computer room where the message consumer is located, the inventor found during the implementation of the present invention that the relationship between the message consumer and the message queue to be consumed may change, and the computer room where the message consumer is located may also change due to computer room migration operations. Therefore, in order to adapt to the above changes, the triple relationship group in this embodiment can be dynamically updated. For example, it can be dynamically updated according to the message consumption request triggered by the message consumer after switching computer rooms, and can also be dynamically updated when the message consumer adds a new message queue to be consumed.

[0064] In order to perceive the change situation of the corresponding relationship in the triple relationship group, in this embodiment, whenever the second computer room in multiple computer rooms generates a group of triple relationship groups according to the message consumption request, it is further determined whether a triple relationship group corresponding to the message consumer included in the message consumption request has been stored in the configuration metadata. If so, the computer room information in the triple relationship group corresponding to the message consumer included in the message consumption request that has been stored is further obtained, and the obtained computer room information is compared with the computer room information in the triple relationship group generated this time. According to the comparison result, it is determined whether the message consumer included in the message consumption request has migrated to another computer room. For example, if the obtained computer room information is inconsistent with the computer room information in the triple relationship group generated this time, it is determined that the message consumer included in the message consumption request has migrated to another computer room. In the case of determining a computer room migration, it is necessary to delete the triple relationship group corresponding before the migration from the configuration metadata and only retain the triple relationship group corresponding after the migration, so as to achieve the dynamic update of the corresponding relationship.

[0065] Similarly, whenever the second computer room in multiple computer rooms generates a group of triple relationship groups according to the message consumption request, it is further determined whether a triple relationship group corresponding to the message consumer included in the message consumption request has been stored in the configuration metadata. If so, the information of the message queue to be consumed in the triple relationship group corresponding to the message consumer included in the message consumption request that has been stored is further obtained, and the obtained message queue information is compared with the message queue information in the triple relationship group generated this time. According to the comparison result, it is determined whether the message consumer included in the message consumption request has added a new message queue to be consumed. If so, the above-mentioned corresponding relationship is newly added to the configuration metadata.

[0066] In summary, the configuration metadata in this embodiment can be dynamically updated according to each received message consumption request to dynamically maintain the current data center to which each message consumer belongs and the message queues to be consumed corresponding to each message consumer. Accordingly, the synchronization modules in each data center dynamically determine the message consumers corresponding to each message queue in this data center and their corresponding data centers based on the dynamically changing configuration metadata, so as to synchronize the message data in the message queue to the data centers corresponding to each message consumer. For example, there is a message queue M stored in a certain data center. Accordingly, the synchronization module in this data center determines through analyzing the configuration metadata that there are two consumers of the message queue M, namely the first consumer located in Data Center 1 and the second consumer located in Data Center 2. After the message queue M is updated, the synchronization module synchronizes the updated content to Data Center 1 and Data Center 2 to facilitate the subsequent consumption process.

[0067] During specific synchronization, the synchronization module consumes on behalf of the consumer of the message queue and writes the consumed data to the data center to be synchronized. For example, the synchronization module consumes the data in the message queue M on behalf of the consumer of the message queue M and writes the consumed data content to Data Center 1 and Data Center 2 respectively.

[0068] In a specific example, the message producer corresponds to a real-time service, and the message consumer corresponds to a non-real-time service associated with the real-time service. Since the real-time service has high real-time requirements, regardless of which data center the service acting as the message producer is located in, the message is directly written to the local message queue in this data center, thus avoiding the delay and jitter problems caused by cross-data center transmission through the data center dedicated line. Moreover, there is no need to care about the location of the consumer in the data center, which is especially suitable for complex business scenarios with a large number of services. Since the message consumer corresponds to a non-real-time service, the data transmission process implemented through the data center dedicated line will not affect the business.

[0069] For example, when the method in this embodiment is applied to an e-book application, the message producer can be the service of receiving books in the e-book. When a user receives a book, a new data record is added to the corresponding message queue to record the correspondence between the user and the received book. Since the real-time requirement of the book receiving operation is high, in order to avoid the user waiting for a long time for the result feedback of the book receiving operation, the response speed is improved by writing the data record to the local data center where the book receiving service is located, and the user is prevented from waiting for a long time. Accordingly, the message consumer can be the service of updating points in the e-book. When a user receives a book, the user's points are updated accordingly. Since the operation of updating points can be completed asynchronously, designing the consumption process as a cross-data center transmission method implemented through the data center dedicated line will not affect the user's use, thus effectively solving the problem of real-time service jamming in the e-book application.

[0070] In addition, in a specific example, the message queue can be implemented based on the Advanced Message Queuing Protocol (AMQP), for example, RabbitMQ. The synchronization module can be controlled by a synchronization switch. When the synchronization switch is turned on, the synchronization service can be implemented; when the synchronization switch is turned off, the synchronization service is temporarily not performed. By setting a synchronization switch for controlling each synchronization module in each computer room, it is possible to flexibly determine whether to perform the synchronization operation of the message queue according to the business situation, so that the synchronization operation can be suspended when the business is busy and the synchronization operation can be performed when the business is idle, thereby minimizing the impact of the synchronization operation on the business system.

[0071] The method in this embodiment is particularly suitable for cross-project production scenarios, where there are a large number of production ends and consumer ends, and one production end may correspond to multiple consumer ends, and one consumer end may also correspond to multiple production ends. In such a complex business scenario, it is difficult to predetermine the number of consumer ends corresponding to the production message queue and the computer room where each consumer end is located. Therefore, the above problem can be well solved by dynamically maintaining the configuration metadata through the agent module. Moreover, after the consumer end switches the computer room, the configuration metadata can be automatically updated dynamically, so that it is not affected by the switching of the computer room, and the message data can be synchronized to the switched computer room in time for consumption.

[0072] The proxy module in this embodiment may also be referred to as a proxy component or proxy element, and may be implemented through software programming or hardware, without limitation in the present invention. Similarly, the synchronization module in this embodiment may also be referred to as a synchronization component or synchronization element, and may be implemented through software programming or hardware, without limitation in the present invention.

[0073] In summary, the method in this embodiment avoids the tedious operation of pre-determining the number of consumer terminals and the computer rooms where they are located, and avoids the delay problem caused by producing messages across computer rooms, and can be applied to business scenarios with high real-time requirements. By setting up a proxy module, the message processing process can be taken over by the proxy module, thereby facilitating the unified maintenance of configuration metadata. Moreover, based on the configuration metadata, the consumer terminal corresponding to each message queue and the computer room where it is located can be determined, and then the synchronization module completes the synchronization operation in advance, thereby improving the efficiency of subsequent consumption.

[0074] Embodiment 3

[0075] An embodiment of the present application provides a non-volatile computer storage medium storing at least one executable instruction. The computer executable instruction can execute the message queue management method based on multi-computer room implementation in any of the above method embodiments.

[0076] The executable instructions can specifically be used to cause the processor to perform the following operations:

[0077] In response to a message writing request triggered by a message production end corresponding to the first computer room among multiple computer rooms, the first computer room writes the message data included in the message writing request into the message queue corresponding to the first computer room, and stores the queue-computer room mapping relationship between the message queue corresponding to the first computer room and the first computer room into the configuration metadata;

[0078] In response to a message consumption request triggered by a message consumption end corresponding to the second computer room among multiple computer rooms, the second computer room determines the message queue corresponding to the message consumption request as the target message queue, determines the computer room where the target message queue is located as the target computer room according to the configuration metadata, and transmits the message data of the target message queue in the target computer room to the second computer room for consumption by the message consumption end.

[0079] In an alternative implementation, the executable instructions can specifically be used to cause the processor to perform the following operations: Proxy modules are respectively set up in each computer room, and the proxy modules in each computer room jointly maintain the configuration metadata; then the step of writing the message data included in the message writing request into the message queue corresponding to the first computer room and storing the queue-computer room mapping relationship between the message queue corresponding to the first computer room and the first computer room into the configuration metadata is executed by the proxy module in the first computer room; and the step of determining the message queue corresponding to the message consumption request as the target message queue and determining the computer room where the target message queue is located as the target computer room according to the configuration metadata is executed by the proxy module in the second computer room.

[0080] In an alternative implementation, the executable instructions can specifically be used to cause the processor to perform the following operations: Synchronization modules are respectively set up in each computer room, and each synchronization module communicates with the proxy module in its own computer room; then the transmitting the message data of the target message queue in the target computer room to the second computer room includes: transmitting the message data of the target message queue in the target computer room to the second computer room through the synchronization module in the target computer room.

[0081] In an alternative implementation, the executable instructions can specifically be used to cause the processor to perform the following operations: Generate a set of triple relationship groups according to the message consumption end corresponding to the message consumption request, the target message queue corresponding to the message consumption request, and the second computer room identifier corresponding to the message consumption end, and add the triple relationship groups to the configuration metadata.

[0082] In an alternative implementation, the executable instructions can be specifically used to cause the processor to perform the following operations: The synchronization module determines any message queue in this computer room as the message queue to be synchronized, determines the computer rooms corresponding to the respective message consumers of the message queue to be synchronized according to the triple relationship group in the configuration metadata, and synchronizes the message data in the message queue to be synchronized to the computer rooms corresponding to the respective message consumers.

[0083] In an alternative implementation, the triple relationship group is used to store the correspondence between a message consumer, the message queue to be consumed, and the computer room identifier where the message consumer is located; and the triple relationship group can be dynamically updated according to the message consumption request triggered by the message consumer after switching computer rooms.

[0084] In an alternative implementation, the executable instructions can be specifically used to cause the processor to perform the following operations:

[0085] Through the computer room dedicated line between the target computer room and the second computer room, the message data of the target message queue in the target computer room is transmitted to the second computer room.

[0086] In an alternative implementation, the message producer corresponds to a real-time service, and the message consumer corresponds to a non-real-time service associated with the real-time service.

[0087] Embodiment 4

[0088] Figure 3 FIG. shows a schematic structural diagram of an electronic device according to another embodiment of the present invention. The specific implementation of the electronic device in the specific embodiments of the present invention is not limited.

[0089] As Figure 3 shown, the electronic device may include: a processor 302, a communication interface 304, a memory 306, and a communication bus 308.

[0090] Wherein: The processor 302, the communication interface 304, and the memory 306 communicate with each other through the communication bus 308. The communication interface 304 is used to communicate with network elements of other devices such as clients or other servers. The processor 302 is used to execute the program 310, and specifically can execute the relevant steps in the above-mentioned embodiment of the method for managing message queues based on multiple computer rooms.

[0091] Specifically, the program 310 may include program code, and the program code includes computer operation instructions.

[0092] The processor 302 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention. One or more processors included in the electronic device may be of the same type of processor, such as one or more CPUs; or may be of different types of processors, such as one or more CPUs and one or more ASICs.

[0093] A memory 306 is used to store a program 310. The memory 306 may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory.

[0094] The program 310 may specifically be used to cause the processor 302 to perform the following operations:

[0095] In response to a message writing request triggered by a message producer corresponding to the first computer room among multiple computer rooms, the first computer room writes the message data included in the message writing request into a message queue corresponding to the first computer room, and stores the queue-computer room mapping relationship between the message queue corresponding to the first computer room and the first computer room into configuration metadata.

[0096] In response to a message consumption request triggered by a message consumer corresponding to the second computer room among multiple computer rooms, the second computer room determines a message queue corresponding to the message consumption request as a target message queue, determines the computer room where the target message queue is located as a target computer room according to the configuration metadata, and transfers the message data of the target message queue in the target computer room to the second computer room for consumption by the message consumer.

[0097] In an alternative implementation, the executable instructions may specifically be used to cause the processor to perform the following operations: proxy modules are respectively set in each computer room, and the proxy modules in each computer room jointly maintain the configuration metadata; then the step of writing the message data included in the message writing request into a message queue corresponding to the first computer room and storing the queue-computer room mapping relationship between the message queue corresponding to the first computer room and the first computer room into the configuration metadata is executed by the proxy module in the first computer room; and the step of determining a message queue corresponding to the message consumption request as a target message queue and determining the computer room where the target message queue is located as a target computer room according to the configuration metadata is executed by the proxy module in the second computer room.

[0098] In an alternative implementation, the executable instructions can be specifically used to cause the processor to perform the following operations: set a synchronization module in each computer room, and each synchronization module communicates with the proxy module in its own computer room; then the transmission of the message data of the target message queue in the target computer room to the second computer room includes: transmitting the message data of the target message queue in the target computer room to the second computer room through the synchronization module in the target computer room.

[0099] In an alternative implementation, the executable instructions can be specifically used to cause the processor to perform the following operations: generate a set of triple relationship groups according to the message consumer corresponding to the message consumption request, the target message queue corresponding to the message consumption request, and the second computer room identifier corresponding to the message consumer, and add the triple relationship groups to the configuration metadata.

[0100] In an alternative implementation, the executable instructions can be specifically used to cause the processor to perform the following operations: the synchronization module determines any message queue in its own computer room as the message queue to be synchronized, determines the computer rooms corresponding to each message consumer of the message queue to be synchronized according to the triple relationship groups in the configuration metadata, and synchronizes the message data in the message queue to be synchronized to the computer rooms corresponding to each message consumer.

[0101] In an alternative implementation, the triple relationship group is used to store the corresponding relationship between the message consumer, the message queue to be consumed, and the computer room identifier where the message consumer is located; and the triple relationship group can be dynamically updated according to the message consumption request triggered by the message consumer after switching computer rooms.

[0102] In an alternative implementation, the executable instructions can be specifically used to cause the processor to perform the following operations:

[0103] Transmit the message data of the target message queue in the target computer room to the second computer room through the computer room dedicated line between the target computer room and the second computer room.

[0104] In an alternative implementation, the message producer corresponds to a real-time service, and the message consumer corresponds to a non-real-time service associated with the real-time service.

[0105] The algorithms and displays provided herein are not inherently related to any particular computer, virtual system, or other apparatus. Various general-purpose systems may also be used in conjunction with the teachings based hereon. The structure required to construct such systems will be apparent from the above description. In addition, the present invention is not directed to any particular programming language. It should be appreciated that the teachings of the present invention described herein can be implemented in a variety of programming languages, and the description of specific languages above is provided to disclose the best mode of the present invention.

[0106] In the specification provided herein, numerous specific details are set forth. However, it is understood that embodiments of the present invention may be practiced without these specific details. In some instances, well-known methods, structures, and techniques have not been shown in detail so as not to obscure the understanding of the present specification.

[0107] Similarly, it should be understood that in order to streamline the present disclosure and assist in understanding one or more of the various inventive aspects, in the foregoing description of the exemplary embodiments of the present invention, the various features of the present invention are sometimes grouped together in a single embodiment, figure, or description thereof. However, the disclosed method should not be construed as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim. Rather, as reflected in the following claims, the inventive aspects lie in less than all the features of the single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into the detailed description, with each claim standing on its own as a separate embodiment of the present invention.

[0108] Those skilled in the art will appreciate that the modules in the devices in the embodiments can be adaptively changed and disposed in one or more devices different from the embodiments. The modules or units or components in the embodiments can be combined into one module or unit or component, and in addition, they can be divided into multiple sub-modules or sub-units or sub-components. Except that at least some of such features and / or processes or units are mutually exclusive, any combination can be used to combine all the features disclosed in this specification (including the accompanying claims, abstract, and drawings) and all the processes or units of any method or device so disclosed. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstract, and drawings) can be replaced by an alternative feature providing the same, equivalent, or similar purpose.

[0109] In addition, those skilled in the art will understand that although some embodiments herein include certain features included in other embodiments rather than other features, the combination of features of different embodiments is meant to be within the scope of the present invention and forms different embodiments. For example, in the following claims, any one of the claimed embodiments can be used in any combination.

[0110] It should be noted that the above embodiments illustrate the present invention rather than limit the present invention, and those skilled in the art can design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in the claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention can be implemented by means of hardware including several different elements and by means of a suitably programmed computer. In the unit claims listing several devices, several of these devices can be embodied by the same item of hardware. The use of the words first, second, and third, etc. does not denote any order. These words can be interpreted as names.

Claims

1. A management method for a message queue implemented based on multiple computer rooms, including: Setting proxy modules in each computer room respectively, and the proxy modules in each computer room jointly maintain configuration metadata; When the first computer room among multiple computer rooms responds to a message writing request triggered by a message production end corresponding to the first computer room, the proxy module in the first computer room is used to write the message data included in the message writing request into the message queue corresponding to the first computer room, and store the message queue corresponding to the first computer room and the queue-computer room mapping relationship between the first computer room into the configuration metadata; When the second computer room among multiple computer rooms responds to a message consumption request triggered by a message consumption end corresponding to the second computer room, the proxy module in the second computer room is used to determine the message queue corresponding to the message consumption request as the target message queue, determine the computer room where the target message queue is located as the target computer room according to the configuration metadata; transmit the message data of the target message queue in the target computer room to the second computer room for consumption by the message consumption end; and generate a set of triple relationship groups according to the message consumption end corresponding to the message consumption request, the target message queue corresponding to the message consumption request, and the second computer room identifier corresponding to the message consumption end, and add the triple relationship groups to the configuration metadata; The method further includes: The synchronization module in any computer room determines any message queue in this computer room as the message queue to be synchronized, determines the computer rooms corresponding to each message consumption end of the message queue to be synchronized according to the triple relationship groups in the configuration metadata, and synchronizes the message data in the message queue to be synchronized to the computer rooms corresponding to each message consumption end; The triple relationship groups can be dynamically updated according to the message consumption requests triggered by the message consumption end after switching computer rooms; Whenever the second computer room generates a set of triple relationship groups according to the message consumption request, further determine whether there is a triple relationship group corresponding to the message consumption end included in the message consumption request stored in the configuration metadata. If so, further obtain the computer room information in the stored triple relationship group corresponding to the message consumption end included in the message consumption request, compare the obtained computer room information with the computer room information in the triple relationship group generated this time, and judge whether the message consumption end included in the message consumption request has migrated computer rooms according to the comparison result.

2. The method according to claim 1, wherein The transmitting the message data of the target message queue in the target computer room to the second computer room includes: Transmitting the message data of the target message queue in the target computer room to the second computer room through the computer room dedicated line between the target computer room and the second computer room.

3. The method according to claim 1, wherein, The message production end corresponds to a real-time service, and the message consumption end corresponds to a non-real-time service associated with the real-time service.

4. An electronic device, comprising: A processor, a memory, a communication interface, and a communication bus, and the processor, the memory, and the communication interface complete mutual communication through the communication bus; The memory is used to store at least one executable instruction, and the executable instruction causes the processor to execute the method according to any one of claims 1-3.

5. A computer storage medium storing at least one executable instruction, and the executable instruction causes the processor to execute the method according to any one of claims 1-3.

Citation Information

Patent Citations

  • Data sending method and device and server

    CN108347477A

  • Message consumption method and device, storage medium and electronic equipment

    CN110740145A