Message matching method, device and equipment for point-to-point conditional subscription between client and message middleware

By obtaining the unconsumed queue in the message middleware and matching the message based on the matching progress of the conditional subscription group, the problems of low message matching efficiency and difficulty in balanced allocation in the prior art are solved, and efficient message characteristics and subscription conditions are achieved.

CN119342098BActive Publication Date: 2025-05-13成方金融科技有限公司
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411910017.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-24
Publication Date
2025-05-13
Estimated Expiration
2044-12-24

AI Technical Summary

Technical Problem

When implementing point-to-point conditional subscription of message middleware, it is difficult to take into account both time and space, especially in the matching process of message characteristics and subscription conditions, which can easily lead to excessive memory demand or the message cannot be matched correctly.

Method used

By obtaining the unconsumed queue on the server, the to-be-matched messages are stored in the form of a message ID. Based on the maximum number of matched messages and the matching progress of each conditional subscription group, the conditional subscription group is matched with the to-be-matched message characteristics in the unconsumed queue in the message matching order, and the matching successful target message is obtained and removed from the unconsumed queue. In response to the distribution operation of the server, the target message is distributed to the member consumers in the conditional subscription group.

Benefits of technology

It realizes efficiently matching message characteristics and subscription conditions without relying on full cache of messages, reducing memory usage and matching times, and ensuring balanced allocation of messages to consumers who meet the conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119342098B_ABST
    Figure CN119342098B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of message matching, and provides a message matching method, device and equipment for point-to-point conditional subscription between a client and a message middleware, the method comprising: obtaining an unconsumed queue of a server; the unconsumed queue is obtained by storing the to-be-matched messages in the form of message IDs; based on the maximum number of matching messages and the matching progress of each conditional subscription group, each conditional subscription group is matched with the features of the to-be-matched messages in the unconsumed queue in a message matching order to obtain each target message, and each target message is removed from the unconsumed queue; each conditional subscription group is a subscription group composed of member consumers with the same subscription conditions; in response to the distribution operation of the server, each target message is distributed to each member consumer in each conditional subscription group. The method accurately indexes and caches the message features according to the matching progress, and uses less memory; and balanced distribution of messages can be guaranteed between member consumers with different subscription conditions and the same subscription conditions.
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 matching, and in particular to a message matching method, device and equipment for point-to-point conditional subscription between a client and a message middleware. Background Art

[0002] The point-to-point message consumption model in the message middleware means that when multiple consumers consume the same queue, each message is consumed by only one consumer. Conditional subscription means that when consumers subscribe to a message queue from the middleware, they set conditions and selectively subscribe to specific messages. Point-to-point consumption and conditional subscription are common functions of message middleware. For example, the most widely used message middleware API (Application Programming Interface) interface JMS (Java Message Service) provides these functions.

[0003] While satisfying the requirement of distributing correct messages to consumers for point-to-point conditional subscription, the message middleware must also take into account the balance of message distribution between consumers with different subscription conditions and between consumers with the same subscription conditions, and the efficiency of the distribution algorithm in time and space.

[0004] In order to realize the above requirements of point-to-point conditional subscription, the following difficulties need to be overcome:

[0005] 1. Regardless of whether the message is persistent or non-persistent, the message middleware must quickly match the message characteristics with the consumer's subscription conditions. If all messages are loaded into memory, the memory demand will be very huge. If only some messages are loaded into memory, the messages cannot be matched correctly.

[0006] 2. When the message middleware distributes messages to consumers, it must match each message with the subscription conditions of each consumer. Message matching is a computationally intensive operation, and the message middleware must minimize the number of message matches. For example, for multiple consumers with the same subscription conditions, only one match is required to exclude the possibility of distribution to such consumers.

[0007] 3. When a number of messages match the subscription conditions of multiple consumers, how to ensure that these messages can be evenly distributed to consumers that meet the conditions, so as to avoid some consumers consuming a large number of messages while other consumers consume a small number or no messages. Summary of the invention

[0008] The present invention provides a message matching method, device and equipment for point-to-point conditional subscription between a client and a message middleware, which is used to solve the defects in the prior art that if all messages are loaded into the memory, the memory demand consumption is very huge, if part of the messages are loaded into the memory, the messages cannot be correctly matched, and the messages that meet the same subscription conditions cannot be relatively evenly distributed to consumers.

[0009] The present invention provides a message matching method for point-to-point conditional subscription between a client and a message middleware, comprising the following steps:

[0010] Obtain an unconsumed queue on the server side; the unconsumed queue is obtained by storing the messages to be matched in the form of message IDs;

