+

CN112052104A - Management method and electronic equipment of message queue based on multi-room implementation - Google Patents

Management method and electronic equipment of message queue based on multi-room implementation Download PDF

Info

Publication number
CN112052104A
CN112052104A CN202010905108.0A CN202010905108A CN112052104A CN 112052104 A CN112052104 A CN 112052104A CN 202010905108 A CN202010905108 A CN 202010905108A CN 112052104 A CN112052104 A CN 112052104A
Authority
CN
China
Prior art keywords
message
computer room
machine room
target
queue
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202010905108.0A
Other languages
Chinese (zh)
Other versions
CN112052104B (en
Inventor
王利超
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ireader Technology Co Ltd
Original Assignee
Ireader Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ireader Technology Co Ltd filed Critical Ireader Technology Co Ltd
Priority to CN202010905108.0A priority Critical patent/CN112052104B/en
Publication of CN112052104A publication Critical patent/CN112052104A/en
Application granted granted Critical
Publication of CN112052104B publication Critical patent/CN112052104B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/54Indexing scheme relating to G06F9/54
    • G06F2209/548Queue

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer And Data Communications (AREA)

Abstract

The invention discloses a management method of message queues based on multi-computer room realization and an electronic device, wherein the method comprises the following steps: responding to a message writing request triggered by a message production end corresponding to a first machine room by a first machine room in a plurality of machine rooms, writing message data contained in the message writing request into a message queue corresponding to the first machine room, and storing a mapping relation between the message queue corresponding to the first machine room and a queue machine room between the first machine rooms into configuration metadata; and a second machine room in the plurality of machine rooms responds to the message consumption request triggered by the message consumption end corresponding to the second machine room, determines the message queue corresponding to the message consumption request as a target message queue, determines the machine room where the target message queue is located as a target machine room according to the configuration metadata, and transmits the message data of the target message queue in the target machine room to the second machine room. The method avoids the delay problem caused by the production of the message across the machine room, and is suitable for service scenes with high real-time performance.

Description

基于多机房实现的消息队列的管理方法及电子设备Management method and electronic equipment of message queue based on multi-room implementation

技术领域technical field

本发明涉及计算机领域,具体涉及一种基于多机房实现的消息队列的管理方法及电子设备。The invention relates to the field of computers, in particular to a method for managing message queues and electronic equipment based on multi-room implementation.

背景技术Background technique

消息队列用于将待传输的数据存储到队列中。其中,向队列中写入数据的业务端叫做消息生产端,从队列中读取数据的业务端叫做消息消费端。通过消息队列能够实现多个消息数据的有序存储,从而有利于实现消息的可靠传输。A message queue is used to store data to be transmitted into the queue. Among them, the business end that writes data to the queue is called the message producer, and the business end that reads data from the queue is called the message consumer. The orderly storage of multiple message data can be achieved through the message queue, which is conducive to the reliable transmission of messages.

随着业务场景的日益复杂,很多业务系统中包含多个机房,在跨机房的实现方案中,消息生产端需要预先确定消息消费端所处的机房,并且,当消息消费端与消息生产端分别位于不同机房时,为了保障消息消费端的消费顺畅,需要将消息生产端在第一机房生产的消息数据传输到消息消费端所在的第二机房进行存储。With the increasing complexity of business scenarios, many business systems include multiple computer rooms. In the implementation plan across computer rooms, the message producer needs to pre-determine the computer room where the message consumer is located, and when the message consumer and the message producer are separated When located in different computer rooms, in order to ensure smooth consumption by the message consumer, the message data produced by the message producer in the first computer room needs to be transmitted to the second computer room where the message consumer is located for storage.

但是,在实现本发明的过程中,发明人发现现有技术中的上述方案至少存在下述缺陷:一方面,在复杂的业务场景中,一个消息生产端可能对应于多个消息消费端,如何预先确定消息消费端的数量以及各个消息消费端所处的机房成为亟待解决的技术难题;另一方面,消息生产端需要将生成的消息数据跨机房传输至消息消费端所在的机房,然而,由于两个机房之间的线路原因或网络原因可能造成数据传输延迟等缺陷,在实时性要求较高的业务场景中无法适用。However, in the process of implementing the present invention, the inventor found that the above solutions in the prior art have at least the following defects: On the one hand, in a complex business scenario, one message producer may correspond to multiple message consumers. Predetermining the number of message consumers and the computer room where each message consumer is located has become an urgent technical problem to be solved; on the other hand, the message producer needs to transmit the generated message data across the computer room to the computer room where the message consumer is located. Defects such as data transmission delay may be caused by line reasons between individual computer rooms or network reasons, which cannot be applied in business scenarios with high real-time requirements.

发明内容SUMMARY OF THE INVENTION

鉴于上述问题,提出了本发明以便提供一种克服上述问题或者至少部分地解决上述问题的基于多机房实现的消息队列的管理方法及电子设备。In view of the above problems, the present invention is proposed to provide a method and electronic device for managing message queues based on multi-machine room implementations that overcome the above problems or at least partially solve the above problems.

根据本发明的一个方面,提供了一种基于多机房实现的消息队列的管理方法,包括:According to one aspect of the present invention, a method for managing message queues based on multiple computer rooms is provided, including:

多个机房中的第一机房响应于与所述第一机房相对应的消息生产端触发的消息写入请求,将所述消息写入请求中包含的消息数据写入与所述第一机房相对应的消息队列,并将所述第一机房相对应的消息队列以及所述第一机房之间的队列机房映射关系存储到配置元数据中;In response to a message write request triggered by a message producer corresponding to the first computer room, the first computer room in the plurality of computer rooms writes the message data contained in the message write request into the first computer room. corresponding message queue, and store the message queue corresponding to the first computer room and the queue-computer room mapping relationship between the first computer room in the configuration metadata;

多个机房中的第二机房响应于与所述第二机房相对应的消息消费端触发的消息消费请求,将与所述消息消费请求相对应的消息队列确定为目标消息队列,根据所述配置元数据将所述目标消息队列所在的机房确定为目标机房,将所述目标机房中的所述目标消息队列的消息数据传输至所述第二机房,以供所述消息消费端消费。The second computer room in the plurality of computer rooms determines the message queue corresponding to the message consumption request as the target message queue in response to the message consumption request triggered by the message consumption terminal corresponding to the second computer room, and according to the configuration The metadata determines the computer room where the target message queue is located as the target computer room, 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 consumer.

根据本发明的另一方面,提供了一种电子设备,包括:处理器、存储器、通信接口和通信总线,所述处理器、所述存储器和所述通信接口通过所述通信总线完成相互间的通信;According to another aspect of the present invention, an electronic device is provided, comprising: a processor, a memory, a communication interface, and a communication bus, and the processor, the memory, and the communication interface can communicate with each other through the communication bus. communication;

所述存储器用于存放至少一可执行指令,所述可执行指令使所述处理器执行以下操作:The memory is used to store at least one executable instruction, and the executable instruction causes the processor to perform the following operations:

多个机房中的第一机房响应于与所述第一机房相对应的消息生产端触发的消息写入请求,将所述消息写入请求中包含的消息数据写入与所述第一机房相对应的消息队列,并将所述第一机房相对应的消息队列以及所述第一机房之间的队列机房映射关系存储到配置元数据中;In response to a message write request triggered by a message producer corresponding to the first computer room, the first computer room in the plurality of computer rooms writes the message data contained in the message write request into the first computer room. corresponding message queue, and store the message queue corresponding to the first computer room and the queue-computer room mapping relationship between the first computer room in the configuration metadata;

多个机房中的第二机房响应于与所述第二机房相对应的消息消费端触发的消息消费请求,将与所述消息消费请求相对应的消息队列确定为目标消息队列,根据所述配置元数据将所述目标消息队列所在的机房确定为目标机房,将所述目标机房中的所述目标消息队列的消息数据传输至所述第二机房,以供所述消息消费端消费。The second computer room in the plurality of computer rooms determines the message queue corresponding to the message consumption request as the target message queue in response to the message consumption request triggered by the message consumption terminal corresponding to the second computer room, and according to the configuration The metadata determines the computer room where the target message queue is located as the target computer room, 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 consumer.

根据本发明的又一方面,提供了一种计算机存储介质,所述存储介质中存储有至少一可执行指令,所述可执行指令使所述处理器执行以下操作:According to yet another aspect of the present invention, a computer storage medium is provided, and at least one executable instruction is stored in the storage medium, and the executable instruction causes the processor to perform the following operations:

多个机房中的第一机房响应于与所述第一机房相对应的消息生产端触发的消息写入请求,将所述消息写入请求中包含的消息数据写入与所述第一机房相对应的消息队列,并将所述第一机房相对应的消息队列以及所述第一机房之间的队列机房映射关系存储到配置元数据中;In response to a message write request triggered by a message producer corresponding to the first computer room, the first computer room in the plurality of computer rooms writes the message data contained in the message write request into the first computer room. corresponding message queue, and store the message queue corresponding to the first computer room and the queue-computer room mapping relationship between the first computer room in the configuration metadata;

多个机房中的第二机房响应于与所述第二机房相对应的消息消费端触发的消息消费请求,将与所述消息消费请求相对应的消息队列确定为目标消息队列,根据所述配置元数据将所述目标消息队列所在的机房确定为目标机房,将所述目标机房中的所述目标消息队列的消息数据传输至所述第二机房,以供所述消息消费端消费。The second computer room in the plurality of computer rooms determines the message queue corresponding to the message consumption request as the target message queue in response to the message consumption request triggered by the message consumption terminal corresponding to the second computer room, and according to the configuration The metadata determines the computer room where the target message queue is located as the target computer room, 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 consumer.

在本发明提供的基于多机房实现的消息队列的管理方法及电子设备中,将消息生产端产生的消息数据直接写入消息生产端所在的本机房中,无需确定消息消费端所在的机房,在消息生产过程中也无需执行跨机房的数据传输操作,从而提升了操作的实时性,避免了因网络抖动造成的影响;另外,当消息消费端消费数据时,根据预先记录的配置元数据中包含的队列机房映射关系确定待消费的消息队列所在的机房,从而异步获取数据以供消费。由此可见,该方式避免了预先确定消费端数量及其所在机房的繁琐操作,且避免了跨机房生产消息所导致的延迟问题,能够适用于实时性要求较高的业务场景中。In the method and electronic device for managing message queues based on the implementation of multiple computer rooms provided by the present invention, the message data generated by the message producing end is directly written into the local computer room where the message producing end is located, and it is not necessary to determine the computer room where the message consuming end is located. In the process of message production, there is no need to perform data transmission operations across computer rooms, which improves the real-time performance of operations and avoids the impact caused by network jitter; The queue computer room mapping relationship determines the computer room where the message queue to be consumed is located, so as to obtain data asynchronously for consumption. It can be seen that this method avoids the tedious operation of pre-determining the number of consumers and the computer room where they are located, and avoids the delay problem caused by the production of messages across computer rooms, and can be applied to business scenarios with high real-time requirements.

上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术手段,而可依照说明书的内容予以实施,并且为了让本发明的上述和其它目的、特征和优点能够更明显易懂,以下特举本发明的具体实施方式。The above description is only an overview of the technical solutions 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 description, and in order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand , the following specific embodiments of the present invention are given.

附图说明Description of drawings

通过阅读下文优选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出优选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are for the purpose of illustrating preferred embodiments only and are not to be considered limiting of the invention. Also, the same components are denoted by the same reference numerals throughout the drawings. In the attached image:

图1示出了本发明一个实施例提供的基于多机房实现的消息队列的管理方法的流程图;FIG. 1 shows a flowchart of a method for managing message queues based on a multi-machine room implementation provided by an embodiment of the present invention;

图2示出了本发明另一个实施例提供的基于多机房实现的消息队列的管理方法的流程图;2 shows a flowchart of a method for managing message queues based on a multi-machine room implementation provided by another embodiment of the present invention;

图3示出了根据本发明另一个实施例的一种电子设备的结构示意图。FIG. 3 shows a schematic structural diagram of an electronic device according to another embodiment of the present invention.

具体实施方式Detailed ways

下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that the present disclosure will be more thoroughly understood, and will fully convey the scope of the present disclosure to those skilled in the art.

实施例一Example 1

图1示出了本发明一个实施例提供的基于多机房实现的消息队列的管理方法的流程图。如图1所示,该方法包括以下步骤:FIG. 1 shows a flowchart of a method for managing message queues based on a multi-machine room implementation provided by an embodiment of the present invention. As shown in Figure 1, the method includes the following steps:

步骤S110:多个机房中的第一机房响应于与第一机房相对应的消息生产端触发的消息写入请求,将消息写入请求中包含的消息数据写入与第一机房相对应的消息队列,并将第一机房相对应的消息队列以及第一机房之间的队列机房映射关系存储到配置元数据中。Step S110: In response to a message writing request triggered by a message producer corresponding to the first computer room, the first computer room among the plurality of computer rooms writes the message data contained in the message writing request into a message corresponding to the first computer room queue, and store the message queue corresponding to the first computer room and the mapping relationship between the queues and computer rooms in the configuration metadata.

其中,本实施例中的多个机房是指:至少两个机房。相应地,多个机房中的第一机房可以是多个机房中的任一机房。具体地,每个机房分别对应于一个或多个服务。其中,一个服务可能对应于一个项目或一个应用,也可能对应于一个应用中的一种功能,本发明对此不做限定。各个机房所对应的服务既可能是消息生产端,也可能是消息消费端,还可能同时作为消息生产端以及消息消费端,具体取决于该服务当前执行的业务功能。Wherein, the multiple computer rooms in this embodiment refer to: at least two computer rooms. Correspondingly, the first computer room in the multiple computer rooms may be any one of the multiple computer rooms. Specifically, each computer room corresponds to one or more services. Wherein, a service may correspond to a project or an application, or may correspond to a function in an application, which is not limited in the present invention. The service corresponding to each computer room may be a message producer, a message consumer, or a message producer and a message consumer at the same time, depending on the business function currently performed by the service.

当一个服务用于产生消息数据时,该服务作为消息生产端向该服务所对应的机房发送消息写入请求,在本实施例中,将该发送消息写入请求的服务所对应的机房作为第一机房。实质上,对于任一机房而言,只要该机房对应的服务作为消息生产端触发了消息写入请求,该机房则被称作第一机房。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 used as the first A machine room. In essence, 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.

第一机房接收到本机房的服务发来的消息写入请求后,将消息写入请求中包含的消息数据写入与第一机房(即本机房)相对应的消息队列,并将第一机房相对应的消息队列以及第一机房之间的队列机房映射关系存储到配置元数据中。由此可见,任一机房接收到消息写入请求后,无需确定对应的消息消费端,直接将接收到的消息数据写入本机房所对应的消息队列即可。该方式无需经由跨机房的网络传输过程,因而能够大幅提升写入效率。After the first computer room receives the message write request sent by the service of the local computer room, it writes the message data contained in the message write request into the message queue corresponding to the first computer room (that is, the local computer room), and writes the message data in the first computer room. The corresponding message queues and the queue-machine room mapping relationship between the first machine rooms are stored in the configuration metadata. It can be seen that, after receiving a message write request in any computer room, it does not need to determine the corresponding message consumer, but directly writes the received message data to the message queue corresponding to the computer room. This method does not need to go through the network transmission process across the computer room, so it can greatly improve the writing efficiency.

其中,与第一机房相对应的消息队列是指:存储在与第一机房相对应的存储空间内的消息队列。其中,与第一机房相对应的存储空间可以在第一机房本地的存储空间,也可以是与第一机房相连接的数据库中的存储空间,具体,与第一机房相对应的消息队列可以由第一机房中的队列服务器负责维护。The message queue corresponding to the first computer room refers to a message queue stored in a storage space corresponding to the first computer room. The storage space corresponding to the first computer room may be a local storage space of the first computer room, or may be a storage space in a database connected to the first computer room. Specifically, the message queue corresponding to the first computer room may be set by The queue server in the first computer room is responsible for maintenance.

另外,队列机房映射关系用于存储消息生产端生产的消息队列以及该消息队列所在的机房之间的对应关系。当然,该队列机房映射关系还可以进一步存储消息生产端、消息生产端生产的消息队列以及该消息队列所在的机房之间的三元对应关系。配置元数据用于统一存储上述的队列机房映射关系,其中,配置元数据既可以统一存储在与各个机房分别相连的配置服务器中,也可以分别存储在各个机房中并由各个机房进行共享。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 may further store the ternary correspondence between 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 mapping relationship between the queues and computer rooms, wherein the configuration metadata can be stored in the configuration server connected to each computer room in a unified manner, or stored in each computer room and shared by each computer room.

步骤S120:多个机房中的第二机房响应于与第二机房相对应的消息消费端触发的消息消费请求,将与消息消费请求相对应的消息队列确定为目标消息队列,根据配置元数据将目标消息队列所在的机房确定为目标机房,将目标机房中的目标消息队列的消息数据传输至第二机房,以供消息消费端消费。Step S120: In response to the message consumption request triggered by the message consumer corresponding to the second computer room, the second computer room in the plurality of computer rooms determines the message queue corresponding to the message consumption request as the target message queue, and according to the configuration metadata The computer room where the target message queue is located is determined as the target computer room, and the message data of the target message queue in the target computer room is transmitted to the second computer room for consumption by the message consumer.

具体地,多个机房中的第二机房可以是多个机房中的任一机房。由于每个机房分别对应于一个或多个服务,因此,当一个服务用于消费消息数据时,该服务作为消息消费端向该服务所对应的机房发送消息消费请求,在本实施例中,将该发送消息消费请求的服务所对应的机房作为第二机房。实质上,对于任一机房而言,只要该机房对应的服务作为消息消费端触发了消息消费请求,该机房则被称作第二机房。Specifically, the second computer room in the multiple computer rooms may be any computer room in the multiple computer rooms. Since each computer room corresponds to one or more services, 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 The computer room corresponding to the service for sending the message consumption request is used as the second computer room. In essence, for any computer room, as long as the service corresponding to the computer room triggers a message consumption request as a message consumer, the computer room is called the second computer room.

第二机房接收到本机房的服务发来的消息消费请求后,首先,确定与消息消费请求相对应的消息队列,将其确定为目标消息队列;然后,查询配置元数据,根据查询结果确定目标消息队列所在的机房,将该机房确定为目标机房;最后,将目标机房中的目标消息队列的消息数据传输至第二机房,以供消息消费端在本地进行消费。由此可见,任一机房接收到消息消费请求后,根据配置元数据确定待消费的消息队列所在的机房,进而从该机房获取数据。After the second computer room receives the message consumption request sent by the service of the local computer room, firstly, 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 target according to the query result. The computer room where the message queue is located is determined as the target computer room; finally, 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. 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 data from the computer room.

其中,目标机房可以是多个机房中的任一机房,例如,目标机房有可能是上述的第一机房,也可能是不同于第一机房和第二机房的第三机房,当然,还可能是第二机房本身,此时,直接在本机房内部获取消息数据即可。总之,本发明不限定目标消息队列以及目标机房的具体位置,完全取决于业务实际需求。另外,在将目标机房中的目标消息队列的消息数据传输至第二机房时,可通过两个机房之间的数据专线进行传输。The target computer room may be any computer room among multiple computer rooms. For example, the target computer room may be the above-mentioned first computer room, or 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, at this time, can directly obtain the message data in this computer room. In a word, the present invention does not limit the specific location of the target message queue and the target computer room, which completely depends on the actual needs of the business. In addition, when the message data of the target message queue in the target computer room is transmitted to the second computer room, the transmission can be performed through a dedicated data line between the two computer rooms.

另外,还需要说明的是,上述的第一机房和第二机房可以是不同的机房,也可能是相同的机房,本发明对此不做限定。In addition, it should also be noted that the above-mentioned first computer room and second computer room may be different computer rooms, or may be the same computer room, which is not limited in the present invention.

由此可见,在本发明提供的基于多机房实现的消息队列的管理方法中,将消息生产端产生的消息数据直接写入消息生产端所在的本机房中,无需确定消息消费端所在的机房,在消息生产过程中也无需执行跨机房的数据传输操作,从而提升了操作的实时性,避免了因网络抖动造成的影响;另外,当消息消费端消费数据时,根据预先记录的配置元数据中包含的队列机房映射关系确定待消费的消息队列所在的机房,从而异步获取数据以供消费。由此可见,该方式避免了预先确定消费端数量及其所在机房的繁琐操作,且避免了跨机房生产消息所导致的延迟问题,能够适用于实时性要求较高的业务场景中。It can be seen that, in the method for managing message queues based on the implementation of multiple computer rooms provided by the present invention, the message data generated by the message producer is directly written into the computer room where the message producer is located, and there is no need to determine the computer room where the message consumer is located. In the process of message production, there is no need to perform data transmission operations across computer rooms, which improves the real-time performance of operations and avoids the impact caused by network jitter; The included queue computer room mapping relationship determines the computer room where the message queue to be consumed is located, thereby asynchronously acquiring data for consumption. It can be seen that this method avoids the tedious operation of pre-determining the number of consumers and the computer room where they are located, and avoids the delay problem caused by the production of messages across computer rooms, and can be applied to business scenarios with high real-time requirements.

实施例二Embodiment 2

图2示出了本发明另一个实施例提供的基于多机房实现的消息队列的管理方法的流程图。如图2所示,该方法包括以下步骤:FIG. 2 shows a flowchart of a method for managing message queues based on a multi-machine room implementation provided by another embodiment of the present invention. As shown in Figure 2, the method includes the following steps:

步骤S200:分别在各个机房中设置代理模块,各个机房的代理模块共同维护配置元数据。Step S200: Set proxy modules in each computer room respectively, and the proxy modules in each computer room jointly maintain configuration metadata.

具体地,在多个机房的每个机房中分别设置一个代理模块,各个机房内部的代理模块用于处理来自各个服务的消息写入请求以及消息消费请求,并根据消息写入请求以及消息消费请求维护配置元数据。例如,消息写入请求中包含消息生产端、待写入的消息队列、以及消息生产端所在的机房的三元对应关系;消息消费请求中包含消息消费端、待消费的消息队列、以及消息消费端所在的机房的三元对应关系,由此可见,各个机房的代理模块在处理消息写入请求以及消息消费请求的过程中,能够建立并维护由服务(包括消息生产端以及消息消费端)、消息队列、机房构成的三元关系组,从而构成配置元数据,以便于后续处理。Specifically, a proxy module is set in each computer room of the multiple computer rooms, and the proxy module in each computer room is used to process the message writing request and the message consumption request from each service, and according to the message writing request and the message consumption request Maintain configuration metadata. For example, the message writing request includes the ternary correspondence between the message producer, the message queue to be written, and the computer room where the message producer is located; the message consumption request includes the message consumer, the message queue to be consumed, and the message consumption The ternary correspondence of the computer room where the terminal is located. It can be seen that the proxy module of each computer room can establish and maintain the service (including the message producer and the message consumer) in the process of processing message writing requests and message consumption requests. The triple relationship group composed of message queue and computer room constitutes configuration metadata for subsequent processing.

具体实施时,各个机房的代理模块用于基于扩展协议实现针对各个服务发来的消息写入请求以及消息消费请求的处理,并在处理过程中通过解析消息内容获取并动态维护上述的三元关系组。In specific implementation, the proxy module of each computer room is used to process the message writing request and message consumption request sent by each service based on the extension protocol, and obtain and dynamically maintain the above-mentioned ternary relationship by analyzing the content of the message during the processing. Group.

需要说明的是,本步骤为一个可选的步骤,在本发明其他的实施例中,也可以不设置代理模块,而通过改动机房内部源代码的方式实现维护配置元数据等相关功能,本发明对具体实现细节不做限定。It should be noted that this step is an optional step. In other embodiments of the present invention, an agent module may not be set, and related functions such as maintaining configuration metadata are implemented by changing the source code inside the computer room. The present invention The specific implementation details are not limited.

步骤S210:多个机房中的第一机房响应于与第一机房相对应的消息生产端触发的消息写入请求,将消息写入请求中包含的消息数据写入与第一机房相对应的消息队列,并将第一机房相对应的消息队列以及第一机房之间的队列机房映射关系存储到配置元数据中。Step S210: The first computer room in the plurality of computer rooms writes the message data contained in the message write request into the message corresponding to the first computer room in response to the message writing request triggered by the message producer corresponding to the first computer room queue, and store the message queue corresponding to the first computer room and the mapping relationship between the queues and computer rooms in the configuration metadata.

其中,本实施例中的多个机房是指:至少两个机房。相应地,多个机房中的第一机房可以是多个机房中的任一机房。具体地,每个机房分别对应于一个或多个服务。其中,一个服务可能对应于一个项目或一个应用,也可能对应于一个应用中的一种功能,本发明对此不做限定。各个机房所对应的服务既可能是消息生产端,也可能是消息消费端,还可能同时作为消息生产端以及消息消费端,具体取决于该服务当前执行的业务功能。Wherein, the multiple computer rooms in this embodiment refer to: at least two computer rooms. Correspondingly, the first computer room in the multiple computer rooms may be any one of the multiple computer rooms. Specifically, each computer room corresponds to one or more services. Wherein, a service may correspond to a project or an application, or may correspond to a function in an application, which is not limited in the present invention. The service corresponding to each computer room may be a message producer, a message consumer, or a message producer and a message consumer at the same time, depending on the business function currently performed by the service.

当一个服务用于产生消息数据时,该服务作为消息生产端向该服务所对应的机房发送消息写入请求,在本实施例中,将该发送消息写入请求的服务所对应的机房作为第一机房。实质上,对于任一机房而言,只要该机房对应的服务作为消息生产端触发了消息写入请求,该机房则被称作第一机房。第一机房接收到本机房的服务发来的消息写入请求后,将消息写入请求中包含的消息数据写入与第一机房(即本机房)相对应的消息队列,并将第一机房相对应的消息队列以及第一机房之间的队列机房映射关系存储到配置元数据中。由此可见,任一机房接收到消息写入请求后,无需确定对应的消息消费端,直接将接收到的消息数据写入本机房所对应的消息队列即可。该方式无需经由跨机房的网络传输过程,因而能够大幅提升写入效率。其中,与第一机房相对应的消息队列是指:存储在与第一机房相对应的存储空间内的消息队列。其中,与第一机房相对应的存储空间可以在第一机房本地的存储空间,也可以是与第一机房相连接的数据库中的存储空间,具体,与第一机房相对应的消息队列可以由第一机房中的队列服务器负责维护。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 used as the first A machine room. In essence, 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. After the first computer room receives the message write request sent by the service of the local computer room, it writes the message data contained in the message write request into the message queue corresponding to the first computer room (that is, the local computer room), and writes the message data in the first computer room. The corresponding message queues and the queue-machine room mapping relationship between the first machine rooms are stored in the configuration metadata. It can be seen that, after receiving a message write request in any computer room, it does not need to determine the corresponding message consumer, but directly writes the received message data to the message queue corresponding to the computer room. This method does not need to go through the network transmission process across the computer room, so it can greatly improve the writing efficiency. The message queue corresponding to the first computer room refers to a message queue stored in a storage space corresponding to the first computer room. The storage space corresponding to the first computer room may be a local storage space of the first computer room, or may be a storage space in a database connected to the first computer room. Specifically, the message queue corresponding to the first computer room may be set by The queue server in the first computer room is responsible for maintenance.

另外,队列机房映射关系用于存储消息生产端生产的消息队列以及该消息队列所在的机房之间的对应关系。当然,该队列机房映射关系还可以进一步存储消息生产端、消息生产端生产的消息队列以及该消息队列所在的机房之间的三元对应关系。配置元数据用于统一存储上述的队列机房映射关系。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 may further store the ternary correspondence between the message producer, the message queue produced by the message producer, and the computer room where the message queue is located. Configuration metadata is used to uniformly store the above queue room mapping relationship.

其中,配置元数据可通过多种方式存储:例如,在一种可选的实现方式中,将来自各个机房的配置元数据统一存储在与各个机房分别相连的配置服务器中,由配置服务器统一维护来自各个机房的配置元数据,相应地,配置服务器能够实现针对配置元数据的去重、检验等功能,以确保配置元数据的准确性。又如,在又一种可选的实现方式中,将各个机房产生的配置元数据分别存储在各个机房中,并由各个机房进行共享,其中,为了便于实现各个机房之间的配置元数据的共享,可以由一个机房通过广播机制向其他机房请求与当前接收到的消息消费请求相关的配置元数据。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 server connected to each computer room, and the configuration server maintains it uniformly The configuration metadata from each computer room, correspondingly, the configuration server can implement functions such as deduplication and inspection for the configuration metadata, so as to ensure the accuracy of the configuration metadata. For another example, in another optional implementation manner, the configuration metadata generated by each computer room is stored in each computer room and shared by each computer room. Sharing, a computer room can request configuration metadata related to the currently received message consumption request from other computer rooms through a broadcast mechanism.

其中,在各个机房中设置有代理模块的前提下,本步骤由第一机房中的代理模块负责执行。具体地,代理模块负责针对接收到的消息写入请求进行解析,根据解析结果中包含的消息生产端标识(即服务标识)、待写入的消息队列标识以及本机房的机房标识构建三元关系组,从而根据三元关系组得到对应的配置元数据。Wherein, on the premise that each computer room is provided with an agent module, this step is performed by the agent module in the first computer room. Specifically, the proxy module is responsible for parsing the received message write request, and constructs a ternary relationship according to the message producer identifier (ie, the service identifier), the message queue identifier to be written, and the computer room identifier of the computer room contained in the parsing result. group, so as to obtain the corresponding configuration metadata according to the ternary relationship group.

其中,为了方便通信,在本实施例中,各个服务都通过该服务所在的本机房发送各类请求数据,相应地,各个机房接收到的消息写入请求显然是由来自本机房的服务发送的,因此,在构建与消息写入请求相对应的三元关系组时,该三元关系组中包含的机房标识为本机房的标识、消息队列也是本机房的消息队列。Among them, in order to facilitate communication, in this embodiment, each service sends various request data through the local computer room where the service is located. Correspondingly, the message writing request received by each computer room is obviously sent by the service from the local computer room. , therefore, when constructing a triple relation group corresponding to a message write request, the computer room ID included in the triple relation group is the identification of the computer room, and the message queue is also the message queue of the computer room.

步骤S220:多个机房中的第二机房响应于与第二机房相对应的消息消费端触发的消息消费请求,将与消息消费请求相对应的消息队列确定为目标消息队列,根据配置元数据将目标消息队列所在的机房确定为目标机房。Step S220: In response to the message consumption request triggered by the message consumer corresponding to the second computer room, the second computer room in the plurality of computer rooms determines the message queue corresponding to the message consumption request as the target message queue, and according to the configuration metadata The computer room where the target message queue is located is determined as the target computer room.

具体地,多个机房中的第二机房可以是多个机房中的任一机房。由于每个机房分别对应于一个或多个服务,因此,当一个服务用于消费消息数据时,该服务作为消息消费端向该服务所对应的机房发送消息消费请求,在本实施例中,将该发送消息消费请求的服务所对应的机房作为第二机房。实质上,对于任一机房而言,只要该机房对应的服务作为消息消费端触发了消息消费请求,该机房则被称作第二机房。Specifically, the second computer room in the multiple computer rooms may be any computer room in the multiple computer rooms. Since each computer room corresponds to one or more services, 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 The computer room corresponding to the service for sending the message consumption request is used as the second computer room. In essence, for any computer room, as long as the service corresponding to the computer room triggers a message consumption request as a message consumer, the computer room is called the second computer room.

其中,在各个机房中设置有代理模块的前提下,本步骤由第二机房中的代理模块负责执行。具体地,第二机房中的代理模块接收到本机房的服务发来的消息消费请求后,执行以下操作:Wherein, on the premise that each computer room is provided with an agent module, this step is performed by the agent module in the second computer room. Specifically, after receiving the message consumption request sent by the service in the second computer room, the proxy module in the second computer room performs the following operations:

首先,解析该消息消费请求,以确定与消息消费请求相对应的消息队列(即待消费的消息队列),将其确定为目标消息队列。然后,查询配置元数据,根据查询结果确定目标消息队列所在的机房,将该机房确定为目标机房。由于配置元数据中记录了消息队列及其所在机房之间的对应关系,因此,基于配置元数据能够准确确定目标消息队列所在的机房,即目标机房。First, the message consumption request is parsed to determine the message queue corresponding to the message consumption request (that is, the message queue to be consumed), which is determined as the target message queue. Then, the configuration metadata is queried, the computer room where the target message queue is located is determined according to the query result, and the computer room is determined as the target computer room. Since the configuration metadata records the correspondence between the message queue and the computer room where it is located, the computer room where the target message queue is located, that is, the target computer room, can be accurately determined based on the configuration metadata.

其中,目标机房可以是多个机房中的任一机房,例如,目标机房有可能是上述的第一机房,也可能是不同于第一机房和第二机房的第三机房,当然,还可能是第二机房本身(此时,直接在第二机房的本机房内部获取消息数据即可)。总之,本发明不限定目标消息队列以及目标机房的具体位置,完全取决于业务实际需求。The target computer room may be any computer room among multiple computer rooms. For example, the target computer room may be the above-mentioned first computer room, or 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 obtained directly in the own computer room of the second computer room). In a word, the present invention does not limit the specific location of the target message queue and the target computer room, which completely depends on the actual needs of the business.

