Message queue allocation method, device, equipment and computer-readable storage medium

By updating the relationship set of consumer instances on the message middleware server and executing the load balancing algorithm, the problem that message queue products do not have grayscale release is solved, ensuring the normal consumption and success rate of message queues, and improving reliability and stability.

CN110781015BActive Publication Date: 2025-08-08WEBANK (CHINA)
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201911032575.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-10-28
Publication Date
2025-08-08
Estimated Expiration
2039-10-28

AI Technical Summary

Technical Problem

Existing message queue products do not have the ability to publish grayscale, resulting in a low success rate of message queue messages being consumed in message topics.

Method used

By sending a heartbeat packet to the message middleware server after the consumer instance generates a new grayscale instance, the relationship set of consumer instances is updated, and after detecting instructions to execute the load balancing algorithm, the number of consumer instances corresponding to the message subject is determined, and the load balancing algorithm is executed to assign the message queue to the consumer instance.

Benefits of technology

It realizes that the message queue product has grayscale publishing capabilities, ensuring that the message queues in the message topic can be consumed normally, improving the success rate of messages being consumed, and enhancing reliability, scalability and stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN110781015B_ABST
    Figure CN110781015B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, apparatus, device and computer-readable storage medium for allocating message queues, and relates to the field of financial technology. The method includes the following steps: when a new grayscale instance is detected to be generated in a consumer instance, a heartbeat packet is sent to a message middleware server, so that the message middleware server updates the relationship set corresponding to the consumer instance according to the heartbeat packet; when an execution instruction for executing a preset load balancing algorithm is detected, a message topic corresponding to the execution instruction is determined, and the number of consumer instances corresponding to the message topic is obtained in the relationship set; the load balancing algorithm is executed according to the number of consumer instances to allocate the message queue in the message topic to the consumer instance. The present invention enables the message queue product to have the ability of grayscale publishing, ensures that the messages in the message topic message queue can be consumed normally, and improves the success rate of message consumption in the message queue.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of message middleware in financial technology (Fintech), and in particular to a message queue allocation method, apparatus, device, and computer-readable storage medium. Background Art

[0002] With the continuous development of financial technology, especially Internet technology finance, more and more technologies (such as distributed, blockchain, artificial intelligence, etc.) are being applied in the financial field. However, the financial industry also puts forward higher requirements for technology, such as higher requirements for message queue products in the financial industry.

[0003] Grayscale release refers to a release method that can smoothly transition between black and white. A / B testing can be performed on it, that is, some users continue to use product feature A, while some users start using product feature B. If users have no objection to B, then the scope is gradually expanded and all users are migrated to B. Specifically, in existing message queue products, the so-called grayscale release refers to such a situation. If, in a certain version update, the Consumer Group (consumer instance category) needs to add or reduce subscriptions to a certain Topic based on the originally subscribed Topic (message topic), if all consumer instances are shut down for the version update and then released at the same time, and the stability of the new version of the Topic has not been verified in production, then catastrophic consequences are likely to occur. Among them, Consumer Group is a classification of homogeneous consumer instances, that is, different consumers under the same Consumer Group are completely equivalent to the outside world.

[0004] For example, there are three consumer instances in Consumer Group A (consumer instance class A), namely c1, c2, and c3. Consumer instance c3 becomes a grayscale instance and adds a subscription to Topic 4. Because different consumer instances under the same consumer instance class appear to be completely equivalent to each other, when Consumer Instance Class A determines, based on the load balancing algorithm, that messages in Topic 4 are distributed among consumer instances c1, c2, and c3 for final consumption, each consumer instance consumes a portion of the message queue in Topic 4. However, in reality, only consumer instance c3 has the ability to consume messages in Topic 4. This is inconsistent, resulting in only a portion of the messages in Topic 4's message queue being consumed, while the remaining messages in the message queue cannot be consumed correctly. This shows that existing message queue products do not have the grayscale publishing capability, resulting in the inability to correctly consume messages in the message queue of a message topic when adding or reducing subscriptions to the message topic, resulting in a low success rate for consuming messages in the message queue of the message topic. Summary of the Invention

[0005] The main purpose of the present invention is to provide a message queue allocation method, device, equipment and computer-readable storage medium, aiming to solve the technical problems that existing message queue products do not have the ability to grayscale release and the success rate of consuming message queue messages in message topics is low.

[0006] To achieve the above object, the present invention provides a method for allocating a message queue, the method comprising the steps of:

[0007] When a new grayscale instance is detected in a consumer instance, a heartbeat packet is sent to the message middleware server, so that the message middleware server updates the relationship set corresponding to the consumer instance according to the heartbeat packet;

[0008] When an execution instruction for executing a preset load balancing algorithm is detected, a message topic corresponding to the execution instruction is determined, and the number of consumer instances corresponding to the message topic is obtained from the relationship set;

[0009] The load balancing algorithm is executed according to the number of the consumer instances to allocate the message queues in the message topic to the consumer instances.

[0010] Preferably, after the step of executing the load balancing algorithm according to the number of consumer instances to allocate the message queues in the message topic to the consumer instances, the method further includes:

[0011] When a failure message indicating that the consumer instance fails to consume the message queue is detected, the failure message is uploaded to a retry queue corresponding to the consumer instance, wherein each consumer instance has a corresponding retry queue.

[0012] Preferably, the step of executing the load balancing algorithm according to the number of consumer instances to allocate the message queues in the message topic to the consumer instances includes:

[0013] Determine the number of consumer instances as an execution parameter for executing the load balancing algorithm, and obtain the number of message queues corresponding to the message topic in the message middleware name service center;

[0014] The load balancing algorithm is executed according to the number of message queues and the execution parameters to allocate the message queues in the message topic to the consumer instance.

[0015] Preferably, after detecting an execution instruction for executing a preset load balancing algorithm, determining a message topic corresponding to the execution instruction, and obtaining the number of consumer instances corresponding to the message topic in the relationship set includes:

[0016] When an execution instruction for executing a preset load balancing algorithm is detected, a message subject corresponding to the execution instruction is determined, and a consumer instance list corresponding to the message subject is obtained from the relationship set;

[0017] The number of consumer instances corresponding to the message topic is determined according to the consumer instance list.

[0018] In addition, to achieve the above-mentioned purpose, the present invention further provides a message queue allocation method, the message queue allocation method comprising:

[0019] When the message middleware server receives the heartbeat packet sent by the consumer instance after generating a new grayscale instance, it updates the relationship set corresponding to the message sender instance according to the heartbeat packet;

[0020] After receiving the message to be consumed sent by the producer instance, determine the message topic corresponding to the message to be consumed;

[0021] The relationship set is accessed in a round-robin manner to find a target consumer instance subscribed to the message topic, and the message queue in the message topic is allocated to the target consumer instance.

[0022] Preferably, when the message middleware server receives a heartbeat packet sent by the consumer instance after generating a new grayscale instance, the step of updating the relationship set corresponding to the message sender instance according to the heartbeat packet includes:

[0023] When the message middleware server receives the heartbeat packet sent by the consumer instance after generating a new grayscale instance, it obtains the heartbeat packet information in the heartbeat packet;

[0024] The mapping relationship between the message subject and the consumer instance is recorded according to the heartbeat packet information to update the relationship set corresponding to the consumer instance, wherein the relationship set stores the mapping relationship between the message subject and the consumer instance.

[0025] In addition, to achieve the above-mentioned purpose, the present invention further provides a message queue allocation device, the message queue allocation device comprising:

[0026] A sending module is configured to send a heartbeat packet to a message middleware server when a new grayscale instance is detected to be generated in a consumer instance, so that the message middleware server updates the relationship set corresponding to the consumer instance according to the heartbeat packet;

[0027] A determination module, configured to, upon detecting an execution instruction for executing a preset load balancing algorithm, determine a message subject corresponding to the execution instruction;

[0028] An acquisition module, configured to acquire the number of consumer instances corresponding to the message topic in the relationship set;

[0029] An execution module is used to execute the load balancing algorithm according to the number of consumer instances to allocate the message queues in the message topic to the consumer instances.

[0030] In addition, to achieve the above-mentioned purpose, the present invention further provides a message queue distribution device, which is applied to a message middleware server and includes:

[0031] An update module, configured to update the relationship set corresponding to the sender instance according to a heartbeat packet received after the consumer instance generates a new grayscale instance;

[0032] A determination module is used to determine the message topic corresponding to the message to be consumed after receiving the message to be consumed sent by the producer instance;

[0033] The access module is used to poll and access the relationship set to find a target consumer instance subscribed to the message topic, and allocate the message queue in the message topic to the target consumer instance.

[0034] In addition, to achieve the above-mentioned purpose, the present invention also provides a message queue allocation device, which includes a memory, a processor, and a message queue allocation program stored on the memory and runnable on the processor. When the message queue allocation program is executed by the processor, the steps of the message queue allocation method described above are implemented.

[0035] In addition, to achieve the above objectives, the present invention also provides a computer-readable storage medium, on which a message queue allocation program is stored. When the message queue allocation program is executed by a processor, the steps of the message queue allocation method described above are implemented.

[0036] The present invention sends a heartbeat packet to a message middleware server when a new grayscale instance is detected to be generated in a consumer instance, so that the message middleware server can update the relationship set corresponding to the consumer instance according to the heartbeat packet, and after detecting the execution instruction of the load balancing algorithm, determines the message subject corresponding to the execution instruction, obtains the number of consumer instances corresponding to the message subject in the relationship set, and then executes the load balancing algorithm according to the number of consumer instances to allocate the message queues in the message subject to the consumer instance. After the new grayscale instance is generated, a relationship set between the message subject and the consumer instance is introduced into the message middleware server, and the mapping relationship between the message subject subscribed by each type of consumer instance and the consumer instance corresponding to the message that can consume the message subject is recorded through the relationship set. The load balancing algorithm is executed based on the number of consumer instances determined according to the relationship set to ensure that all message queues of the message subject are correctly allocated to the consumer instance that can consume them, so that the message queue product has the ability of grayscale publishing, ensures that the messages in the message subject message queue can be consumed normally, improves the success rate of message consumption in the message queue, and improves the reliability, scalability and stability of the message queue. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] Figure 1 1 is a flow chart of a first embodiment of a method for allocating message queues according to the present invention;