[0011] Based on the maximum number of matching messages and the matching progress of each conditional subscription group, each conditional subscription group is matched with the features of the to-be-matched messages in the unconsumed queue in a message matching order to obtain each successfully matched target message, and each target message is removed from the unconsumed queue; each conditional subscription group is a subscription group composed of member consumers with the same subscription condition;

[0012] In response to the distribution operation of the server, each target message is distributed to each member consumer in each conditional subscription group.

[0013] According to a message matching method for point-to-point conditional subscription between a client and a message middleware provided by the present invention, based on the maximum number of matching messages and the matching progress of each conditional subscription group, each conditional subscription group is matched with the features of the to-be-matched messages in the unconsumed queue in a message matching order to obtain each successfully matched target message, and each target message is removed from the unconsumed queue, including:

[0014] The first cycle is executed until the first preset condition is met:

[0015] The first cycle process includes:

[0016] Based on the maximum number of matching messages and the matching progress of each conditional subscription group, each conditional subscription group is matched with the features of the to-be-matched messages in the unconsumed queue in a message matching order to obtain each successfully matched target message, and each target message is removed from the unconsumed queue to obtain the target remaining messages;

[0017] The first preset condition is that the target remaining message is empty.

[0018] According to a message matching method for point-to-point conditional subscription between a client and a message middleware provided by the present invention, based on the maximum number of matching messages and the matching progress of each conditional subscription group, each conditional subscription group is matched with the features of the to-be-matched messages in the unconsumed queue in a message matching order to obtain each successfully matched target message, and each target message is removed from the unconsumed queue to obtain the target remaining message, including:

[0019] The second cycle is executed until the second preset condition is met:

[0020] The second cycle process includes:

[0021] Updating the message matching order of each conditional subscription group;

[0022] Updating the matching progress of each conditional subscription group;

[0023] Based on the maximum number of matching messages and the matching progress of each conditional subscription group, each conditional subscription group is matched with the features of the to-be-matched messages in the unconsumed queue in the message matching order to obtain each successfully matched target message, and each target message is removed from the unconsumed queue to obtain the target remaining messages;

[0024] The second preset condition is that the message matching traversal of each conditional subscription group is completed.

[0025] According to a message matching method for point-to-point conditional subscription between a client and a message middleware provided by the present invention, based on the maximum number of matching messages and the matching progress of each conditional subscription group, each conditional subscription group is matched with the features of the to-be-matched messages in the unconsumed queue in a message matching order to obtain each successfully matched target message, and each target message is removed from the unconsumed queue to obtain the target remaining message, including:

[0026] Based on the maximum number of matching messages and the matching progress of each conditional subscription group, the first conditional subscription group is matched with the features of the messages to be matched in the unconsumed queue to obtain a first target message that successfully matches, and the first target message is removed from the unconsumed queue to obtain a first remaining message;

[0027] Based on the maximum number of matching messages, the intermediate conditional subscription group is matched with the features of the first remaining messages in sequence to obtain a second target message that successfully matches, and the second target message is removed from the first remaining messages to obtain a second remaining message; the intermediate conditional subscription group is a conditional subscription group between the first conditional subscription group and the last conditional subscription group;

[0028] Based on the maximum number of matching messages, the last conditional subscription group is matched with the second remaining messages to obtain the last target message that matches successfully, and the last target message is removed from the second remaining messages to obtain the target remaining messages.

[0029] According to a message matching method for point-to-point conditional subscription between a client and a message middleware provided by the present invention, the message matching order of each conditional subscription group is updated, comprising:

[0030] The order of the first conditional subscription group in each conditional subscription group in the message matching order is moved to the end, and the order of the remaining conditional subscription groups in each conditional subscription group remains unchanged.

[0031] According to the present invention, a message matching method for point-to-point conditional subscription between a client and a message middleware further includes:

[0032] Periodically remove the features of consumed messages from the feature cache.

[0033] According to a message matching method for point-to-point conditional subscription between a client and a message middleware provided by the present invention, in response to the distribution operation of the server, each target message is distributed to each member consumer in each conditional subscription group, including:

[0034] In response to the distribution operation of the server, the target messages are evenly distributed to the member consumers in the conditional subscription groups.

[0035] The present invention also provides a message matching device for point-to-point conditional subscription between a client and a message middleware, which is applied to the message middleware and includes the following units:

[0036] An acquisition unit, used for acquiring an unconsumed queue of the server; the unconsumed queue is obtained by storing the to-be-matched messages in the form of message IDs;

[0037] A message matching unit, configured to match each conditional subscription group with features of the to-be-matched messages in the unconsumed queue in a message matching order based on the maximum number of matching messages and the matching progress of each conditional subscription group, obtain each successfully matched target message, and remove each target message from the unconsumed queue; each conditional subscription group is a subscription group composed of member consumers with the same subscription condition;