步骤S230:将目标机房中的目标消息队列的消息数据传输至第二机房,以供消息消费端消费。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.

具体地,在确定出目标机房后,将目标机房中的目标消息队列的消息数据传输至第二机房,以供消息消费端在本地进行消费。由此可见,任一机房接收到消息消费请求后,根据配置元数据确定待消费的消息队列所在的机房,进而从该机房获取数据。Specifically, after the target computer room is determined, 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. 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 data from the computer room.

具体实施时,通过位于目标机房与第二机房之间的机房专线,将目标机房中的目标消息队列的消息数据传输至第二机房。其中,任意两个机房之间通过机房专线进行网络通信,因此,通过位于目标机房与第二机房之间的机房专线,即可将目标机房中的目标消息队列的消息数据传输至第二机房。During 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. The network communication between any two computer rooms is 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.

具体地,数据传输操作可通过第二机房向目标机房发送传输请求的方式进行触发,相应地,目标机房根据接收到的传输请求中包含的消息队列的标识,向第二机房返回该消息队列中的消息数据。Specifically, the data transmission operation can be triggered by the second computer room sending a transmission request to the target computer room. Accordingly, the target computer room returns the message queue to the second computer room according to the identifier of the message queue included in the received transmission request. message data.

可选的,在本实施例中,为了提升消息数据的传输效率,分别在各个机房中设置同步模块,各个机房的同步模块与本机房中的代理模块相互通信,能够在代理模块的控制下进行数据同步操作。相应地,在将目标机房中的目标消息队列的消息数据传输至第二机房时,通过目标机房中的同步模块,将目标机房中的目标消息队列的消息数据传输至第二机房。Optionally, in this embodiment, in order to improve the transmission efficiency of message data, a synchronization module is set in each computer room, and the synchronization module in each computer room communicates with the proxy module in the local computer room, which can be performed under the control of the proxy module. Data synchronization operation. Correspondingly, when transmitting the message data of the target message queue in the target computer room to the second computer room, the synchronization module in the target computer room transmits the message data of the target message queue in the target computer room to the second computer room.