[0038] Figure 2 This is a schematic diagram of the relationship between the consumer instance class and the message middleware server in the message queue product according to an embodiment of the present invention;

[0039] Figure 3 is a schematic diagram comparing the existing load balancing algorithm and the load balancing algorithm in this embodiment;

[0040] Figure 4 2 is a flow chart of a second embodiment of a method for allocating message queues according to the present invention;

[0041] Figure 51 is a flow chart of a third embodiment of a method for allocating a message queue according to the present invention;

[0042] Figure 6 It is a functional schematic module diagram of a preferred embodiment of a message queue distribution device of the present invention;

[0043] Figure 7 It is a schematic diagram of the structure of the hardware operating environment involved in the embodiment of the present invention.

[0044] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings and in conjunction with the embodiments. DETAILED DESCRIPTION

[0045] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0046] The present invention provides a message queue allocation method, referring to Figure 1 , Figure 1 2 is a flow chart of a first embodiment of a message queue allocation method according to the present invention.

[0047] The embodiment of the present invention provides an embodiment of a method for allocating a message queue. It should be noted that although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in an order different from that shown here.

[0048] In this embodiment of the present invention, grayscale publishing refers to the situation where, among consumer instances of the same category, only the grayscale instance listens to the new message topic. Only the grayscale instance receives messages from the new message topic, while other non-grayscale instances can only receive messages from the old message topic. Grayscale instances can process messages from both the old and new message topics. The following explains the professional terms used in this invention.

[0049] Message queue: A container that stores messages during message transmission, used to store messages generated during inter-process communication or communication between different threads of the same process.

[0050] Queue: Messages are actually stored in the logical area of the message middleware. The correspondence between Topic and Queue is a one-to-many relationship. Messages of the same topic are stored in the Queue {Q1, Q2, Q3…} corresponding to the topic.

[0051] Producer: message producer; Consumer: message consumer.

[0052] Consumer Group: A grouping of homogeneous consumer instances. Consumers consume messages from a queue in units of consumer groups. For ease of description, we'll refer to consumer groups as consumer instance categories.

[0053] Broker: A message middleware server that provides capabilities such as maintaining the mapping relationship between topics and queues and storing messages.

[0054] Name server: The name service center of the message middleware, providing Topic and Broker global routing services for service requesters and service providers.

[0055] Message queue allocation methods include:

[0056] Step S10: When a new grayscale instance is detected to be generated in a consumer instance, a heartbeat packet is sent to a message middleware server, so that the message middleware server updates the relationship set corresponding to the consumer instance according to the heartbeat packet.

[0057] In existing message queue products, when consumers actually consume messages in a message topic, they consume them in units of consumer instance categories. The message is then passed through the consumer instance category and then determined by the load balancing algorithm to be consumed by a specific consumer. Each consumer instance under a consumer instance category regularly sends a heartbeat packet to the message middleware server, and through the heartbeat packet, informs the message middleware server of the message topic it has subscribed to and the consumer instance category to which it belongs. The message middleware server maintains information objects of multiple consumer instance categories, such as Figure 2 The consumer instance class A objects and consumer instance class B objects in the consumer instance class record the message topic information subscribed by the consumer instance category and the subscription message information corresponding to the subscribed message topic. The message topic information includes but is not limited to the message topic name and the number of message queues corresponding to the message topic. The subscription message information is the specific information of the message topic subscribed by a certain type of consumer instance. Through the subscription message, you can know which message queues in the subscribed message topic to assign to the consumer instance.

[0058] In an embodiment of the present invention, when a new grayscale instance is generated in a consumer instance, the consumer instance corresponding to the new grayscale instance will generate a heartbeat packet and send the heartbeat packet to the message middleware server. After the message middleware server receives the heartbeat packet, the message middleware server updates the relationship set corresponding to the consumer instance based on the heartbeat packet. The heartbeat packet information of the heartbeat packet carries the consumer identifier of the consumer instance corresponding to the new grayscale instance. The relationship set also contains the consumer identifier. Therefore, the consumer instance corresponding to the new grayscale instance can be determined through the consumer identifier in the heartbeat packet information, and then the relationship set corresponding to the consumer instance can be determined. In the relationship set, the mapping relationship between the message topic and the consumer instance is recorded. It should be noted that after the relationship set is updated, the consumer instances under the same consumer instance category are still equivalent to the outside world.

[0059] Step S20: When an execution instruction for executing a preset load balancing algorithm is detected, a message topic corresponding to the execution instruction is determined, and the number of consumer instances corresponding to the message topic is obtained from the relationship set.

[0060] When a consumer instance detects an execution instruction to execute a preset load balancing algorithm, the consumer instance determines the message topic corresponding to the execution instruction. The load balancing algorithm includes but is not limited to round-robin, source address hashing, and weighted round-robin.