[0038] The distribution unit is used to distribute the target messages to the member consumers in the conditional subscription groups in response to the distribution operation of the server.

[0039] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a message matching method for point-to-point conditional subscription between a client and a message middleware as described in any one of the above is implemented.

[0040] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the message matching method for point-to-point conditional subscription between a client and a message middleware as described in any of the above methods is implemented.

[0041] The present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements any of the above-mentioned message matching methods for point-to-point conditional subscription between a client and a message middleware.

[0042] The message matching method, device and equipment for point-to-point conditional subscription between a client and a message middleware provided by the present invention, on the one hand, compared with some message middleware that relies on the full cache of messages, when the message cache is too large, it is impossible to match the message features with the subscription conditions. The method accurately indexes and caches the message features according to the matching progress, and uses less memory; on the other hand, when there are multiple subscriptions with the same subscription conditions, after the conditional subscriptions are grouped, the message features are matched with each subscription condition only once, and the number of matches is greatly reduced. Furthermore, balanced distribution of messages can be guaranteed between member consumers with different subscription conditions and those with the same subscription conditions. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0044] Figure 1 It is a flow chart of a message matching method for point-to-point conditional subscription between a client and a message middleware provided by the present invention.

[0045] Figure 2 This is one of the schematic diagrams of the conditional subscription group matching message provided by the present invention.

[0046] Figure 3 This is the second schematic diagram of the conditional subscription group matching message provided by the present invention.

[0047] Figure 4 This is the third schematic diagram of the conditional subscription group matching message provided by the present invention.

[0048] Figure 5This is the fourth schematic diagram of the conditional subscription group matching message provided by the present invention.

[0049] Figure 6 It is a structural schematic diagram of a message matching device for point-to-point conditional subscription between a client and a message middleware provided by the present invention.

[0050] Figure 7 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0051] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0052] The terms "first", "second", etc. in the present invention are used to distinguish similar objects, rather than to describe a specific order or precedence. It should be understood that the terms used in this way can be interchangeable where appropriate, so that the embodiments of the present application can be implemented in an order other than those illustrated or described herein, and the objects distinguished by "first", "second", etc. are generally of the same type.

[0053] The present invention provides a message matching method for point-to-point conditional subscription between a client and a message middleware. Figure 1 : is a flow chart of a message matching method for point-to-point conditional subscription between a client and a message middleware provided by the present invention, such as Figure 1 As shown, the method is applied to message middleware, and the method includes step 110, step 120 and step 130.

[0054] Step 110, obtaining an unconsumed queue of the server; the unconsumed queue is obtained by storing the to-be-matched messages in the form of message IDs.

[0055] Step 120, based on the maximum number of matching messages and the matching progress of each conditional subscription group, match each conditional subscription group with the characteristics of the messages to be matched in the unconsumed queue in the message matching order to obtain each successfully matched target message, and remove each target message from the unconsumed queue; each conditional subscription group is a subscription group composed of member consumers with the same subscription conditions.

[0056] Step 130: In response to the distribution operation of the server, distribute the target messages to the member consumers in the conditional subscription groups.

[0057] Specifically, the message middleware can obtain the unconsumed queue of the server, where the unconsumed queue is obtained by storing the to-be-matched message in the form of a message ID. In addition, in order to quickly match messages with conditional subscriptions, the embodiment of the present invention extracts message features from the complete message and caches them in memory with the message ID index.

[0058] Then, based on the maximum number of matching messages and the matching progress of each conditional subscription group, each conditional subscription group is matched with the features of the messages to be matched in the unconsumed queue in the message matching order to obtain each successfully matched target message, and each target message is removed from the unconsumed queue.

[0059] The maximum number of matching messages refers to the maximum matching length of the features of each conditional subscription group and the messages to be matched in the unconsumed queue, which may be 4 or 5, etc., and is not specifically limited in the embodiment of the present invention.

[0060] The matching progress refers to the matching index of each conditional subscription group in the unconsumed queue, which can be a g1 cursor, a g2 cursor, a g3 cursor, etc.

[0061] Here, each conditional subscription group is a subscription group composed of member consumers with the same subscription condition. Among them, the subscription condition can be "length is greater than 10", then the conditional subscription group is a subscription group composed of all member consumers that meet the subscription condition of "length is greater than 10". Member consumers refer to each member in the conditional subscription group.

[0062] Here, the features of the messages to be matched in the unconsumed queue are message features, which may be "the length of the box is XX meters", "the width of the box is XX meters", or "the height of the box is XX meters", etc. The embodiment of the present invention does not specifically limit this.