另外,发明人在实现本发明的过程中发现,消息消费端与待消费的消息队列之间通常具有固定的映射关系,例如,服务A、B均作为消费端消费第一消息队列中的消息,只要第一消息队列发生更新,则服务A、B则会作为消费端触发消息消费请求。另外,在服务A、B未发生机房迁移的前提下,服务A、B各自所在的机房也是固定的,例如,服务A在机房1,服务B在机房2,若第一消息队列位于机房3,则需要将位于机房3中的第一消息队列的内容分别传输至机房1和机房2。为了防止后续传输过程中的延迟,可以基于上述的对应关系,在监测到机房3中的第一消息队列发生更新时,将更新后的第一消息队列分别同步至机房1和机房2,以便于后续消费。In addition, the inventor found in the process of implementing the present invention that there is usually a fixed mapping relationship between the message consumer and the message queue to be consumed. For example, services A and B both serve as consumers to consume messages in the first message queue, As long as the first message queue is updated, services A and B will act as consumers to trigger a message consumption request. In addition, under the premise that services A and B are not relocated, the computer rooms where services A and B are located are also fixed. For example, service A is in computer room 1 and service B is in computer room 2. If the first message queue is located in computer room 3, Then, the content of the first message queue located in the computer room 3 needs to be transmitted to the computer room 1 and the computer room 2 respectively. In order to prevent the delay in the subsequent transmission process, based on the above-mentioned corresponding relationship, when monitoring the update of the first message queue in the computer room 3, the updated first message queue can be synchronized to the computer room 1 and the computer room 2 respectively, so as to facilitate subsequent consumption.