[0061] In this embodiment, there are two ways to trigger the execution of instructions. The first method is to pre-set a scheduled task for each consumer instance. This scheduled task can trigger the execution of instructions, causing the consumer instance corresponding to the scheduled task to periodically execute the load balancing algorithm to update the message queue information in the message topic to which the corresponding consumer instance is subscribed. The scheduled duration of the scheduled task can be set according to specific needs and can be the same or different for different message consumer instances.

[0062] The second triggering method is: when a consumer instance goes offline, or a new consumer instance comes online, the message middleware server will detect changes in the heartbeat packet. Specifically, when the messenger instance goes offline, the message middleware server will detect the absence of the heartbeat packet; when a new consumer instance comes online, the message middleware server will detect a new heartbeat packet. When the message middleware server detects changes in the heartbeat packet, the message middleware server will update the information object of the maintained consumer instance category and the relationship set in the information object of the updated messenger instance category, generate an update message, and send an update message to all consumer instances under the consumer instance category, so as to inform the corresponding consumer instance through the update message that the number of consumer instances corresponding to the message topic to which it subscribes has changed. When the consumer instance receives the update message sent by the message middleware server, it triggers the execution instruction of the preset load balancing algorithm.

[0063] It should be noted that regardless of the triggering method used, the consumer instance can know the message topic to which it has subscribed, that is, the message topic corresponding to the execution instruction. After the consumer instance determines the message topic corresponding to the execution instruction, the consumer instance obtains the number of consumer instances corresponding to the message topic in the relationship set, that is, determines the number of consumer instances corresponding to the subscribed message topic. It should be noted that the same message topic can be subscribed to by multiple consumer instances. That is, a message topic can correspond to one consumer instance or multiple consumer instances, and a consumer instance can subscribe to one message topic or multiple message topics.

[0064] Furthermore, step S20 includes:

[0065] Step a: after detecting an execution instruction for executing a preset load balancing algorithm, determining a message subject corresponding to the execution instruction, and obtaining a consumer instance list corresponding to the message subject in the relationship set.

[0066] Step b: determining the number of consumer instances corresponding to the message topic according to the consumer instance list.

[0067] Specifically, when the consumer instance detects the execution instruction of the preset load balancing algorithm, it determines the message topic corresponding to the execution instruction, determines the relationship set corresponding to the message topic, and then obtains the consumer instance list corresponding to the subscribed message topic in the determined relationship set. After determining the consumer instance list, the consumer instance determines the number of consumer instances corresponding to the subscribed message topic based on the determined consumer instance list. It should be noted that each consumer instance has a category, each consumer instance category has a corresponding information object, each information object has a corresponding relationship set, and the mapping relationship between the message topic and the consumer instance is stored in the relationship set. It can be seen from this that the consumer instance category to which the consumer instance belongs is determined, and the corresponding information object can be determined according to the consumer instance category to which the consumer instance belongs, and then the relationship set corresponding to the consumer instance is determined according to the information object.

[0068] In the mapping relationship of this embodiment, the message subject is the keyword and the consumer instance is the key value. The message subject can be represented by the subject name and the consumer instance can be represented by the consumer identifier. In this embodiment, the representation of the message subject and the consumer identifier is not limited.

[0069] like Figure 2 As shown in the figure, Topic1, Topic2 and Topic3 represent topic names, and c1, c2, c3 and c4 represent consumer identifiers. Figure 2 It can be seen that the message topics subscribed to by consumer instance c1 are Topic1, Topic2, and Topic3. The consumer instance list corresponding to Topic1 is: c1, c2, and c3, and the corresponding number of consumer instances is 3; the consumer instance list corresponding to Topic2 is: c1, c2, and c3, and the corresponding number of consumer instances is 3; the consumer instance list corresponding to Topic3 is: c1, c2, and c3, and the corresponding number of consumer instances is 3. The message topics subscribed to by consumer instance c3 are Topic1, Topic2, Topic3, and Topic4. The consumer instance list corresponding to Topic4 only has one consumer instance, consumer instance c3, which means the number of consumer instances corresponding to Topic4 is 1.

[0070] Step S30: executing the load balancing algorithm according to the number of the consumer instances to allocate the message queues in the message topic to the consumer instances.

[0071] After determining the number of consumer instances corresponding to the subscribed message topic, the consumer instance determines the number of consumer instances as the execution parameter of the modulo operation of the load balancing algorithm, executes the load balancing algorithm according to the execution parameter to obtain the message queue in the message topic, and completes the operation of allocating the message queue in the message topic to the consumer instance.

[0072] Furthermore, step S30 includes:

[0073] Step c: determining the number of consumer instances as an execution parameter for executing the load balancing algorithm, and obtaining the number of message queues corresponding to the message topic in the message middleware name service center.

[0074] Step d: executing the load balancing algorithm according to the number of message queues and the execution parameters to allocate the message queues in the message topic to the consumer instance.