[0063] It is understandable that as messages are continuously generated, the memory usage of the message feature cache increases. The embodiment of the present invention uses a timer to periodically remove the features of consumed messages from the cache to release memory usage.

[0064] It can be understood that, based on the maximum number of matching messages and the matching progress of each conditional subscription group, each conditional subscription group is matched with the features of the messages to be matched in the unconsumed queue in the message matching order to obtain each successfully matched target message, and each target message is removed from the unconsumed queue. If the remaining messages in the unconsumed queue are not empty, it is necessary to update the message matching order, and record the matching progress of each conditional subscription group in the last execution of message matching. With the updated message matching order and the matching progress of each conditional subscription group, each conditional subscription group is matched with the features of the messages to be matched in the unconsumed queue until the remaining messages in the unconsumed queue are empty.

[0065] It should be noted that each conditional subscription group needs to save the matched target messages for subsequent average distribution to member consumers.

[0066] Finally, in response to the distribution operation of the server, each target message is distributed to each member consumer in each conditional subscription group. Here, each target message can be evenly distributed to each member consumer in each conditional subscription group. For example, the conditional subscription group matches 3 target messages, and the conditional subscription group has 3 member consumers, then the 3 target messages are evenly distributed to the 3 member consumers of the conditional subscription group, that is, one member consumer corresponds to one target message. For another example, the conditional subscription group matches 5 target messages, and the conditional subscription group has 3 member consumers, then the 5 target messages are evenly distributed to the 3 member consumers of the conditional subscription group, that is, the first two member consumers correspond to two target messages, and the last member consumer corresponds to one target message, which means that balanced distribution of messages is achieved.

[0067] It should be noted that 1) the matching calculation is performed on the basis of conditional subscription groups, and multiple consumers with the same subscription conditions and messages only have one matching calculation. 2) The message middleware organizes the unconsumed messages (which can be the message itself or the message ID) into an unconsumed queue, and all conditional subscription groups try to match the messages in the unconsumed queue in turn. 3) To ensure that each conditional subscription group has a fair chance to match messages, each conditional subscription group can only match a certain number of messages from the unconsumed queue at a time, to prevent a large number of messages from being consumed by one conditional subscription group when they meet multiple conditions.

[0068] The method provided by the embodiment of the present invention, on the one hand, compared with some message middleware that relies on full cache of messages, when the message cache is too large, it makes it impossible to match message features with subscription conditions. The method provided by the embodiment of the present invention, on the one hand, accurately indexes and caches message features according to the matching progress, and uses less memory; on the other hand, when there are multiple subscriptions with the same subscription conditions, after the conditional subscriptions are grouped, the message features are matched with each subscription condition only once, and the number of matches is greatly reduced. Furthermore, balanced distribution of messages can be guaranteed between member consumers with different subscription conditions and the same subscription conditions.

[0069] Based on the above embodiment, step 120 includes:

[0070] The first cycle is executed until the first preset condition is met:

[0071] The first cycle process includes:

[0072] Based on the maximum number of matching messages and the matching progress of each conditional subscription group, each conditional subscription group is matched with the features of the to-be-matched messages in the unconsumed queue in a message matching order to obtain each successfully matched target message, and each target message is removed from the unconsumed queue to obtain the target remaining messages;

[0073] The matching progress of each conditional subscription group is updated; the first preset condition is that the target remaining message is empty.

[0074] Specifically, Figure 2 is one of the schematic diagrams of the conditional subscription group matching message provided by the present invention, Figure 3 This is the second schematic diagram of the conditional subscription group matching message provided by the present invention. Figure 4 This is the third schematic diagram of the conditional subscription group matching message provided by the present invention. Figure 5 This is a fourth schematic diagram of a conditional subscription group matching message provided by the present invention, such as Figure 2 , Figure 3 , Figure 4 and Figure 5 As shown, the first cycle process is executed until the first preset condition is met:

[0075] The first cycle process includes:

[0076] Based on the maximum number of matching messages and the matching progress of each conditional subscription group, each conditional subscription group is matched with the features of the to-be-matched messages in the unconsumed queue in the message matching order to obtain each successfully matched target message, and each target message is removed from the unconsumed queue to obtain the target remaining message. Here, the first preset condition is that the target remaining message is empty.