为了实现上述目的,在本实施例中,需要确定各个消费端与其待消费的消息队列之间的对应关系,为此,每当多个机房中的第二机房响应于与第二机房相对应的消息消费端触发的消息消费请求时,进一步根据与消息消费请求相对应的消息消费端、与消息消费请求相对应的目标消息队列以及与消息消费端相对应的第二机房标识,生成一组三元关系组,将该三元关系组添加到配置元数据中。由此可见,根据消息消费请求生成的三元关系组用于表示消息消费端、待消费的消息队列、消息消费端所在的机房之间的对应关系。根据该对应关系能够确定后续的同步方向。In order to achieve the above purpose, in this embodiment, it is necessary to determine the corresponding relationship between each consumer and the message queue to be consumed. When a message consumption request is triggered by the message consumption end, a set of three messages is generated according to the message consumption end corresponding to the message consumption request, the target message queue corresponding to the message consumption request, and the identifier of the second computer room corresponding to the message consumption end. Meta relationship group, which is added to the configuration metadata. It can be seen that the triple relation group generated according to the message consumption request is used to represent the correspondence between the message consumer, the message queue to be consumed, and the computer room where the message consumer is located. The subsequent synchronization direction can be determined according to the corresponding relationship.

相应地,为了提升同步效率,降低后续消费过程中的传输时延,任一机房中的同步模块进一步用于:将本机房中的任一消息队列确定为待同步消息队列,根据配置元数据中的三元关系组确定待同步消息队列的各个消息消费端所对应的机房,并将待同步消息队列中的消息数据同步至各个消息消费端所对应的机房。具体地,各个机房中的同步模块可以定时轮询本机房中的各个消息队列是否发生更新,并在任一消息队列发生更新时,根据配置元数据中的三元关系组确定与该更新后的消息队列相对应的消费端及其所在的机房,进而将该更新后的消息队列同步至消费端所在的机房。Correspondingly, in order to improve the synchronization efficiency and reduce the transmission delay in the subsequent consumption process, the synchronization module in any computer room is further used to: determine any message queue in the computer room as the message queue to be synchronized, according to the configuration metadata. The ternary relationship group of the message queue to be synchronized determines the computer room corresponding to each message consumer of the message queue to be synchronized, and synchronizes the message data in the message queue to be synchronized to the computer room corresponding to each message consumer. Specifically, the synchronization module in each computer room can periodically poll whether each message queue in the computer room is updated, and when any message queue is updated, according to the ternary relationship group in the configuration metadata, determine the message related to the updated message. The consumer terminal corresponding to the queue and the computer room where it is located, and then the updated message queue is synchronized to the computer room where the consumer terminal is located.