[0075] Specifically, the consumer instance uses the number of consumer instances as the execution parameter for the modulo operation during the load balancing algorithm. It then retrieves the message queue numbers corresponding to each subscribed message topic from the message middleware name service center. Each message topic corresponds to at least one message queue, and each message queue stores messages. After obtaining the message queue numbers corresponding to each message topic, the consumer instance executes the load balancing algorithm based on the number of consumer queues and the execution parameter, ensuring that the consumer instance obtains the message queues for the subscribed message topics.

[0076] For ease of understanding, Figure 3 For example, Figure 3 As shown, there are five message queues in the message topic, denoted as {Q1, Q2, Q3, Q4, Q5}, and three consumer instances in a certain type of consumer instance, denoted as {c1, c2, c3}. Among them, c2 and c3 are grayscale instances, and only c2 and c3 grayscale instances have subscribed to this message topic. During the execution of the load balancing algorithm in the existing technology, message queue Q1 is assigned to consumer instance c1, message queue Q2 is assigned to consumer instance c2, message queue Q3 is assigned to consumer instance c3, message queue Q4 is assigned to consumer instance c1, and message queue Q5 is assigned to consumer instance c2. However, because consumer instance c1 has not subscribed to the message topic, the messages assigned to the message queue of consumer instance c1 cannot be correctly consumed by consumer instance c1. However, in an embodiment of the present invention, during the execution of the load balancing algorithm, the message queue will not be assigned to the consumer instance c1, but the message queue Q1 will be assigned to the consumer instance c2, the message queue Q2 will be assigned to the consumer instance c3, the message queue Q3 will be assigned to the consumer instance c2, the message queue Q4 will be assigned to the consumer instance c3, and the message queue Q5 will be assigned to the consumer instance c2. This can ensure that all message queues of the message topic will be correctly assigned to the consumer instances that can consume them.

[0077] This embodiment sends a heartbeat packet to the message middleware server when a new grayscale instance is detected in a consumer instance, so that the message middleware server can update the relationship set corresponding to the consumer instance according to the heartbeat packet, and after detecting the execution instruction of the load balancing algorithm, it determines the message topic corresponding to the execution instruction, obtains the number of consumer instances corresponding to the message topic in the relationship set, and then executes the load balancing algorithm according to the number of consumer instances to allocate the message queues in the message topic to the consumer instance. After the new grayscale instance is generated, the relationship set between the message topic and the consumer instance is introduced into the message middleware server, and the mapping relationship between the message topic subscribed by each type of consumer instance and the consumer instance corresponding to the message that can consume the message topic is recorded through the relationship set. The load balancing algorithm is executed based on the number of consumer instances determined according to the relationship set to ensure that all message queues of the message topic are correctly allocated to the consumer instances that can consume them, so that the message queue product has the ability of grayscale release, ensures that the messages in the message topic message queue can be consumed normally, improves the success rate of message consumption in the message queue, and improves the reliability, scalability and stability of the message queue.

[0078] Furthermore, a second embodiment of the message queue allocation method of the present invention is proposed.

[0079] The difference between the second embodiment of the message queue allocation method and the first embodiment of the message queue allocation method is that, referring to Figure 4 , the step of calculating the abnormal probability corresponding to the module to be executed includes:

[0080] Step S40: upon detecting a failure message indicating that the consumer instance fails to consume the message in the message queue, the failure message is uploaded to a retry queue corresponding to the consumer instance, wherein each consumer instance has a corresponding retry queue.

[0081] When a consumer instance detects a failure message generated by a failed message consumption attempt in its assigned message queue, it uploads the failed message to its corresponding retry queue. The retry queue is pre-configured to store messages that failed to be consumed by the consumer instance. Messages in the retry queue are retrieved and re-consumed by the consumer instance. In this embodiment, each consumer instance corresponds to a retry queue. It is understood that if a network failure or consumer instance failure occurs while the consumer instance is consuming a message, message consumption may fail.

[0082] Furthermore, if the producer instance does not detect a successful message from the consumer instance within a preset duration, the producer instance regenerates a message indicating that the consumer instance failed to consume the message and sends the regenerated message to the message middleware server, which then stores the regenerated message in the corresponding message topic for the consumer instance to consume the message the next time. The preset duration can be set based on specific needs, and this embodiment does not impose any specific restrictions on the length of the preset duration.

[0083] In the prior art, one consumer instance category corresponds to one retry queue, that is, one type of consumer instance corresponds to one retry queue. Consumer instances of the same type share one retry queue, which causes the message queue in the message topic subscribed by the grayscale instance to be assigned to a non-grayscale instance that has not subscribed to the message topic, resulting in message consumption failure. In this embodiment, each consumer instance corresponds to a retry queue, and each consumer instance only maintains its own retry queue. The retry queues of different consumer instances are isolated from each other, avoiding the situation where messages in the message topic subscribed by the grayscale instance cannot be consumed by the non-grayscale instance, further improving the success rate of message consumption in the message queue.

[0084] Furthermore, a third embodiment of a message queue allocation method of the present invention is proposed.

[0085] Reference Figure 5 , the message queue allocation method includes:

[0086] Step S50: When the message middleware server receives the heartbeat packet sent by the consumer instance after generating a new grayscale instance, it updates the relationship set corresponding to the message sender instance according to the heartbeat packet.