[0077] For example, the conditional subscription groups are g1, g2, and g3, and the message IDs of the unconsumed queue are 1, 2, 3, 4, 5, 6, 7, 8, 9, and 10. Among them, the conditional subscription group that can be satisfied by message ID1 in the unconsumed queue is g1, the conditional subscription group that can be satisfied by message ID3 in the unconsumed queue is g2, the conditional subscription groups that can be satisfied by message ID4 in the unconsumed queue are g1 and g3, the conditional subscription group that can be satisfied by message ID5 in the unconsumed queue is g2, the conditional subscription group that can be satisfied by message ID6 in the unconsumed queue is g1, the conditional subscription group that can be satisfied by message ID8 in the unconsumed queue is g3, and there is no conditional subscription group that can be satisfied by other messages in the unconsumed queue.

[0078] It should be noted that at the beginning, the matching progress of the conditional subscription groups g1, g2 and g3, that is, the cursors are all at the front of the unconsumed queue, and the maximum number of matching messages each time = 4.

[0079] The specific message matching process is as follows:

[0080] Based on the maximum number of matching messages and the matching progress of each conditional subscription group, the first conditional subscription group is matched with the features of the to-be-matched messages in the unconsumed queue to obtain the first target message that successfully matches, and the first target message is removed from the unconsumed queue to obtain the first remaining message;

[0081] Based on the maximum number of matching messages, the intermediate conditional subscription group is matched with the features of the first remaining message in sequence to obtain a second target message that successfully matches, and the second target message is removed from the first remaining message to obtain a second remaining message; the intermediate conditional subscription group is a conditional subscription group between the first conditional subscription group and the last conditional subscription group;

[0082] Based on the maximum number of matching messages, the last condition subscription group is matched with the second remaining message to obtain the last target message that matches successfully, and the last target message is removed from the second remaining message to obtain the target remaining message.

[0083] Here, three conditional subscription groups are used as an example. The message matching order starts with conditional subscription groups g1, g2, and g3. The first conditional subscription group is g1, the middle conditional subscription group is g2, and the last conditional subscription group is g3.

[0084] Then, a match is performed from the first conditional subscription group g1 to obtain the first target messages 1 and 4 that are successfully matched, and the first target messages 1 and 4 are removed from the unconsumed queue to obtain the first remaining messages 2, 3, 5, 6, 7, 8, 9 and 10.

[0085] After the first conditional subscription group g1 is matched, the intermediate conditional subscription group g2 is matched with the features of the first remaining message to obtain the second target messages 3 and 5 that are successfully matched, and the target messages 3 and 5 are removed from the first remaining message to obtain the second remaining messages 2, 6, 7, 8, 9 and 10.

[0086] If there are multiple intermediate condition subscription groups, the intermediate condition subscription groups are matched with the features of the first remaining message in sequence to obtain a successfully matched second target message, which will not be described in detail here.

[0087] After the matching of the middle condition subscription group g2 is completed, the last condition subscription group g3 is matched with the characteristics of the second remaining message to obtain the last target message 8 that successfully matches, and the last target message 8 is removed from the unconsumed queue to obtain the target remaining messages 2, 6, 7, 9 and 10.

[0088] Based on the above embodiment, based on the maximum number of matching messages and the matching progress of each conditional subscription group, each conditional subscription group is matched with the features of the to-be-matched messages in the unconsumed queue in a message matching order to obtain each successfully matched target message, and each target message is removed from the unconsumed queue to obtain the target remaining message, including:

[0089] The second cycle is executed until the second preset condition is met:

[0090] The second cycle process includes:

[0091] Updating the message matching order of each conditional subscription group;

[0092] Updating the matching progress of each conditional subscription group;

[0093] Based on the maximum number of matching messages and the matching progress of each conditional subscription group, each conditional subscription group is matched with the features of the to-be-matched messages in the unconsumed queue in the message matching order to obtain each successfully matched target message, and each target message is removed from the unconsumed queue to obtain the target remaining messages;

[0094] The second preset condition is that the message matching traversal of each conditional subscription group is completed.

[0095] Specifically, after the first round of message matching is completed, the message matching order of each conditional subscription group is updated, and the order of the first conditional subscription group in each conditional subscription group in the message matching order is moved to the end, and the order of the remaining conditional subscription groups in each conditional subscription group remains unchanged, that is, the matching order of each conditional subscription group is updated to g2, g3, and g1. That is, conditional subscription group g2 is used as the first conditional subscription group, conditional subscription group g3 is used as the middle conditional subscription group, and conditional subscription group g1 is used as the last conditional subscription group.

[0096] Update the matching progress of each conditional subscription group. Specifically, update the matching progress of conditional subscription group g1, that is, the g1 cursor points to 5 in the unconsumed queue, the matching progress of conditional subscription group g2, that is, the g2 cursor points to 7 in the unconsumed queue, and the matching progress of conditional subscription group g3, that is, the g3 cursor points to 9 in the unconsumed queue.