另外,虽然上述的三元关系组能够存储消息消费端、待消费的消息队列以及消息消费端所在的机房标识之间的对应关系,但是,发明人在实现本发明的过程中发现,消息消费端与待消费的消息队列之间的关系可能发生变化,且消息消费端所在的机房也可能因机房迁移操作而发生改变,因此,为了适应上述变化,本实施例中的三元关系组能够动态更新,例如,能够根据接收到的消息消费端在切换机房后触发的消息消费请求进行动态更新,还能够根据消息消费端增加新的待消费的消息队列时进行动态更新。In addition, although the above-mentioned ternary relationship group can store the correspondence between the message consumer, the message queue to be consumed, and the identifier of the computer room where the message consumer is located, the inventor found in the process of implementing the present invention that the message consumer The relationship with the message queue to be consumed may change, and the computer room where the message consumer is located may also change due to the computer room migration operation. Therefore, in order to adapt to the above changes, the ternary relationship group in this embodiment can be dynamically updated. For example, it can be dynamically updated according to the received message consumption request triggered by the message consumer after switching the computer room, and can also be dynamically updated according to when the message consumer adds a new message queue to be consumed.

为了感知三元关系组中的对应关系的变化情况,在本实施例中,每当多个机房中的第二机房根据消息消费请求生成一组三元关系组之后,进一步判断配置元数据中是否已存储有与该消息消费请求中包含的消息消费端相对应的三元关系组,若有,进一步获取已存储的与该消息消费请求中包含的消息消费端相对应的三元关系组中的机房信息,将获取的机房信息与本次生成的三元关系组中的机房信息进行比较,根据比较结果判断该消息消费请求中包含的消息消费端是否发生机房迁移。例如,若获取的机房信息与本次生成的三元关系组中的机房信息不一致,则确定该消息消费请求中包含的消息消费端发生了机房迁移。在判断出机房迁移的情况下,需要从配置元数据中删除迁移前所对应的三元关系组,仅保留迁移后对应的三元关系组,从而实现对应关系的动态更新。In order to perceive the change of the corresponding relationship in the ternary relationship group, in this embodiment, every time the second computer room in the multiple computer rooms generates a set of ternary relationship groups according to the message consumption request, it is further judged whether the configuration metadata is The triple relation group corresponding to the message consumer included in the message consumption request has been stored. If so, further obtain the stored triple relation group corresponding to the message consumer included in the message consumption request. Computer room information, compare the acquired computer room information with the computer room information in the ternary relationship group generated this time, and judge whether the message consumer included in the message consumption request has undergone computer room migration according to the comparison result. For example, if the acquired computer room information is inconsistent with the computer room information in the ternary relationship group generated this time, it is determined that the message consumer included in the message consumption request has undergone computer room migration. When it is determined that the computer room is to be migrated, it is necessary to delete the ternary relationship group corresponding to the migration from the configuration metadata, and only retain the ternary relationship group corresponding to the migration, so as to realize the dynamic update of the corresponding relationship.

同理,每当多个机房中的第二机房根据消息消费请求生成一组三元关系组之后,进一步判断配置元数据中是否已存储有与该消息消费请求中包含的消息消费端相对应的三元关系组,若有,进一步获取已存储的与该消息消费请求中包含的消息消费端相对应的三元关系组中的待消费的消息队列的信息,将获取的消息队列的信息与本次生成的三元关系组中的消息队列的信息进行比较,根据比较结果判断该消息消费请求中包含的消息消费端是否增加了新的待消费消息队列,若是,则在配置元数据中新增上述的对应关系。Similarly, every time the second computer room in the multiple computer rooms generates a set of ternary relationship groups according to the message consumption request, it is further judged whether the configuration metadata has stored the corresponding message consumer included in the message consumption request. If there is a ternary relationship group, further obtain the stored information of the message queue to be consumed in the ternary relationship group corresponding to the message consumer included in the message consumption request, and compare the obtained message queue information with this Compare the information of the message queues in the ternary relationship group generated for the second time, and judge whether the message consumer included in the message consumption request has added a new message queue to be consumed according to the comparison result. If so, add a new message queue to the configuration metadata. the above-mentioned correspondence.

总而言之,本实施例中的配置元数据能够根据各次接收到的消息消费请求进行动态更新,以动态维护各个消息消费端当前所属的机房以及各个消息消费端对应的待消费消息队列。相应地,各个机房中的同步模块基于动态变化的配置元数据,动态确定本机房中的各个消息队列所对应的各个消息消费端及其对应的机房,以便将消息队列中的消息数据同步至各个消息消费端所对应的机房。例如,某机房中存储有消息队列M,相应地,该机房的同步模块通过分析配置元数据,确定消息队列M的消费端共有两个,分别为位于机房1的第一消费端,以及位于机房2的第二消费端,则该同步模块在消息队列M发生更新后,将更新内容同步至机房1以及机房2,以便为后续的消费过程提供便利。All in all, the configuration metadata in this embodiment can be dynamically updated according to each received message consumption request, so as to dynamically maintain the computer room to which each message consumer currently belongs and the message queue to be consumed corresponding to each message consumer. Correspondingly, the synchronization module in each computer room dynamically determines each message consumer corresponding to each message queue in the computer room and its corresponding computer room based on the dynamically changing configuration metadata, so as to synchronize the message data in the message queue to each The computer room corresponding to the message consumer. For example, a message queue M is stored in a computer room. Correspondingly, the synchronization module of the computer room determines that there are two consumers of the message queue M by analyzing the configuration metadata, namely the first consumer located in the computer room 1 and the consumer located in the computer room. 2, the synchronization module synchronizes the updated content to the computer room 1 and the computer room 2 after the message queue M is updated, so as to provide convenience for the subsequent consumption process.

具体同步时,同步模块代替消息队列的消费端进行消费,并将消费后的数据写入待同步的机房。例如,同步模块代替消息队列M的消费端消费消息队列M中的数据,并将消费后的数据内容分别写入机房1和机房2。During specific synchronization, the synchronization module consumes instead of the consumer of the message queue, and writes the consumed data into the computer room to be synchronized. For example, the synchronization module consumes the data in the message queue M instead of the consumer of the message queue M, and writes the consumed data content into the computer room 1 and the computer room 2 respectively.

在一个具体的示例中,消息生产端对应于实时服务,消息消费端对应于与实时服务相关联的非实时服务。由于实时服务的实时性要求较高,因此,无论作为消息生产端的服务位于哪个机房,都直接在该机房本地写入消息队列,从而避免了通过机房专线跨机房传输的延迟和抖动问题,并且,也无需关心消费端所在的机房位置,尤其适用于服务数量众多的复杂业务场景。由于消息消费端对应于非实时服务,因此,经由机房专线实现的数据传输过程不会对业务造成影响。In a specific example, the message producer corresponds to the real-time service, and the message consumer corresponds to the non-real-time service associated with the real-time service. Due to the high real-time requirements of real-time services, no matter which computer room the service as the message producer is located in, the message queue is directly written to the local computer room, thus avoiding the delay and jitter problems of cross-computer room transmission through the special line of the computer room, and, There is no need to care about the location of the computer room where the consumer end is located, especially 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 via the dedicated line in the computer room will not affect the business.