[0087] When a consumer instance generates a new grayscale instance, it sends a heartbeat packet to the messaging middleware server. After the messaging middleware server receives the heartbeat packet from the consumer instance, it updates the corresponding relationship set of the consumer instance based on the heartbeat packet.

[0088] Furthermore, step S50 includes:

[0089] Step e: After the message middleware server receives the heartbeat packet sent by the consumer instance after generating a new grayscale instance, it obtains the heartbeat packet information in the heartbeat packet.

[0090] Specifically, when the message middleware server receives the heartbeat packet sent by the consumer instance after generating a new grayscale instance, the message middleware server obtains the heartbeat packet information in the heartbeat packet, where the heartbeat packet information includes the consumer identifier of the consumer instance corresponding to the heartbeat packet, the message topic name of the message topic subscribed by the consumer instance, and the consumer instance category corresponding to the heartbeat packet, etc.

[0091] Step f: Record the mapping relationship between the message subject and the consumer instance according to the heartbeat packet information to update the relationship set corresponding to the consumer instance, wherein the relationship set stores the mapping relationship between the message subject and the consumer instance.

[0092] After the message middleware server obtains the heartbeat packet information, the message middleware server updates the information object of the consumer instance category according to the heartbeat packet information, and updates the mapping relationship between the message topic and the consumer instance according to the heartbeat packet information, so as to update the relationship set corresponding to the consumer instance, wherein the relationship set stores the mapping relationship between the message topic and the consumer instance. In this embodiment, the mapping relationship uses the consumer instance as the keyword and the message topic as the key value. If the consumer instance newly subscribes to a message topic, the message topic is added to the information object of the consumer instance category corresponding to the consumer instance, and the key value of a message topic is added to the mapping relationship corresponding to the consumer instance.

[0093] Step S60: After receiving the message to be consumed sent by the producer instance, determine the message topic corresponding to the message to be consumed.

[0094] When a producer instance generates a new pending message to be consumed, it sends it to the messaging middleware server. Upon receiving the pending message from the producer instance, the messaging middleware server determines the message topic corresponding to the pending message. The pending message carries the corresponding message topic name, which can be used to determine the message topic.

[0095] Step S70 : polling and accessing the relationship set to find a target consumer instance subscribed to the message topic, and allocating the message queue in the message topic to the target consumer instance.

[0096] After determining the message topic corresponding to the message to be consumed, the messaging middleware server polls the access relationship set to find the target consumer instance subscribed to the message topic and assigns the message queue in the message topic to the target consumer instance. It should be noted that a message topic contains at least one message queue, each of which stores corresponding messages.

[0097] Specifically, the message middleware server decides how to poll the access relationship set based on a pre-set load balancing algorithm. During the polling access relationship set process, if the message middleware server detects that the current consumer instance has not subscribed to the message topic corresponding to the message to be consumed, it will continue to access the next consumer instance in the relationship set, and loop in sequence until all consumer instances subscribed to the message topic corresponding to the message to be consumed are found; if the message middleware server detects that the current consumer instance has subscribed to the message topic corresponding to the message to be consumed, it will determine the current consumer instance as the target consumer instance, and continue to access the next consumer instance in the relationship set, and loop in sequence until all consumer instances subscribed to the message topic corresponding to the message to be consumed are found, that is, until all target consumer instances are found. It should be noted that the process of allocating the message queue in the message topic to the target consumer instance is consistent with the process of allocating the message queue in the message topic to the target consumer instance in the first embodiment, and will not be repeated here.

[0098] This embodiment updates the relationship set after receiving the heartbeat packet sent by the consumer instance through the message middleware server. After receiving the message to be consumed sent by the producer instance, it determines the message topic corresponding to the message to be consumed, and polls the access relationship set to find the target consumer instance that subscribes to the message topic, and assigns the message queue in the message topic to the target consumer instance. After generating a new grayscale instance, the relationship set between the message topic and the consumer instance is introduced in the message middleware server. The relationship set records the mapping relationship between the message topic subscribed by each type of consumer instance and the consumer instance corresponding to the message that can consume the message topic. According to the relationship set, it ensures that all message queues of the message topic will be correctly assigned to the consumer instance that can consume them, so that the message queue product has the ability of grayscale release, ensuring that the messages in the message topic message queue can be consumed normally, improving the success rate of message consumption in the message queue, and improving the reliability, scalability and stability of the message queue.

[0099] In addition, refer to Figure 6 The present invention further provides a message queue allocation device, the message queue allocation device comprising:

[0100] The sending module 10 is used to send a heartbeat packet to the message middleware server when a new grayscale instance is detected to be generated in the consumer instance, so that the message middleware server updates the relationship set corresponding to the consumer instance according to the heartbeat packet;

[0101] The determination module 20 is configured to, upon detecting an execution instruction for executing a preset load balancing algorithm, determine a message subject corresponding to the execution instruction;

[0102] An acquisition module 30, configured to acquire the number of consumer instances corresponding to the message topic in the relationship set;

