CN112052104A - Message queue management method based on multi-computer-room realization and electronic equipment - Google Patents

Message queue management method based on multi-computer-room realization and electronic equipment 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
machine room
target
message queue
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.)
Pending
Application number
CN202010905108.0A
Other languages
Chinese (zh)
Inventor
王利超
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
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/CN112052104A/en
Publication of CN112052104A publication Critical patent/CN112052104A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR 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; CALCULATING OR 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

Message queue management method based on multi-computer-room realization and electronic equipment
Technical Field
The invention relates to the field of computers, in particular to a message queue management method and electronic equipment based on multi-computer-room implementation.
Background
The message queue is used for storing data to be transmitted into the queue. The service end for writing data into the queue is called a message production end, and the service end for reading data from the queue is called a message consumption end. The ordered storage of a plurality of message data can be realized through the message queue, thereby being beneficial to realizing the reliable transmission of the message.
With the increasingly complex service scenarios, many service systems include multiple machine rooms, in an implementation scheme of crossing machine rooms, a message production end needs to determine a machine room where a message consumption end is located in advance, and when the message consumption end and the message production end are located in different machine rooms respectively, in order to ensure smooth consumption of the message consumption end, message data produced by the message production end in a first machine room needs to be transmitted to a second machine room where the message consumption end is located for storage.
However, in the process of implementing the present invention, the inventor finds that the above solution in the prior art has at least the following defects: on one hand, in a complex service scene, one message production end may correspond to a plurality of message consumption ends, and how to predetermine the number of the message consumption ends and a machine room where each message consumption end is located becomes a technical problem to be solved urgently; on the other hand, the message production end needs to transmit the generated message data to the machine room where the message consumption end is located, however, due to the defects that data transmission delay and the like may be caused by a line reason or a network reason between the two machine rooms, the method is not applicable to a service scene with a high real-time requirement.
Disclosure of Invention
In view of the above, the present invention is proposed to provide a method and an electronic device for managing a message queue based on multiple-chassis implementation, which overcome or at least partially solve the above problems.
According to one aspect of the invention, a message queue management method implemented based on multiple computer rooms is provided, which 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.
According to another aspect of the present invention, there is provided an electronic apparatus including: 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:
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.
According to yet another aspect of the present invention, there is provided a computer storage medium having at least one executable instruction stored therein, the executable instruction causing the processor to:
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.
In the message queue management method and the electronic equipment based on multiple machine rooms, message data generated by the message production end is directly written into the machine room where the message production end is located, the machine room where the message consumption end is located does not need to be determined, and data transmission operation across the machine rooms does not need to be executed in the message production process, so that the real-time performance of operation is improved, and the influence caused by network jitter is avoided; in addition, when the message consumption end consumes the data, the machine room where the message queue to be consumed is located is determined according to the queue machine room mapping relation contained in the configuration metadata recorded in advance, and therefore the data are asynchronously obtained to be consumed. Therefore, the method avoids the complex operation of predetermining the number of the consumption ends and the machine room where the consumption ends are located, avoids the delay problem caused by cross-machine-room production messages, and can be suitable for service scenes with high real-time requirements.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
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 only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 is a flow chart illustrating a method for managing message queues based on a multi-machine-room implementation according to an embodiment of the present invention;
FIG. 2 is a flow chart illustrating a method for managing message queues based on a multi-machine-room implementation according to another embodiment of the present invention;
fig. 3 shows a schematic structural diagram of an electronic device according to another embodiment of the invention.
Detailed Description
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 to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
Example one
Fig. 1 is a flowchart illustrating a method for managing a message queue based on a multi-machine-room implementation according to an embodiment of the present invention. As shown in fig. 1, the method comprises the steps of:
step S110: and a first machine room in the plurality of machine rooms responds to a message writing request triggered by a message production end corresponding to the first machine room, writes message data contained in the message writing request into a message queue corresponding to the first machine room, and stores the message queue corresponding to the first machine room and a queue machine room mapping relation between the first machine room and the first machine room into configuration metadata.
Wherein, a plurality of computer rooms in this embodiment refer to: at least two machine rooms. Accordingly, the first machine room of the plurality of machine rooms may be any one of the plurality of machine rooms. Specifically, each room corresponds to one or more services, respectively. A service may correspond to an item 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 machine room may be a message producing end, a message consuming end, or both, depending on the currently executed service function of the service.
When one service is used to generate message data, the service serves as a message production end to send a message write request to a machine room corresponding to the service, and in this embodiment, the machine room corresponding to the service that sends the message write request serves as a first machine room. In essence, for any machine room, as long as the service corresponding to the machine room triggers a message write request as a message production side, the machine room is referred to as a first machine room.
After receiving a message write request sent by a service of the first machine room, the first machine room writes message data contained in the message write request into a message queue corresponding to the first machine room (namely, the first machine room), and stores a message queue corresponding to the first machine room and a queue machine room mapping relation between the first machine room and the first machine room into configuration metadata. Therefore, after any computer room receives the message writing request, the corresponding message consuming end does not need to be determined, and the received message data can be directly written into the message queue corresponding to the computer room. The method does not need a network transmission process crossing a computer room, so that the writing efficiency can be greatly improved.
Wherein, the message queue corresponding to the first machine room means: a message queue stored in a storage space corresponding to the first machine room. The storage space corresponding to the first machine room may be a local storage space of the first machine room, or may be a storage space in a database connected to the first machine room, and specifically, the message queue corresponding to the first machine room may be maintained by a queue server in the first machine room.
In addition, the queue machine room mapping relation is used for storing the corresponding relation between the message queue produced by the message production end and the machine room where the message queue is located. Of course, the queue room mapping relationship may further store a ternary correspondence relationship between the message production end, the message queue produced by the message production end, and the room in which the message queue is located. The configuration metadata is used for uniformly storing the queue machine room mapping relationship, wherein the configuration metadata can be uniformly stored in configuration servers respectively connected with the machine rooms, or can be respectively stored in the machine rooms and shared by the machine rooms.
Step S120: 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 the 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 for consumption by the message consumption end.
In particular, the second machine room of the plurality of machine rooms may be any one of the plurality of machine rooms. Each machine room corresponds to one or more services, so when one service is used for consuming message data, the service serves as a message consumption end to send a message consumption request to the machine room corresponding to the service, and in this embodiment, the machine room corresponding to the service sending the message consumption request serves as a second machine room. In essence, for any computer room, as long as the service corresponding to the computer room triggers the message consumption request as the message consumption end, the computer room is called a second computer room.
After receiving a message consumption request sent by the service of the machine room, the second machine room firstly determines a message queue corresponding to the message consumption request and determines the message queue as a target message queue; then, inquiring configuration metadata, determining a machine room where the target message queue is located according to the inquiry result, and determining the machine room as a target machine room; and finally, transmitting the message data of the target message queue in the target machine room to a second machine room so that the message consumption end can consume the message data locally. Therefore, after any computer room receives the message consumption request, the computer room where the message queue to be consumed is located is determined according to the configuration metadata, and then data are obtained from the computer room.
The target machine room may be any one of a plurality of machine rooms, for example, the target machine room may be the first machine room described above, or may be a third machine room different from the first machine room and the second machine room, or may be the second machine room itself, and at this time, it is only necessary to directly obtain the message data in the machine room. In summary, the present invention does not limit the specific location of the target message queue and the target machine room, and depends on the actual business requirements. In addition, when the message data of the target message queue in the target machine room is transmitted to the second machine room, the message data can be transmitted through a data special line between the two machine rooms.
In addition, it should be noted that the first machine room and the second machine room may be different machine rooms or may be the same machine room, which is not limited in the present invention.
Therefore, in the management method of the message queue based on the multiple machine rooms, the message data generated by the message production end is directly written into the machine room where the message production end is located, the machine room where the message consumption end is located does not need to be determined, and data transmission operation across the machine rooms does not need to be executed in the message production process, so that the real-time performance of operation is improved, and the influence caused by network jitter is avoided; in addition, when the message consumption end consumes the data, the machine room where the message queue to be consumed is located is determined according to the queue machine room mapping relation contained in the configuration metadata recorded in advance, and therefore the data are asynchronously obtained to be consumed. Therefore, the method avoids the complex operation of predetermining the number of the consumption ends and the machine room where the consumption ends are located, avoids the delay problem caused by cross-machine-room production messages, and can be suitable for service scenes with high real-time requirements.
Example two
Fig. 2 is a flowchart illustrating a method for managing a message queue based on a multi-machine-room implementation according to another embodiment of the present invention. As shown in fig. 2, the method comprises the steps of:
step S200: and respectively arranging agent modules in the machine rooms, wherein the agent modules of the machine rooms maintain the configuration metadata together.
Specifically, each of the multiple computer rooms is provided with an agent module, and the agent module in each computer room is configured to process a message write request and a message consumption request from each service, and maintain configuration metadata according to the message write request and the message consumption request. For example, the message write request includes a ternary correspondence relationship between the message production end, the message queue to be written, and the machine room in which the message production end is located; the message consumption request comprises a message consumption end, a message queue to be consumed and a ternary corresponding relation of a machine room where the message consumption end is located, so that the agent modules of all the machine rooms can establish and maintain a ternary relation group consisting of a service (comprising a message production end and a message consumption end), the message queue and the machine room in the process of processing the message writing request and the message consumption request, and configuration metadata is formed so as to facilitate subsequent processing.
In specific implementation, the agent modules of the respective machine rooms are configured to implement processing of message write requests and message consumption requests sent by the respective services based on an extension protocol, and obtain and dynamically maintain the above-mentioned triplet by analyzing message contents in a processing process.
It should be noted that this step is an optional step, and in other embodiments of the present invention, the related functions such as maintaining and configuring metadata may be implemented by changing the source code inside the machine room without setting the proxy module, and the present invention does not limit the specific implementation details.
Step S210: and a first machine room in the plurality of machine rooms responds to a message writing request triggered by a message production end corresponding to the first machine room, writes message data contained in the message writing request into a message queue corresponding to the first machine room, and stores the message queue corresponding to the first machine room and a queue machine room mapping relation between the first machine room and the first machine room into configuration metadata.
Wherein, a plurality of computer rooms in this embodiment refer to: at least two machine rooms. Accordingly, the first machine room of the plurality of machine rooms may be any one of the plurality of machine rooms. Specifically, each room corresponds to one or more services, respectively. A service may correspond to an item 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 machine room may be a message producing end, a message consuming end, or both, depending on the currently executed service function of the service.
When one service is used to generate message data, the service serves as a message production end to send a message write request to a machine room corresponding to the service, and in this embodiment, the machine room corresponding to the service that sends the message write request serves as a first machine room. In essence, for any machine room, as long as the service corresponding to the machine room triggers a message write request as a message production side, the machine room is referred to as a first machine room. After receiving a message write request sent by a service of the first machine room, the first machine room writes message data contained in the message write request into a message queue corresponding to the first machine room (namely, the first machine room), and stores a message queue corresponding to the first machine room and a queue machine room mapping relation between the first machine room and the first machine room into configuration metadata. Therefore, after any computer room receives the message writing request, the corresponding message consuming end does not need to be determined, and the received message data can be directly written into the message queue corresponding to the computer room. The method does not need a network transmission process crossing a computer room, so that the writing efficiency can be greatly improved. Wherein, the message queue corresponding to the first machine room means: a message queue stored in a storage space corresponding to the first machine room. The storage space corresponding to the first machine room may be a local storage space of the first machine room, or may be a storage space in a database connected to the first machine room, and specifically, the message queue corresponding to the first machine room may be maintained by a queue server in the first machine room.
In addition, the queue machine room mapping relation is used for storing the corresponding relation between the message queue produced by the message production end and the machine room where the message queue is located. Of course, the queue room mapping relationship may further store a ternary correspondence relationship between the message production end, the message queue produced by the message production end, and the room in which the message queue is located. And the configuration metadata is used for uniformly storing the queue computer room mapping relation.
Wherein the configuration metadata may be stored in a variety of ways: for example, in an alternative implementation manner, 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, and accordingly, the configuration servers can implement functions of deduplication, verification and the like for the configuration metadata to ensure the accuracy of the configuration metadata. For another example, in another alternative implementation manner, the configuration metadata generated by each computer room is stored in each computer room respectively, and is shared by each computer room, wherein to facilitate the sharing of the configuration metadata between each computer room, one computer room may request, through a broadcast mechanism, configuration metadata related to a currently received message consumption request from another computer room.
Under the premise that the agent modules are arranged in the machine rooms, the agent module in the first machine room is responsible for executing the steps. Specifically, the agent module is responsible for analyzing the received message write-in request, and constructs a ternary relationship group according to a message production end identifier (namely, a service identifier) contained in an analysis result, a message queue identifier to be written in, and a machine room identifier of the machine room, so as to obtain corresponding configuration metadata according to the ternary relationship group.
In order to facilitate communication, in this embodiment, each service sends various types of request data through the local machine room where the service is located, and accordingly, the message write-in request received by each machine room is obviously sent by the service from the local machine room.
Step S220: 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, and determines the machine room where the target message queue is located as the target machine room according to the configuration metadata.
In particular, the second machine room of the plurality of machine rooms may be any one of the plurality of machine rooms. Each machine room corresponds to one or more services, so when one service is used for consuming message data, the service serves as a message consumption end to send a message consumption request to the machine room corresponding to the service, and in this embodiment, the machine room corresponding to the service sending the message consumption request serves as a second machine room. In essence, for any computer room, as long as the service corresponding to the computer room triggers the message consumption request as the message consumption end, the computer room is called a second computer room.
Under the premise that the agent modules are arranged in the machine rooms, the agent module in the second machine room is responsible for executing the steps. Specifically, after receiving a message consumption request sent by the service of the local computer room, the agent module in the second computer room executes the following operations:
first, the message consumption request is parsed to determine a message queue corresponding to the message consumption request (i.e., a message queue to be consumed), which is determined as a target message queue. And then, inquiring the configuration metadata, determining the machine room where the target message queue is located according to the inquiry result, and determining the machine room as the target machine room. Because the configuration metadata records the corresponding relation between the message queue and the machine room where the message queue is located, the machine room where the target message queue is located, namely the target machine room, can be accurately determined based on the configuration metadata.
The target machine room may be any one of the multiple machine rooms, for example, the target machine room may be the first machine room, or may be a third machine room different from the first machine room and the second machine room, or may be the second machine room itself (at this time, it is only necessary to directly obtain the message data in the local machine room of the second machine room). In summary, the present invention does not limit the specific location of the target message queue and the target machine room, and depends on the actual business requirements.
Step S230: and transmitting the message data of the target message queue in the target machine room to a second machine room for consumption by the message consumption end.
Specifically, after the target machine room is determined, the message data of the target message queue in the target machine room is transmitted to the second machine room, so that the message consumption end can consume the message data locally. Therefore, after any computer room receives the message consumption request, the computer room where the message queue to be consumed is located is determined according to the configuration metadata, and then data are obtained from the computer room.
In specific implementation, the message data of the target message queue in the target machine room is transmitted to the second machine room through the machine room dedicated line between the target machine room and the second machine room. The network communication is carried out between any two machine rooms through the machine room special line, so that the message data of the target message queue in the target machine room can be transmitted to the second machine room through the machine room special line between the target machine room and the second machine room.
Specifically, the data transmission operation may be triggered by the second machine room sending a transmission request to the target machine room, and accordingly, the target machine room returns the message data in the message queue to the second machine room according to the identifier of the message queue included in the received transmission request.
Optionally, in this embodiment, in order to improve the transmission efficiency of the message data, a synchronization module is respectively set in each machine room, and the synchronization module of each machine room communicates with the proxy module in the machine room, so that data synchronization operation can be performed under the control of the proxy module. Correspondingly, when the message data of the target message queue in the target machine room is transmitted to the second machine room, the message data of the target message queue in the target machine room is transmitted to the second machine room through the synchronization module in the target machine room.
In addition, in the process of implementing the present invention, the inventor finds that there is usually a fixed mapping relationship between the message consuming side and the message queue to be consumed, for example, the services A, B all consume the messages in the first message queue as the consuming side, and as long as the first message queue is updated, the service A, B triggers the message consumption request as the consuming side. In addition, on the premise that the service A, B does not have room migration, the rooms in which the services A, B are respectively located are also fixed, for example, the service a is in the room 1, the service B is in the room 2, and if the first message queue is located in the room 3, the contents of the first message queue located in the room 3 need to be respectively transmitted to the room 1 and the room 2. In order to prevent delay in the subsequent transmission process, when it is monitored that the first message queue in the machine room 3 is updated based on the correspondence, the updated first message queue is synchronized to the machine room 1 and the machine room 2 respectively, so as to facilitate subsequent consumption.
In order to achieve the above object, in this embodiment, it is necessary to determine a corresponding relationship between each consuming end and a message queue to be consumed by the consuming end, and for this purpose, each time a second machine room in the multiple machine rooms responds to a message consumption request triggered by the message consuming end corresponding to the second machine room, a set of three-way relationship groups is further generated according to the message consuming 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 consuming end, and the three-way relationship groups are added to the configuration metadata. Therefore, the ternary relationship group generated according to the message consumption request is used for representing the corresponding relationship among the message consumption end, the message queue to be consumed and the machine room where the message consumption end is located. The subsequent synchronization direction can be determined according to the corresponding relation.
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 for: determining any message queue in the machine room as a message queue to be synchronized, determining the machine room corresponding to each message consumption end of the message queue to be synchronized according to the ternary relation group in the configuration metadata, and synchronizing the message data in the message queue to be synchronized to the machine room corresponding to each message consumption end. Specifically, the synchronization module in each machine room may poll each message queue in the machine room at regular time to determine whether each message queue in the machine room is updated, and when any message queue is updated, determine the consuming terminal corresponding to the updated message queue and the machine room in which the consuming terminal is located according to the ternary relationship group in the configuration metadata, and further synchronize the updated message queue to the machine room in which the consuming terminal is located.
In addition, although the above-mentioned ternary relationship group can store the corresponding relationship between the message consuming end, the message queue to be consumed, and the machine room identifier where the message consuming end is located, the inventor finds that, in implementing the present invention, the relationship between the message consuming end and the message queue to be consumed may change, and the machine room where the message consuming end is located may also change due to machine room migration operation, so to adapt to the change, the ternary relationship group in this embodiment can be dynamically updated, for example, dynamically updated according to a received message consumption request triggered by the message consuming end after the machine room is switched, and dynamically updated when a new message queue to be consumed is added according to the message consuming end.
In order to sense the change of the corresponding relationship in the ternary relationship group, in this embodiment, after a second machine room in the multiple machine rooms generates a group of ternary relationship groups according to the message consumption request, it is further determined whether a ternary relationship group corresponding to the message consumption end included in the message consumption request is stored in the configuration metadata, if so, machine room information in the stored ternary relationship group corresponding to the message consumption end included in the message consumption request is further acquired, the acquired machine room information is compared with the machine room information in the ternary relationship group generated this time, and it is determined whether the message consumption end included in the message consumption request has machine room migration according to the comparison result. For example, if the acquired machine room information is inconsistent with the machine room information in the generated three-way relationship group, it is determined that the machine room migration has occurred at the message consumption end included in the message consumption request. And under the condition that the machine room is judged to be migrated, deleting the corresponding ternary relationship group before migration from the configuration metadata, and only reserving the corresponding ternary relationship group after migration, thereby realizing the dynamic update of the corresponding relationship.
Similarly, every time a second machine room in the plurality of machine rooms generates a group of ternary relationship groups according to the message consumption request, whether a ternary relationship group corresponding to the message consumption end contained in the message consumption request is stored in the configuration metadata is further judged, if yes, information of a message queue to be consumed in the stored ternary relationship group corresponding to the message consumption end contained in the message consumption request is further acquired, the acquired information of the message queue is compared with information of the message queue in the ternary relationship group generated at this time, whether a new message queue to be consumed is added to the message consumption end contained in the message consumption request is judged according to the comparison result, and if yes, the corresponding relationship is added to the configuration metadata.
In summary, the configuration metadata in this embodiment can be dynamically updated according to the message consumption requests received each time, so as to dynamically maintain the machine room to which each message consumption end currently belongs and the message queue to be consumed corresponding to each message consumption end. Correspondingly, the synchronization module in each machine room dynamically determines each message consumption end corresponding to each message queue in the machine room and the machine room corresponding to the message queue based on the dynamically changed configuration metadata, so as to synchronize the message data in the message queue to the machine room corresponding to each message consumption end. For example, a message queue M is stored in a certain machine room, and accordingly, the synchronization module of the machine room determines, by analyzing the configuration metadata, that there are two consuming ends of the message queue M, which are the first consuming end located in the machine room 1 and the second consuming end located in the machine room 2, respectively, and then synchronizes the updated content to the machine room 1 and the machine room 2 after the message queue M is updated, so as to facilitate the subsequent consuming process.
And during specific synchronization, the synchronization module replaces a consumption end of the message queue to consume, and writes the consumed data into a machine room to be synchronized. For example, the synchronization module consumes the data in the message queue M instead of the consuming side of the message queue M, and writes the consumed data content into the machine room 1 and the machine room 2, respectively.
In one particular 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. Because the real-time requirement of the real-time service is higher, no matter which machine room the service as the message production end is located in, the message queue is directly written into the machine room locally, so that the problems of delay and jitter of cross-machine-room transmission through a special line of the machine room are solved, the position of the machine room where the consumption end is located does not need to be concerned, and the method is particularly suitable for complex service scenes with a large number of services. Because the message consumption end corresponds to the non-real-time service, the data transmission process realized by the special line of the machine room can not influence the service.
For example, when the method in this embodiment is applied to an electronic book application, the message production end may serve to receive a book in an electronic book, and after a user receives the book, a new data record is added in the corresponding message queue to record a corresponding relationship between the user and the received book. Correspondingly, the message consumption end can serve for updating the points in the electronic book, after the user gets the book, the points of the user are updated along with the book, and the operation of updating the points can be completed asynchronously, so that the consumption process is designed to be a cross-machine-room transmission mode realized through a machine-room special line, the use of the user cannot be influenced, and the problem of real-time service blockage in the electronic book application is effectively solved.
Additionally, in one particular example, the message queue may be implemented based on the Advanced Message Queue Protocol (AMQP), such as may be implemented using a RabbitMQ. The synchronous module can be controlled by a synchronous switch, and when the synchronous switch is turned on, synchronous service can be realized; when the synchronous switch is turned off, the synchronous service is not performed temporarily, and whether the synchronous operation of the message queue is performed or not can be flexibly determined according to the service condition by arranging the synchronous switch for controlling each synchronous module in each machine room, so that the synchronous operation can be suspended when the service is busy, and the synchronous operation is performed when the service is idle, and the influence of the synchronous operation on a service system is reduced to the minimum.
The method in this embodiment is particularly suitable for a cross-project production scenario, where the number of production ports and consumption ports is large, one production port may correspond to multiple consumption ports, and one consumption port may also correspond to multiple production ports, and in this complex business scenario, it is difficult to predetermine the number of consumption ports corresponding to the produced message queues and the machine rooms where the consumption ports are located, so that the above problems can be solved well by dynamically maintaining the configuration metadata by the proxy module, and after the consumption ports switch the machine rooms, the configuration metadata can be dynamically updated automatically, so that the method is not affected by machine room switching, and the message data can be synchronized to the switched machine rooms for consumption in time.
The agent module in this embodiment may also be referred to as an agent component or an agent element, and may be implemented in a software programming manner, or may be implemented in a hardware manner, which is not limited in this disclosure. Similarly, the synchronization module in this embodiment may also be referred to as a synchronization component or a synchronization element, and may be specifically implemented by a software programming manner, or may be implemented by a hardware manner, which is not limited in this disclosure.
In summary, the method in this embodiment avoids the complex operations of predetermining the number of consumption terminals and the machine room where the consumption terminals are located, avoids the delay problem caused by the production of messages across the machine room, and can be applied to service scenes with high real-time requirements. By arranging the agent module, the message processing process can be taken over by the agent module, so that the unified maintenance of the configuration metadata is facilitated. And the consumption end corresponding to each message queue and the machine room where the consumption end is located can be determined based on the configuration metadata, and then the synchronization module completes the synchronization operation in advance, so that the efficiency of subsequent consumption is improved.
EXAMPLE III
The 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 may execute the management method of the message queue based on multiple computer rooms in any of the above method embodiments.
The executable instructions may be specifically configured to cause the processor to:
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.
In an alternative implementation, the executable instructions may be specifically configured to cause the processor to: 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.
In an alternative implementation, the executable instructions may be specifically configured to cause the processor to: 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.
In an alternative implementation, the executable instructions may be specifically configured to cause the processor to: 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.
In an alternative implementation, the executable instructions may be specifically configured to cause the processor to: 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.
In an optional implementation manner, the ternary relationship group is used for storing a 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.
In an alternative implementation, the executable instructions may be specifically configured to cause the processor to:
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.
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.
Example four
Fig. 3 is a schematic structural diagram of an electronic device according to another embodiment of the present invention, and the specific embodiment of the present invention does not limit the specific implementation of the electronic device.
As shown in fig. 3, the electronic device may include: a processor (processor)302, a communication Interface 304, a memory 306, and a communication bus 308.
Wherein: the processor 302, communication interface 304, and memory 306 communicate with each other via a communication bus 308. A communication interface 304 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 perform relevant steps in the embodiment of the method for managing a message queue implemented on the basis of multiple machine rooms.
In particular, program 310 may include program code comprising computer operating instructions.
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 an embodiment of the present invention. The electronic device comprises one or more processors, which can be the same type of processor, such as one or more CPUs; or may be different types of processors such as one or more CPUs and one or more ASICs.
And a memory 306 for storing a program 310. Memory 306 may comprise high-speed RAM memory and may also include non-volatile memory (non-volatile memory), such as at least one disk memory.
The program 310 may specifically be configured to cause the processor 302 to perform the following operations:
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.
In an alternative implementation, the executable instructions may be specifically configured to cause the processor to: 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.
In an alternative implementation, the executable instructions may be specifically configured to cause the processor to: 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.
In an alternative implementation, the executable instructions may be specifically configured to cause the processor to: 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.
In an alternative implementation, the executable instructions may be specifically configured to cause the processor to: 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.
In an optional implementation manner, the ternary relationship group is used for storing a 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.
In an alternative implementation, the executable instructions may be specifically configured to cause the processor to:
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.
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.
The algorithms and displays presented herein are not inherently related to any particular computer, virtual machine, or other apparatus. Various general purpose systems may also be used with the teachings herein. The required structure for constructing such a system will be apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of the invention.
In the description provided herein, numerous specific details are set forth. It is 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 should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: 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 appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the 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-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to 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 a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may 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-computer-room realization and electronic equipment Pending CN112052104A (en)