例如,当本实施例中的方式应用于电子书应用时,消息生产端可以为电子书中的领取书籍服务,当用户领取书籍后,在对应的消息队列中新增一条数据记录,以记录用户与领取的书籍之间的对应关系,由于领书操作的实时性较高,为了避免用户长时间等待领书操作的结果反馈,通过将数据记录写入领取书籍服务所在的本地机房的方式提升响应速度,避免用户长时间等待。相应地,消息消费端可以为电子书中的积分更新服务,当用户领取书籍后,用户积分随之更新,由于积分更新的操作可以异步完成,因此,将消费过程设计为通过机房专线实现的跨机房传输方式不会对用户的使用造成影响,从而有效解决了电子书应用中的实时服务卡顿的问题。For example, when the method in this embodiment is applied to an e-book application, the message producing end can serve for book collection in the e-book. After the user receives the book, a new data record is added to the corresponding message queue to record the user The correspondence between the book collection and the book collection operation is very real-time. In order to avoid users waiting for a long time for the result feedback of the book collection operation, the response is improved by writing the data records into the local computer room where the book collection service is located. speed, avoiding long waits for users. Correspondingly, the message consumer can update the points in the e-book. When the user receives the book, the user points will be updated accordingly. Since the point update operation can be completed asynchronously, the consumption process is designed as a cross-border transaction through the computer room dedicated line. The transmission method in the computer room will not affect the use of users, thus effectively solving the problem of real-time service freezes in e-book applications.

另外,在一个具体示例中,消息队列可基于高级消息队列协议(AMQP)实现,例如,可以采用RabbitMQ实现。其中,同步模块可通过同步开关进行控制,当同步开关开启时,能够实现同步服务;当同步开关关闭时,则暂时不进行同步服务,通过在各个机房中设置用于控制各个同步模块的同步开关,能够根据业务情况灵活确定是否进行消息队列的同步操作,从而能够在业务繁忙时暂停同步操作,而在业务空闲时进行同步操作,从而将同步操作对业务系统的影响降至最低。In addition, in a specific example, the message queue may be implemented based on the Advanced Message Queuing Protocol (AMQP), for example, may be implemented using RabbitMQ. Among them, the synchronization module can be controlled by the synchronization switch. When the synchronization switch is turned on, the synchronization service can be realized; when the synchronization switch is turned off, the synchronization service will not be performed temporarily. By setting the synchronization switch for controlling each synchronization module in each computer room , which can 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.

本实施例中的方式尤其适用于跨项目生产场景,生产端和消费端的数量众多,且一个生产端可能对应于多个消费端,且一个消费端也可能对应于多个生产端,在这种复杂的业务场景中,很难预先确定生产的消息队列所对应的消费端的数量以及各个消费端所在的机房,因此,通过由代理模块动态维护配置元数据的方式能够很好地解决上述问题,并且,在消费端切换机房后,配置元数据能够自动实现动态更新,从而不受机房切换的影响,及时将消息数据同步至切换后的机房进行消费。The method in this embodiment is especially suitable for cross-project production scenarios, where there are a large number of producers and consumers, and one producer may correspond to multiple consumers, and one consumer may also correspond to multiple producers. In complex business scenarios, it is difficult to pre-determine the number of consumers corresponding to the produced message queues and the computer room where each consumer is located. Therefore, the above problems can be well solved by dynamically maintaining configuration metadata by the proxy module, and , After the consumer side switches the computer room, the configuration metadata can be automatically updated dynamically, so that it is not affected by the switch of the computer room, and the message data can be synchronized to the switched computer room in time for consumption.

其中,本实施例中的代理模块也可以称作代理组件或代理元件,具体可通过软件编程方式实现,或者也可以通过硬件方式实现,本发明对此不做限定。同理,本实施例中的同步模块也可以称作同步组件或同步元件,具体可通过软件编程方式实现,或者也可以通过硬件方式实现,本发明对此不做限定。The agent module in this embodiment may also be called an agent component or an agent element, which may be implemented in a software programming manner, or may also be implemented in a hardware manner, which is not limited in the present invention. Similarly, the synchronization module in this embodiment may also be referred to as a synchronization component or a synchronization element, which may be implemented in a software programming manner, or may also be implemented in a hardware manner, which is not limited in the present invention.

综上可知,本实施例中的方式避免了预先确定消费端数量及其所在机房的繁琐操作,且避免了跨机房生产消息所导致的延迟问题,能够适用于实时性要求较高的业务场景中。通过设置代理模块,能够将消息处理过程由代理模块接管,从而便于统一维护配置元数据。并且,基于配置元数据能够确定各个消息队列所对应的消费端及其所在的机房,进而由同步模块提前完成同步操作,从而提升后续消费的效率。To sum up, the method in this embodiment avoids the tedious operation of pre-determining the number of consumers and the computer room where they are located, and avoids the delay problem caused by the production of messages across computer rooms, and can be applied to business scenarios with high real-time requirements. . By setting the 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 end corresponding to each message queue and the computer room where it is located can be determined, and then the synchronization module can complete the synchronization operation in advance, thereby improving the efficiency of subsequent consumption.

实施例三Embodiment 3

本申请实施例提供了一种非易失性计算机存储介质,所述计算机存储介质存储有至少一可执行指令,该计算机可执行指令可执行上述任意方法实施例中的基于多机房实现的消息队列的管理方法。An embodiment of the present application provides a non-volatile computer storage medium, where the computer storage medium stores at least one executable instruction, and the computer-executable instruction can execute the message queue implemented based on multiple computer rooms in any of the foregoing method embodiments management method.

可执行指令具体可以用于使得处理器执行以下操作:Executable instructions can specifically be used to cause the processor to perform the following operations:

多个机房中的第一机房响应于与所述第一机房相对应的消息生产端触发的消息写入请求,将所述消息写入请求中包含的消息数据写入与所述第一机房相对应的消息队列,并将所述第一机房相对应的消息队列以及所述第一机房之间的队列机房映射关系存储到配置元数据中;In response to a message write request triggered by a message producer corresponding to the first computer room, the first computer room in the plurality of computer rooms writes the message data contained in the message write request into the first computer room. corresponding message queue, and store the message queue corresponding to the first computer room and the queue-computer room mapping relationship between the first computer room in the configuration metadata;

多个机房中的第二机房响应于与所述第二机房相对应的消息消费端触发的消息消费请求,将与所述消息消费请求相对应的消息队列确定为目标消息队列,根据所述配置元数据将所述目标消息队列所在的机房确定为目标机房,将所述目标机房中的所述目标消息队列的消息数据传输至所述第二机房,以供所述消息消费端消费。The second computer room in the plurality of computer rooms determines the message queue corresponding to the message consumption request as the target message queue in response to the message consumption request triggered by the message consumption terminal corresponding to the second computer room, and according to the configuration The metadata determines the computer room where the target message queue is located as the target computer room, 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 consumer.

在一种可选的实现方式中,可执行指令具体可以用于使得处理器执行以下操作:分别在各个机房中设置代理模块,各个机房的代理模块共同维护所述配置元数据;则所述将所述消息写入请求中包含的消息数据写入与所述第一机房相对应的消息队列,并将所述第一机房相对应的消息队列以及所述第一机房之间的队列机房映射关系存储到配置元数据中的步骤由第一机房中的代理模块执行;且所述将与所述消息消费请求相对应的消息队列确定为目标消息队列,根据所述配置元数据将所述目标消息队列所在的机房确定为目标机房的步骤由第二机房中的代理模块执行。In an optional implementation manner, the executable instructions can specifically be used to cause the processor to perform the following operations: respectively setting proxy modules in each computer room, and the proxy modules in each computer room jointly maintain the configuration metadata; The message data contained in the message write request is written into the message queue corresponding to the first computer room, and the message queue corresponding to the first computer room and the queue-computer room mapping relationship between the first computer rooms The step of storing the configuration metadata is performed by an agent module in the first computer room; and the message queue corresponding to the message consumption request is determined as a target message queue, and the target message is stored according to the configuration metadata. The step of determining the computer room where the queue is located as the target computer room is performed by the agent module in the second computer room.

在一种可选的实现方式中,可执行指令具体可以用于使得处理器执行以下操作:分别在各个机房中设置同步模块,各个同步模块与本机房中的代理模块相互通信;则所述将所述目标机房中的所述目标消息队列的消息数据传输至所述第二机房包括:通过所述目标机房中的同步模块,将所述目标机房中的目标消息队列的消息数据传输至第二机房。In an optional implementation manner, the executable instructions can specifically be used to cause the processor to perform the following operations: setting up synchronization modules in each computer room, and each synchronization module communicates with the agent module in the computer room; 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. engine room.

在一种可选的实现方式中,可执行指令具体可以用于使得处理器执行以下操作:根据与所述消息消费请求相对应的消息消费端、与所述消息消费请求相对应的目标消息队列以及与所述消息消费端相对应的第二机房标识,生成一组三元关系组,将所述三元关系组添加到所述配置元数据中。In an optional implementation manner, the executable instructions may specifically be used to cause the processor to perform the following operations: according to the message consumer corresponding to the message consumption request, the target message queue corresponding to the message consumption request and the identifier of the second computer room corresponding to the message consumer, generate a set of ternary relationship groups, and add the ternary relationship groups to the configuration metadata.

在一种可选的实现方式中,可执行指令具体可以用于使得处理器执行以下操作:所述同步模块将本机房中的任一消息队列确定为待同步消息队列,根据所述配置元数据中的三元关系组确定所述待同步消息队列的各个消息消费端所对应的机房,并将所述待同步消息队列中的消息数据同步至所述各个消息消费端所对应的机房。In an optional implementation manner, the executable instructions may specifically be used to cause the processor to perform the following operations: the synchronization module determines any message queue in the local computer room as the message queue to be synchronized, and according to the configuration metadata The ternary relationship group in determines the computer room corresponding to each message consumer of the message queue to be synchronized, and synchronizes the message data in the message queue to be synchronized to the computer room corresponding to each message consumer.

在一种可选的实现方式中,所述三元关系组用于存储消息消费端、待消费的消息队列以及所述消息消费端所在的机房标识之间的对应关系;并且,所述三元关系组能够根据接收到的消息消费端在切换机房后触发的消息消费请求进行动态更新。In an optional implementation manner, the ternary relationship group is used to store the correspondence between the message consumer, the message queue to be consumed, and the identifier of the computer room where the message consumer is located; and, the ternary The relationship group can be dynamically updated according to the received message consumption request triggered by the message consumer after switching the computer room.