[0103] The execution module 40 is configured to execute the load balancing algorithm according to the number of the consumer instances, so as to allocate the message queues in the message topic to the consumer instances.

[0104] Furthermore, the message queue allocation device further includes:

[0105] The uploading module is used to upload the failure message to the retry queue corresponding to the consumer instance after detecting that the consumer instance fails to consume the message in the message queue, wherein each consumer instance has a corresponding retry queue.

[0106] Furthermore, the execution module 40 includes:

[0107] a determining unit, configured to determine the number of consumer instances as an execution parameter for executing the load balancing algorithm;

[0108] An acquiring unit, configured to acquire the number of message queues corresponding to the message topic in a message middleware name service center;

[0109] An execution unit is configured to execute the load balancing algorithm according to the number of message queues and the execution parameters, so as to allocate the message queues in the message topic to the consumer instance.

[0110] Furthermore, the determination module 20 is further configured to, upon detecting an execution instruction for executing a preset load balancing algorithm, determine a message subject corresponding to the execution instruction;

[0111] The acquisition module 30 is further configured to acquire a list of consumer instances corresponding to the message topic in the relationship set;

[0112] The determining module 20 is further configured to determine the number of consumer instances corresponding to the message topic according to the consumer instance list.

[0113] It should be noted that the various embodiments of the message queue allocation device are substantially the same as the various embodiments of the message queue allocation method described above, and will not be described in detail herein.

[0114] In addition, the present invention also provides a message queue distribution device, which is applied to a message middleware server and includes:

[0115] An update module, configured to update the relationship set corresponding to the sender instance according to a heartbeat packet received after the consumer instance generates a new grayscale instance;

[0116] A determination module is used to determine the message topic corresponding to the message to be consumed after receiving the message to be consumed sent by the producer instance;

[0117] The access module is used to poll and access the relationship set to find a target consumer instance subscribed to the message topic, and allocate the message queue in the message topic to the target consumer instance.

[0118] Furthermore, the update module includes:

[0119] An acquisition unit, configured to acquire heartbeat packet information in a heartbeat packet sent by a consumer instance after the message middleware server receives the heartbeat packet sent after the consumer instance generates a new grayscale instance;

[0120] A recording unit is used to record the mapping relationship between the message subject and the consumer instance according to the heartbeat packet information to update the relationship set corresponding to the consumer instance, wherein the relationship set stores the mapping relationship between the message subject and the consumer instance.

[0121] It should be noted that the various embodiments of the message queue allocation device are substantially the same as the various embodiments of the message queue allocation method described above, and will not be described in detail herein.

[0122] In addition, the present invention also provides a message queue distribution device. Figure 7 As shown, Figure 7 It is a schematic diagram of the structure of the hardware operating environment involved in the embodiment of the present invention.

[0123] It should be noted that Figure 7 The schematic diagram of the hardware operating environment of the message queue distribution device is shown in FIG. The message queue distribution device of the embodiment of the present invention can be a terminal device such as a PC or a portable computer.

[0124] like Figure 7 As shown, the distribution device of the message queue may include: a processor 1001, such as a CPU, a memory 1005, a user interface 1003, a network interface 1004, and a communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the user interface 1003 may optionally include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a stable memory (non-volatile memory), such as a disk memory. The memory 1005 may optionally be a storage device independent of the aforementioned processor 1001.

[0125] Optionally, the message queue distribution device may further include a camera, an RF (Radio Frequency) circuit, a sensor, an audio circuit, a WiFi module, and the like.

[0126] Those skilled in the art will understand that Figure 7 The message queue distribution device structure shown in does not constitute a limitation to the message queue distribution device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0127] like Figure 7 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a message queue allocation program. The operating system is a program that manages and controls the hardware and software resources of the message queue allocation device and supports the operation of the message queue allocation program and other software or programs.

[0128] exist Figure 7 In the message queue distribution device shown, the message middleware server and consumer instance can be installed in the message queue distribution device, the user interface 1003 is mainly used to connect to the client and communicate data with the client; the network interface 1004 is mainly used for the background server and communicates data with the background server; the processor 1001 can be used to call the message queue distribution program stored in the memory 1005, and execute the steps of the message queue distribution method as described above.

[0129] The specific implementation of the message queue allocation device of the present invention is basically the same as the various embodiments of the message queue allocation method described above, and will not be repeated here.

[0130] In addition, an embodiment of the present invention further provides a computer-readable storage medium, on which a message queue allocation program is stored. When the message queue allocation program is executed by a processor, the steps of the message queue allocation method described above are implemented.

[0131] The specific implementation of the computer-readable storage medium of the present invention is basically the same as the various embodiments of the message queue allocation method described above, and will not be repeated here.

[0132] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or apparatus comprising the element.

[0133] The serial numbers of the above embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments.