[0097] After updating the message matching order of each conditional subscription group and the matching progress of each conditional subscription group, each conditional subscription group can be matched with the features of the to-be-matched messages in the unconsumed queue according to the message matching order based on the maximum number of matching messages and the matching progress of each conditional subscription group to obtain each successfully matched target message, and each target message is removed from the unconsumed queue to obtain the target remaining messages;

[0098] The second preset condition is that the message matching traversal of each conditional subscription group is completed.

[0099] That is, conditional subscription group g2 is used as the first conditional subscription group, conditional subscription group g3 is used as the middle conditional subscription group, and conditional subscription group g1 is used as the last conditional subscription group, and the steps of matching the conditional subscription group with the features of the to-be-matched messages 2, 6, 7, 9, and 10 in the unconsumed queue are re-executed, which will not be repeated here. In addition, each conditional subscription group can also be 2 or 1, and the steps of matching the conditional subscription group with the features of the to-be-matched messages in the unconsumed queue in the message matching order are similar to the above description, which will not be repeated here.

[0100] It should be noted that, in addition, each subscriber can also be matched with each member consumer Consumer, but this method is less efficient.

[0101] It can be understood that the method provided by the embodiment of the present invention accurately caches message features in memory according to the matching progress; groups consumers subscribed to the same conditions to reduce the number of matches between messages and conditions; multiple conditional subscription groups are used to match messages, and after the conditional subscription group matches the message, it is evenly distributed to the member consumers in the group, thereby ensuring balanced distribution of messages between member consumers with different subscription conditions and the same subscription conditions.

[0102] The message matching device for point-to-point conditional subscription between a client and a message middleware provided by the present invention is described below. The message matching device for point-to-point conditional subscription between a client and a message middleware described below and the message matching method for point-to-point conditional subscription between a client and a message middleware described above can be referred to each other.

[0103] Based on any of the above embodiments, the present invention provides a message matching device for point-to-point conditional subscription between a client and a message middleware, Figure 6 It is a structural diagram of a message matching device for peer-to-peer conditional subscription between a client and a message middleware provided by the present invention, such as Figure 6 As shown, applied to message middleware, the device includes:

[0104] The acquisition unit 610 is used to acquire an unconsumed queue of the server; the unconsumed queue is obtained by storing the to-be-matched messages in the form of message IDs;

[0105] The message matching unit 620 is used to match each conditional subscription group with the features of the to-be-matched messages in the unconsumed queue in a message matching order based on the maximum number of matching messages and the matching progress of each conditional subscription group, obtain each successfully matched target message, and remove each target message from the unconsumed queue; each conditional subscription group is a subscription group composed of member consumers with the same subscription condition;

[0106] The distribution unit 630 is used to distribute the target messages to the member consumers in the conditional subscription groups in response to the distribution operation of the server.

[0107] The device provided by the embodiment of the present invention, on the one hand, compared with some message middleware that relies on the full cache of messages, when the message cache is too large, it makes it impossible to match the message characteristics with the subscription conditions. The method provides an accurate index cache of the message characteristics according to the matching progress, and uses less memory; on the other hand, when there are multiple subscriptions with the same subscription conditions, after the conditional subscriptions are grouped, the message characteristics are matched with each subscription condition only once, and the number of matches is greatly reduced. Furthermore, balanced distribution of messages can be guaranteed between member consumers with different subscription conditions and the same subscription conditions.

[0108] Based on any of the above embodiments, the message matching unit 620 is specifically configured to:

[0109] The first cycle is executed until the first preset condition is met:

[0110] The first cycle process includes:

[0111] Based on the maximum number of matching messages and the matching progress of each conditional subscription group, each conditional subscription group is matched with the features of the to-be-matched messages in the unconsumed queue in a message matching order to obtain each successfully matched target message, and each target message is removed from the unconsumed queue to obtain the target remaining messages;

[0112] The first preset condition is that the target remaining message is empty.

[0113] Based on any of the above embodiments, the first cycle process is specifically used for:

[0114] The second cycle is executed until the second preset condition is met:

[0115] The second cycle process includes:

[0116] Updating the message matching order of each conditional subscription group;

[0117] Updating the matching progress of each conditional subscription group;

[0118] Based on the maximum number of matching messages and the matching progress of each conditional subscription group, each conditional subscription group is matched with the features of the to-be-matched messages in the unconsumed queue in the message matching order to obtain each successfully matched target message, and each target message is removed from the unconsumed queue to obtain the target remaining messages;

[0119] The second preset condition is that the message matching traversal of each conditional subscription group is completed.

[0120] Based on any of the above embodiments, the first cycle process is specifically used for:

[0121] Based on the maximum number of matching messages and the matching progress of each conditional subscription group, the first conditional subscription group is matched with the features of the messages to be matched in the unconsumed queue to obtain a first target message that successfully matches, and the first target message is removed from the unconsumed queue to obtain a first remaining message;

[0122] Based on the maximum number of matching messages, the intermediate conditional subscription group is matched with the features of the first remaining messages in sequence to obtain a second target message that successfully matches, and the second target message is removed from the first remaining messages to obtain a second remaining message; the intermediate conditional subscription group is a conditional subscription group between the first conditional subscription group and the last conditional subscription group;

[0123] Based on the maximum number of matching messages, the last conditional subscription group is matched with the second remaining messages to obtain the last target message that matches successfully, and the last target message is removed from the second remaining messages to obtain the target remaining messages.

[0124] Based on any of the foregoing embodiments, updating the message matching order of each conditional subscription group includes:

[0125] The order of the first conditional subscription group in each conditional subscription group in the message matching order is moved to the end, and the order of the remaining conditional subscription groups in each conditional subscription group remains unchanged.

[0126] Based on any of the above embodiments, a timing removal unit is further included, and the timing removal unit is specifically used to:

[0127] Periodically remove the features of consumed messages from the feature cache.

[0128] Based on any of the above embodiments, the distribution unit 630 is specifically configured to:

[0129] In response to the distribution operation of the server, the target messages are evenly distributed to the member consumers in the conditional subscription groups.

[0130] Figure 7 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Figure 7As shown, the electronic device may include: a processor 710, a communication interface 720, a memory 730 and a communication bus 740, wherein the processor 710, the communication interface 720 and the memory 730 complete mutual communication through the communication bus 740. The processor 710 may call the logic instructions in the memory 730 to execute the message matching method of the point-to-point conditional subscription between the client and the message middleware, the method comprising: obtaining the unconsumed queue of the server; the unconsumed queue is obtained by storing the to-be-matched message in the form of a message ID; based on the maximum number of matching messages and the matching progress of each conditional subscription group, the conditional subscription groups are matched with the features of the to-be-matched messages in the unconsumed queue in the message matching order to obtain each successfully matched target message, and the target messages are removed from the unconsumed queue; the conditional subscription groups are subscription groups composed of member consumers with the same subscription conditions; in response to the distribution operation of the server, the target messages are distributed to each member consumer in the conditional subscription groups.

[0131] In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0132] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the message matching method for point-to-point conditional subscription between the client and the message middleware provided by the above methods, and the method includes: obtaining an unconsumed queue of the server; the unconsumed queue is obtained by storing the messages to be matched in the form of message IDs; based on the maximum number of matching messages and the matching progress of each conditional subscription group, the each conditional subscription group is matched with the characteristics of the messages to be matched in the unconsumed queue in the message matching order to obtain each successfully matched target message, and each target message is removed from the unconsumed queue; each conditional subscription group is a subscription group composed of member consumers with the same subscription conditions; in response to the distribution operation of the server, the each target message is distributed to each member consumer in the each conditional subscription group.

[0133] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a message matching method for point-to-point conditional subscription between a client and a message middleware provided by the above-mentioned methods, the method comprising: obtaining an unconsumed queue of a server; the unconsumed queue is obtained by storing messages to be matched in the form of message IDs; based on the maximum number of matching messages and the matching progress of each conditional subscription group, matching each conditional subscription group with the features of the messages to be matched in the unconsumed queue in a message matching order to obtain each successfully matched target message, and removing each target message from the unconsumed queue; each conditional subscription group is a subscription group composed of member consumers with the same subscription conditions; in response to the distribution operation of the server, distributing each target message to each member consumer in each conditional subscription group.

[0134] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0135] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0136] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A message matching method for point-to-point conditional subscription between a client and a message middleware, characterized in that: Applied to message middleware, the method includes: Obtain an unconsumed queue on the server side; the unconsumed queue is obtained by storing the messages to be matched in the form of message IDs; Based on the maximum number of matching messages and the matching progress of each conditional subscription group, each conditional subscription group is matched with the features of the to-be-matched messages in the unconsumed queue in a message matching order to obtain each successfully matched target message, and each target message is removed from the unconsumed queue; each conditional subscription group is a subscription group composed of member consumers with the same subscription condition; the matching progress refers to the matching index of each conditional subscription group in the unconsumed queue; In response to the distribution operation of the server, each target message is distributed to each member consumer in each conditional subscription group.