在一种可选的实现方式中,可执行指令具体可以用于使得处理器执行以下操作:In an optional implementation manner, the executable instructions may specifically be used to cause the processor to perform the following operations:

通过位于所述目标机房与所述第二机房之间的机房专线,将所述目标机房中的目标消息队列的消息数据传输至所述第二机房。The message data of the target message queue in the target computer room is transmitted to the second computer room through a computer room dedicated line located between the target computer room and the second computer room.

在一种可选的实现方式中,所述消息生产端对应于实时服务,所述消息消费端对应于与所述实时服务相关联的非实时服务。In an optional implementation manner, 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.

实施例四Embodiment 4

图3示出了根据本发明另一个实施例的一种电子设备的结构示意图,本发明具体实施例并不对电子设备的具体实现做限定。FIG. 3 shows a schematic structural diagram of an electronic device according to another embodiment of the present invention. The specific embodiment of the present invention does not limit the specific implementation of the electronic device.

如图3所示,该电子设备可以包括:处理器(processor)302、通信接口(Communications Interface)304、存储器(memory)306、以及通信总线308。As shown in FIG. 3 , the electronic device may include: a processor (processor) 302 , a communication interface (Communications Interface) 304 , a memory (memory) 306 , and a communication bus 308 .

其中:处理器302、通信接口304、以及存储器306通过通信总线308完成相互间的通信。通信接口304,用于与其它设备比如客户端或其它服务器等的网元通信。处理器302,用于执行程序310,具体可以执行上述基于多机房实现的消息队列的管理方法实施例中的相关步骤。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 for communicating with network elements of other devices such as clients or other servers. The processor 302 is configured to execute the program 310, and may specifically execute the relevant steps in the above-mentioned embodiments of the method for managing message queues implemented based on multiple computer rooms.

具体地,程序310可以包括程序代码,该程序代码包括计算机操作指令。Specifically, the program 310 may include program code including computer operation instructions.

处理器302可能是中央处理器CPU,或者是特定集成电路ASIC(ApplicationSpecific Integrated Circuit),或者是被配置成实施本发明实施例的一个或多个集成电路。电子设备包括的一个或多个处理器,可以是同一类型的处理器,如一个或多个CPU;也可以是不同类型的处理器,如一个或多个CPU以及一个或多个ASIC。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 embodiments of the present invention. The one or more processors included in the electronic device may be the same type of processors, such as one or more CPUs; or may be different types of processors, such as one or more CPUs and one or more ASICs.

存储器306,用于存放程序310。存储器306可能包含高速RAM存储器,也可能还包括非易失性存储器(non-volatile memory),例如至少一个磁盘存储器。The memory 306 is used to store the program 310 . Memory 306 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk memory.

程序310具体可以用于使得处理器302执行以下操作:The program 310 can specifically be used to cause the processor 302 to perform the following operations:

多个机房中的第一机房响应于与所述第一机房相对应的消息生产端触发的消息写入请求,将所述消息写入请求中包含的消息数据写入与所述第一机房相对应的消息队列,并将所述第一机房相对应的消息队列以及所述第一机房之间的队列机房映射关系存储到配置元数据中;In response to a message write request triggered by a message producer corresponding to the first computer room, the first computer room in the plurality of computer rooms writes the message data contained in the message write request into the first computer room. corresponding message queue, and store the message queue corresponding to the first computer room and the queue-computer room mapping relationship between the first computer room in the configuration metadata;

多个机房中的第二机房响应于与所述第二机房相对应的消息消费端触发的消息消费请求,将与所述消息消费请求相对应的消息队列确定为目标消息队列,根据所述配置元数据将所述目标消息队列所在的机房确定为目标机房,将所述目标机房中的所述目标消息队列的消息数据传输至所述第二机房,以供所述消息消费端消费。In response to the message consumption request triggered by the message consumer corresponding to the second computer room, the second computer room in the plurality of computer rooms determines the message queue corresponding to the message consumption request as the target message queue, and according to the configuration The metadata determines the computer room where the target message queue is located as the target computer room, 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 consumer.

在一种可选的实现方式中,可执行指令具体可以用于使得处理器执行以下操作:分别在各个机房中设置代理模块,各个机房的代理模块共同维护所述配置元数据;则所述将所述消息写入请求中包含的消息数据写入与所述第一机房相对应的消息队列,并将所述第一机房相对应的消息队列以及所述第一机房之间的队列机房映射关系存储到配置元数据中的步骤由第一机房中的代理模块执行;且所述将与所述消息消费请求相对应的消息队列确定为目标消息队列,根据所述配置元数据将所述目标消息队列所在的机房确定为目标机房的步骤由第二机房中的代理模块执行。In an optional implementation manner, the executable instructions can specifically be used to cause the processor to perform the following operations: respectively setting proxy modules in each computer room, and the proxy modules in each computer room jointly maintain the configuration metadata; The message data contained in the message write request is written into the message queue corresponding to the first computer room, and the message queue corresponding to the first computer room and the queue-computer room mapping relationship between the first computer rooms The step of storing the configuration metadata is performed by the agent module in the first computer room; and the message queue corresponding to the message consumption request is determined as the target message queue, and the target message is stored according to the configuration metadata. The step of determining the computer room where the queue is located as the target computer room is performed by the agent module in the second computer room.

在一种可选的实现方式中,可执行指令具体可以用于使得处理器执行以下操作:分别在各个机房中设置同步模块,各个同步模块与本机房中的代理模块相互通信;则所述将所述目标机房中的所述目标消息队列的消息数据传输至所述第二机房包括:通过所述目标机房中的同步模块,将所述目标机房中的目标消息队列的消息数据传输至第二机房。In an optional implementation manner, the executable instructions can specifically be used to cause the processor to perform the following operations: setting up synchronization modules in each computer room, and each synchronization module communicates with the agent module in the computer room; 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. engine room.

在一种可选的实现方式中,可执行指令具体可以用于使得处理器执行以下操作:根据与所述消息消费请求相对应的消息消费端、与所述消息消费请求相对应的目标消息队列以及与所述消息消费端相对应的第二机房标识,生成一组三元关系组,将所述三元关系组添加到所述配置元数据中。In an optional implementation manner, the executable instructions may specifically be used to cause the processor to perform the following operations: according to the message consumer corresponding to the message consumption request, the target message queue corresponding to the message consumption request and the identifier of the second computer room corresponding to the message consumer, generate a set of ternary relationship groups, and add the ternary relationship groups to the configuration metadata.

在一种可选的实现方式中,可执行指令具体可以用于使得处理器执行以下操作:所述同步模块将本机房中的任一消息队列确定为待同步消息队列,根据所述配置元数据中的三元关系组确定所述待同步消息队列的各个消息消费端所对应的机房,并将所述待同步消息队列中的消息数据同步至所述各个消息消费端所对应的机房。In an optional implementation manner, the executable instructions may specifically be used to cause the processor to perform the following operations: the synchronization module determines any message queue in the local computer room as the message queue to be synchronized, and according to the configuration metadata The ternary relationship group in determines the computer room corresponding to each message consumer of the message queue to be synchronized, and synchronizes the message data in the message queue to be synchronized to the computer room corresponding to each message consumer.

在一种可选的实现方式中,所述三元关系组用于存储消息消费端、待消费的消息队列以及所述消息消费端所在的机房标识之间的对应关系;并且,所述三元关系组能够根据接收到的消息消费端在切换机房后触发的消息消费请求进行动态更新。In an optional implementation manner, the ternary relationship group is used to store the correspondence between the message consumer, the message queue to be consumed, and the identifier of the computer room where the message consumer is located; and, the ternary The relationship group can be dynamically updated according to the received message consumption request triggered by the message consumer after switching the computer room.

在一种可选的实现方式中,可执行指令具体可以用于使得处理器执行以下操作:In an optional implementation manner, the executable instructions may specifically be used to cause the processor to perform the following operations:

通过位于所述目标机房与所述第二机房之间的机房专线,将所述目标机房中的目标消息队列的消息数据传输至所述第二机房。The message data of the target message queue in the target computer room is transmitted to the second computer room through a computer room dedicated line located between the target computer room and the second computer room.

在一种可选的实现方式中,所述消息生产端对应于实时服务,所述消息消费端对应于与所述实时服务相关联的非实时服务。In an optional implementation manner, 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.

在此提供的算法和显示不与任何特定计算机、虚拟系统或者其它设备固有相关。各种通用系统也可以与基于在此的示教一起使用。根据上面的描述,构造这类系统所要求的结构是显而易见的。此外,本发明也不针对任何特定编程语言。应当明白,可以利用各种编程语言实现在此描述的本发明的内容,并且上面对特定语言所做的描述是为了披露本发明的最佳实施方式。The algorithms and displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used with teaching based on this. The structure required to construct such a system is apparent from the above description. Furthermore, the present invention is not directed to any particular programming language. It is to be understood that various programming languages may be used to implement the inventions described herein, and that the descriptions of specific languages above are intended to disclose the best mode for carrying out the invention.

在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。In the description provided herein, numerous specific details are set forth. It will be understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.

类似地,应当理解,为了精简本公开并帮助理解各个发明方面中的一个或多个,在上面对本发明的示例性实施例的描述中,本发明的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该公开的方法解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确记载的特征更多的特征。更确切地说,如下面的权利要求书所反映的那样,发明方面在于少于前面公开的单个实施例的所有特征。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为本发明的单独实施例。Similarly, it is to be understood that in the above description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together into a single embodiment, figure, or its description. This disclosure, however, should not be construed as reflecting an intention that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the Detailed Description are hereby expressly incorporated into this Detailed Description, with each claim standing on its own as a separate embodiment of this invention.