Priority Applications (1)

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

Applications Claiming Priority (1)

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

Publications (1)

Publication Number Publication Date
CN112052104A true CN112052104A (en) 2020-12-08

Family

ID=73607282

Family Applications (1)

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

Country Status (1)

Country Link
CN (1) CN112052104A (en)

Cited By (1)

* 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

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
CN113794757B (en) * 2021-08-31 2024-03-19 百融至信(北京)科技有限公司 Redis cluster off-site synchronization method and system based on rabitmq

Similar Documents

Publication Publication Date Title
CN112069265B (en) Synchronization method of configuration data, business data system, computer system and medium
CN110795503A (en) Multi-cluster data synchronization method and related device of distributed storage system
CN110119304B (en) Interrupt processing method and device and server
CN110196843B (en) File distribution method based on container cluster and container cluster
CN111881116A (en) Data migration method, data migration system, computer system, and storage medium
CN113094430B (en) Data processing method, device, equipment and storage medium
CN114461593B (en) Log writing method and device, electronic device and storage medium
CN114285695B (en) Communication method, device, apparatus, system and storage medium
CN113746641B (en) ODX protocol processing method based on distributed storage
JP4208506B2 (en) High-performance storage device access environment
CN112148206A (en) Data reading and writing method and device, electronic equipment and medium
CN112015595B (en) Master-slave database switching method, computing device and storage medium
CN116800616B (en) Management method and related device of virtualized network equipment
CN112052104A (en) Message queue management method based on multi-computer-room realization and electronic equipment
CN112363980A (en) Data processing method and device for distributed system
CN113051244B (en) Data access method and device, and data acquisition method and device
CN115629909A (en) Service data processing method and device, electronic equipment and storage medium
CN112187916B (en) Cross-system data synchronization method and device
CN113259408A (en) Data transmission method and system
CN112068972A (en) Message queue consumption method based on multi-computer room realization and electronic equipment
CN114745438B (en) Cache data processing method, device and system of multi-data center and electronic equipment
CN109005059A (en) A kind of system and method for realizing Redis automated back-up
CN117493027B (en) Thermal upgrading method and device and electronic equipment
CN113438281B (en) Storage method, device, equipment and readable medium of distributed message queue
CN114051047B (en) Session message backup method and device, network equipment and storage medium

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