2. The message matching method for peer-to-peer conditional subscription between a client and a message middleware according to claim 1, characterized in that: The method of matching each conditional subscription group with features of the to-be-matched messages in the unconsumed queue in a message matching order based on the maximum number of matching messages and the matching progress of each conditional subscription group, obtaining each successfully matched target message, and removing each target message from the unconsumed queue includes: The first cycle is executed until the first preset condition is met: The first cycle process includes: Based on the maximum number of matching messages and the matching progress of each conditional subscription group, each conditional subscription group is matched with the features of the to-be-matched messages in the unconsumed queue in a message matching order to obtain each successfully matched target message, and each target message is removed from the unconsumed queue to obtain the target remaining messages; The first preset condition is that the target remaining message is empty.

3. The message matching method for peer-to-peer conditional subscription between a client and a message middleware according to claim 2, characterized in that: The method of matching each conditional subscription group with the features of the to-be-matched messages in the unconsumed queue in a message matching order based on the maximum number of matching messages and the matching progress of each conditional subscription group, obtaining each successfully matched target message, and removing each target message from the unconsumed queue to obtain the target remaining message includes: The second cycle is executed until the second preset condition is met: The second cycle process includes: Updating the message matching order of each conditional subscription group; Updating the matching progress of each conditional subscription group; Based on the maximum number of matching messages and the matching progress of each conditional subscription group, each conditional subscription group is matched with the features of the to-be-matched messages in the unconsumed queue in the message matching order to obtain each successfully matched target message, and each target message is removed from the unconsumed queue to obtain the target remaining messages; The second preset condition is that the message matching traversal of each conditional subscription group is completed.

4. The message matching method for peer-to-peer conditional subscription between a client and a message middleware according to claim 2, characterized in that: The method of matching each conditional subscription group with the features of the to-be-matched messages in the unconsumed queue in a message matching order based on the maximum number of matching messages and the matching progress of each conditional subscription group, obtaining each successfully matched target message, and removing each target message from the unconsumed queue to obtain the target remaining message includes: Based on the maximum number of matching messages and the matching progress of each conditional subscription group, the first conditional subscription group is matched with the features of the messages to be matched in the unconsumed queue to obtain a first target message that successfully matches, and the first target message is removed from the unconsumed queue to obtain a first remaining message; Based on the maximum number of matching messages, the intermediate conditional subscription group is matched with the features of the first remaining messages in sequence to obtain a second target message that successfully matches, and the second target message is removed from the first remaining messages to obtain a second remaining message; the intermediate conditional subscription group is a conditional subscription group between the first conditional subscription group and the last conditional subscription group; Based on the maximum number of matching messages, the last conditional subscription group is matched with the second remaining messages to obtain the last target message that matches successfully, and the last target message is removed from the second remaining messages to obtain the target remaining messages.

5. The message matching method for peer-to-peer conditional subscription between a client and a message middleware according to claim 3, characterized in that: Updating the message matching order of each conditional subscription group includes: The order of the first conditional subscription group in each conditional subscription group in the message matching order is moved to the end, and the order of the remaining conditional subscription groups in each conditional subscription group remains unchanged.

6. The message matching method for point-to-point conditional subscription between a client and a message middleware according to any one of claims 1 to 5, characterized in that: Also includes: Periodically remove the features of consumed messages from the feature cache.

7. The message matching method for point-to-point conditional subscription between a client and a message middleware according to any one of claims 1 to 5, characterized in that: The step of distributing each target message to each member consumer in each conditional subscription group in response to the distribution operation of the server includes: In response to the distribution operation of the server, the target messages are evenly distributed to the member consumers in the conditional subscription groups.

8. A message matching device for point-to-point conditional subscription between a client and a message middleware, characterized in that: Applied to message middleware, the device comprises: An acquisition unit, used for acquiring an unconsumed queue of the server; the unconsumed queue is obtained by storing the to-be-matched messages in the form of message IDs; A message matching unit is used to match each conditional subscription group with the features of the to-be-matched messages in the unconsumed queue in a message matching order based on the maximum number of matching messages and the matching progress of each conditional subscription group, obtain each successfully matched target message, and remove each target message from the unconsumed queue; each conditional subscription group is a subscription group composed of member consumers with the same subscription condition; the matching progress refers to the matching index of each conditional subscription group in the unconsumed queue; The distribution unit is used to distribute the target messages to the member consumers in the conditional subscription groups in response to the distribution operation of the server.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the message matching method for point-to-point conditional subscription between the client and the message middleware as described in any one of claims 1 to 7 is implemented.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the message matching method for point-to-point conditional subscription between a client and a message middleware as described in any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Message middleware consumption proxy method and device, proxy server and storage medium

    CN111770172A

  • Message subscription method and device, storage medium and electronic device

    CN115878341A