本领域那些技术人员可以理解,可以对实施例中的设备中的模块进行自适应性地改变并且把它们设置在与该实施例不同的一个或多个设备中。可以把实施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它们分成多个子模块或子单元或子组件。除了这样的特征和/或过程或者单元中的至少一些是相互排斥之外,可以采用任何组合对本说明书(包括伴随的权利要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征来代替。Those skilled in the art will understand that the modules in the device in the embodiment can be adaptively changed and arranged in one or more devices different from the embodiment. The modules or units or components in the embodiments may be combined into one module or unit or component, and further they may be divided into multiple sub-modules or sub-units or sub-assemblies. All features disclosed in this specification (including accompanying claims, abstract and drawings) and any method so disclosed may be employed in any combination, unless at least some of such features and/or procedures or elements are mutually exclusive. All processes or units of equipment are combined. Each feature disclosed in this specification (including accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.

此外,本领域的技术人员能够理解,尽管在此的一些实施例包括其它实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本发明的范围之内并且形成不同的实施例。例如,在下面的权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使用。Furthermore, it will be understood by those skilled in the art that although some of the embodiments herein include certain features, but not others, included in other embodiments, that combinations of features of the different embodiments are intended to be within the scope of the present invention And form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.

应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包含”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。It should be noted that the above-described embodiments illustrate rather than limit the invention, and that alternative embodiments may be devised by those skilled in the art 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 a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by one and the same item of hardware. The use of the words first, second, and third, etc. do not denote any order. These words can be interpreted as names.

Claims (10)

1. A management method of message queues realized based on multiple machine rooms comprises the following steps:
responding to a message writing request triggered by a message production end corresponding to a first machine room by a first machine room in a plurality of machine rooms, writing message data contained in the message writing request into a message queue corresponding to the first machine room, and storing a message queue corresponding to the first machine room and a queue machine room mapping relation between the first machine room into configuration metadata;
responding to a message consumption request triggered by a message consumption end corresponding to a second machine room, determining a message queue corresponding to the message consumption request as a target message queue by the second machine room in the plurality of machine rooms, determining the machine room where the target message queue is located as a target machine room according to the configuration metadata, and transmitting message data of the target message queue in the target machine room to the second machine room for consumption by the message consumption end.
2. The method of claim 1, wherein prior to performing the method, further comprising: respectively setting agent modules in each machine room, wherein the agent modules of the machine rooms maintain the configuration metadata together;
the step of writing the message data contained in the message write request into the message queue corresponding to the first machine room, and storing the message queue corresponding to the first machine room and the queue machine room mapping relationship between the first machine rooms into configuration metadata is executed by an agent module in the first machine room;
and the step of determining the message queue corresponding to the message consumption request as a target message queue and determining the machine room where the target message queue is located as a target machine room according to the configuration metadata is executed by an agent module in a second machine room.
3. The method of claim 2, wherein prior to performing the method, further comprising: setting synchronous modules in each machine room respectively, wherein each synchronous module is communicated with the agent module in the machine room;
the transmitting the message data of the target message queue in the target machine room to the second machine room includes: and transmitting the message data of the target message queue in the target machine room to a second machine room through a synchronization module in the target machine room.
4. The method of claim 3, wherein a second one of the plurality of kiosks responding to a message consumption request triggered by a message consumption peer corresponding to the second one further comprises:
and generating a group of ternary relationship groups according to a message consumption end corresponding to the message consumption request, a target message queue corresponding to the message consumption request and a second machine room identifier corresponding to the message consumption end, and adding the ternary relationship groups into the configuration metadata.
5. The method of claim 4, wherein the method further comprises: and the synchronization module determines any message queue in the machine room as a message queue to be synchronized, determines the machine room corresponding to each message consumption end of the message queue to be synchronized according to the ternary relationship group in the configuration metadata, and synchronizes the message data in the message queue to be synchronized to the machine room corresponding to each message consumption end.
6. The method according to claim 4 or 5, wherein the ternary relationship group is used for storing the corresponding relationship between a message consumption end, a message queue to be consumed and a machine room identifier where the message consumption end is located; and the three-element relation group can be dynamically updated according to a received message consumption request triggered by the message consumption end after the machine room is switched.
7. The method of any of claims 1-6, wherein the transmitting message data of the target message queue in the target room to the second room comprises:
and transmitting the message data of the target message queue in the target machine room to the second machine room through a machine room special line between the target machine room and the second machine room.
8. The method of any of claims 1-7, wherein 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.
9. An electronic device, comprising: the system comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete mutual communication through the communication bus;
the memory is configured to store at least one executable instruction that causes the processor to perform the method of any of claims 1-8.
10. A computer storage medium having stored therein at least one executable instruction that causes a processor to perform the method of any one of claims 1-8.
CN202010905108.0A 2020-09-01 2020-09-01 Message queue management method based on multi-machine-room implementation and electronic equipment Active CN112052104B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010905108.0A CN112052104B (en) 2020-09-01 2020-09-01 Message queue management method based on multi-machine-room implementation and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010905108.0A CN112052104B (en) 2020-09-01 2020-09-01 Message queue management method based on multi-machine-room implementation and electronic equipment

Publications (2)

Publication Number Publication Date
CN112052104A true CN112052104A (en) 2020-12-08
CN112052104B CN112052104B (en) 2025-07-29

Family

ID=73607282

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010905108.0A Active CN112052104B (en) 2020-09-01 2020-09-01 Message queue management method based on multi-machine-room implementation and electronic equipment

Country Status (1)

Country Link
CN (1) CN112052104B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113794757A (en) * 2021-08-31 2021-12-14 百融至信(北京)征信有限公司 Method and system for remote synchronization of redis cluster based on rabbitmq
CN117950888A (en) * 2024-03-25 2024-04-30 民航成都电子技术有限责任公司 Airport message management method, device, medium and computing equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108256002A (en) * 2017-12-31 2018-07-06 广东欧珀移动通信有限公司 Across computer room method of data synchronization, device, system and server
CN108347477A (en) * 2018-01-24 2018-07-31 广东欧珀移动通信有限公司 Data transmission method, device and server
CN110740145A (en) * 2018-07-18 2020-01-31 北京京东尚科信息技术有限公司 Message consumption method, device, storage medium and electronic equipment
WO2020140661A1 (en) * 2019-01-04 2020-07-09 深圳壹账通智能科技有限公司 Data synchronization method and system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108256002A (en) * 2017-12-31 2018-07-06 广东欧珀移动通信有限公司 Across computer room method of data synchronization, device, system and server
CN108347477A (en) * 2018-01-24 2018-07-31 广东欧珀移动通信有限公司 Data transmission method, device and server
CN110740145A (en) * 2018-07-18 2020-01-31 北京京东尚科信息技术有限公司 Message consumption method, device, storage medium and electronic equipment
WO2020140661A1 (en) * 2019-01-04 2020-07-09 深圳壹账通智能科技有限公司 Data synchronization method and system

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113794757A (en) * 2021-08-31 2021-12-14 百融至信(北京)征信有限公司 Method and system for remote synchronization of redis cluster based on rabbitmq
CN113794757B (en) * 2021-08-31 2024-03-19 百融至信(北京)科技有限公司 Redis cluster off-site synchronization method and system based on rabitmq
CN117950888A (en) * 2024-03-25 2024-04-30 民航成都电子技术有限责任公司 Airport message management method, device, medium and computing equipment

Also Published As

Publication number Publication date
CN112052104B (en) 2025-07-29

Similar Documents

Publication Publication Date Title
CN111723160B (en) Multi-source heterogeneous incremental data synchronization method and system
US20150363340A1 (en) Providing multiple synchronous serial console sessions using data buffering
CN108055255A (en) A kind of event base, expansible data management system and its management method
CN113596085B (en) Data processing method, system and device
CN111259022B (en) Information synchronization method, synchronization system, computer equipment and medium
WO2024037629A1 (en) Data integration method and apparatus for blockchain, and computer device and storage medium
CN105373563B (en) Database switching method and device
CN119254780A (en) Large model processing method, device, equipment and medium based on distributed cache
CN112052104A (en) Management method and electronic equipment of message queue based on multi-room implementation
CN115168440A (en) Data reading and writing method, distributed storage system, device, equipment and storage medium
CN115550382A (en) Configuration item synchronization method, device, system and equipment
CN103338160B (en) Based on optimization system and the optimization method of the polling service of buffer queue
CN113259408A (en) Data transmission method and system
CN118540336A (en) Distributed data transmission method and distributed data access system
CN112068972A (en) Message queue consumption method based on multi-computer room realization and electronic equipment
CN110674221B (en) Spatial data synchronization method, terminal and computer-readable storage medium
CN116225742B (en) A message distribution method, device and storage medium
CN117950850A (en) Data transmission method, device, electronic equipment and computer readable medium
WO2024174258A1 (en) Deep neural network checkpoint optimization system and method based on nonvolatile memory
CN114138895B (en) Data synchronization method and device for multiple data sources, computer equipment and storage medium
CN115454666A (en) Data synchronization method and device among message queue clusters
CN118101757A (en) A distributed distribution system deployment, distribution method, system, device and medium
CN114356873A (en) Data sharing system and method
CN120256154B (en) Data processing method, device, computer equipment, storage medium and program product
WO2021179556A1 (en) Storage system and request processing method, and switch

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载