[0134] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better embodiment. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0135] The above are only preferred embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention description and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A message queue allocation method, characterized in that: The message queue allocation method comprises the following steps: When a new grayscale instance is detected in a consumer instance, a heartbeat packet is sent to the message middleware server, so that the message middleware server can update the relationship set corresponding to the consumer instance according to the heartbeat packet; the relationship set corresponding to the consumer instance records the mapping relationship between the message topic subscribed by each type of consumer instance and the consumer instance corresponding to the message consuming the message topic; When an execution instruction for executing a preset load balancing algorithm is detected, a message topic corresponding to the execution instruction is determined, and the number of consumer instances corresponding to the message topic is obtained from the relationship set; The load balancing algorithm is executed according to the number of the consumer instances to allocate the message queues in the message topic to the consumer instances.

2. The message queue allocation method according to claim 1, wherein: After the step of executing the load balancing algorithm according to the number of consumer instances to allocate the message queues in the message topic to the consumer instances, the method further includes: When a failure message indicating that the consumer instance fails to consume the message queue is detected, the failure message is uploaded to a retry queue corresponding to the consumer instance, wherein each consumer instance has a corresponding retry queue.

3. The message queue allocation method according to claim 1, wherein: The step of executing the load balancing algorithm according to the number of consumer instances to allocate the message queues in the message topic to the consumer instances includes: Determine the number of consumer instances as an execution parameter for executing the load balancing algorithm, and obtain the number of message queues corresponding to the message topic in the message middleware name service center; The load balancing algorithm is executed according to the number of message queues and the execution parameters to allocate the message queues in the message topic to the consumer instance.

4. The message queue allocation method according to any one of claims 1 to 3, characterized in that: The steps of, after detecting an execution instruction for executing a preset load balancing algorithm, determining a message topic corresponding to the execution instruction, and obtaining the number of consumer instances corresponding to the message topic in the relationship set include: When an execution instruction for executing a preset load balancing algorithm is detected, a message subject corresponding to the execution instruction is determined, and a consumer instance list corresponding to the message subject is obtained from the relationship set; The number of consumer instances corresponding to the message topic is determined according to the consumer instance list.

5. A message queue allocation method, characterized in that: The message queue allocation method comprises the following steps: When the message middleware server receives the heartbeat packet sent by the consumer instance after generating a new grayscale instance, it updates the relationship set corresponding to the message sender instance according to the heartbeat packet; the relationship set corresponding to the consumer instance records the mapping relationship between the message topic subscribed by each type of consumer instance and the consumer instance corresponding to the message consuming the message topic; After receiving the message to be consumed sent by the producer instance, determine the message topic corresponding to the message to be consumed; The relationship set is accessed in a round-robin manner to find a target consumer instance subscribed to the message topic, and the message queue in the message topic is allocated to the target consumer instance.

6. The message queue allocation method according to claim 5, wherein: The step of updating the relationship set corresponding to the message sender instance according to the heartbeat packet after the message middleware server receives the heartbeat packet sent by the consumer instance after generating a new grayscale instance includes: When the message middleware server receives the heartbeat packet sent by the consumer instance after generating a new grayscale instance, it obtains the heartbeat packet information in the heartbeat packet; The mapping relationship between the message subject and the consumer instance is recorded according to the heartbeat packet information to update the relationship set corresponding to the consumer instance, wherein the relationship set stores the mapping relationship between the message subject and the consumer instance.

7. A message queue distribution device, characterized in that: The message queue distribution device includes: The sending module is used to send a heartbeat packet to the message middleware server when a new grayscale instance is detected in the consumer instance, so that the message middleware server can update the relationship set corresponding to the consumer instance according to the heartbeat packet; the relationship set corresponding to the consumer instance records the mapping relationship between the message topic subscribed by each type of consumer instance and the consumer instance corresponding to the message consuming the message topic; A determination module, configured to, upon detecting an execution instruction for executing a preset load balancing algorithm, determine a message subject corresponding to the execution instruction; An acquisition module, configured to acquire the number of consumer instances corresponding to the message topic in the relationship set; An execution module is used to execute the load balancing algorithm according to the number of consumer instances to allocate the message queues in the message topic to the consumer instances.

8. A message queue distribution device, characterized in that: The message queue allocation device is applied to the message middleware server, and the message queue allocation device includes: An update module is configured to update the relationship set corresponding to the message sender instance according to the heartbeat packet received after the consumer instance generates a new grayscale instance; the relationship set corresponding to the consumer instance records the mapping relationship between the message topic subscribed by each type of consumer instance and the consumer instance corresponding to the message consuming the message topic; A determination module is used to determine the message topic corresponding to the message to be consumed after receiving the message to be consumed sent by the producer instance; The access module is used to poll and access the relationship set to find a target consumer instance subscribed to the message topic, and allocate the message queue in the message topic to the target consumer instance.

9. A message queue distribution device, characterized in that: The message queue allocation device includes a memory, a processor, and a message queue allocation program stored in the memory and runnable on the processor. When the message queue allocation program is executed by the processor, the steps of the message queue allocation method as described in any one of claims 1 to 4 or 5 to 6 are implemented.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a message queue allocation program, which, when executed by a processor, implements the steps of the message queue allocation method according to any one of claims 1 to 4 or 5 to 6.

Citation Information

Patent Citations

  • Method and device for gray releasing

    CN108108175A

  • Service release system and method, equipment and storage medium

    CN108376118A