WO2021000693A1 - 一种服务熔断方法、装置及消息中间件 - Google Patents

一种服务熔断方法、装置及消息中间件 Download PDF

Info

Publication number
WO2021000693A1
WO2021000693A1 PCT/CN2020/094418 CN2020094418W WO2021000693A1 WO 2021000693 A1 WO2021000693 A1 WO 2021000693A1 CN 2020094418 W CN2020094418 W CN 2020094418W WO 2021000693 A1 WO2021000693 A1 WO 2021000693A1
Authority
WO
WIPO (PCT)
Prior art keywords
message
queue
message queue
depth
consumption
Prior art date
Application number
PCT/CN2020/094418
Other languages
English (en)
French (fr)
Inventor
卢道和
杨军
陈广胜
熊梦飞
梁炜强
Original Assignee
深圳前海微众银行股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳前海微众银行股份有限公司 filed Critical 深圳前海微众银行股份有限公司
Publication of WO2021000693A1 publication Critical patent/WO2021000693A1/zh

Links

Images

Classifications

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

Definitions

  • the present invention relates to the computer technology field of financial (Fintech) technology, and in particular to a method, device and message middleware for service fusing.
  • Message middleware is a middleware technology that uses message queues for message transmission.
  • the embodiments of the present application provide a service fusing method, device, and message middleware, which are used to improve the reliability of the message middleware.
  • a service fusing method includes:
  • the fuse isolation information is sent to the message producer to fuse the message service of the target message queue to the message producer.
  • determining a target message queue meeting a preset isolation condition from the message queue group according to the message consumption status information of each message queue includes:
  • the queue level depth of a message queue is continuously greater than the predetermined queue level depth threshold for the first predetermined time period, it is determined that the message queue is a target message queue that meets the preset isolation condition.
  • determining the queue-level depth of each message queue according to the queue depth of all consumer groups corresponding to each message queue includes:
  • the consumption group queue depth of the message queue for the message consumer group is determined as the queue-level depth of the message queue
  • the queue-level depth of the message queue is determined according to the message queue's queue depth for the multiple consumer groups of the multiple message consumer groups.
  • the consumption group queue depth of each message queue for each message consumer group is determined in the following way:
  • Real-time detection of the consumption progress update and total message total update of a message queue for each message consumer group and determine the consumption group queue depth of the message queue for each message consumer group according to the real-time updated message total volume and consumption progress ;
  • determining the queue-level depth of a message queue according to the queue depths of a message queue for multiple consumer groups of multiple message consumer groups includes:
  • a predetermined calculation method is used to calculate the queue depth of multiple consumer groups corresponding to a message queue, and the calculation result is determined as the queue-level depth of the message queue.
  • determining a target message queue meeting a preset isolation condition from the message queue group according to the message consumption status information of each message queue includes:
  • the message queue is a target message queue that meets the preset isolation condition.
  • the consumption rate of multiple messages of a message queue is gradually decreasing, it is determined that the message queue is a target message queue that meets the preset isolation condition.
  • the fuse isolation information is also used to indicate the isolation duration for fuse isolation of the target message queue.
  • the method after sending the fuse isolation information to the message producer, the method further includes:
  • the present invention provides a message middleware, including:
  • the obtaining module is used to obtain the message consumption status information of each message queue in the message queue group;
  • the first determining module is configured to determine a target message queue meeting a preset isolation condition from the message queue group according to the message consumption status information of each message queue;
  • the second determining module is configured to determine the fuse isolation information for the target message queue, where the fuse isolation information is used to indicate that the target message queue is fuse isolation;
  • the sending module is used to send the fuse isolation information to the message producer to fuse the message service of the target message queue to the message producer.
  • the first determining module is used to:
  • the queue level depth of a message queue is continuously greater than the predetermined queue level depth threshold for the first predetermined time period, it is determined that the message queue is a target message queue meeting the preset isolation condition.
  • the first determining module is used to:
  • the consumption group queue depth of the message queue for the message consumer group is determined as the queue-level depth of the message queue
  • the queue-level depth of the message queue is determined according to the message queue's queue depth for the multiple consumer groups of the multiple message consumer groups.
  • the first determining module is used to:
  • Real-time detection of the consumption progress update and total message total update of a message queue for each message consumer group and determine the consumption group queue depth of the message queue for each message consumer group according to the real-time updated message total volume and consumption progress ;
  • the first determining module is used to:
  • a predetermined calculation method is used to calculate the queue depth of multiple consumer groups corresponding to a message queue, and the calculation result is determined as the queue-level depth of the message queue.
  • the first determining module is used to:
  • the message queue is a target message queue that meets the preset isolation condition.
  • the consumption rate of multiple messages of a message queue is gradually decreasing, it is determined that the message queue is a target message queue that meets the preset isolation condition.
  • the fuse isolation information is also used to indicate the isolation duration for fuse isolation of the target message queue.
  • the sending module is also used to:
  • a service fuse device which includes at least one processor and at least one memory, wherein the memory stores a computer program, and when the program is executed by the processor, the processor executes Steps of the service fuse method described in any one of the above-mentioned first aspects.
  • a storage medium stores computer instructions that, when the computer instructions are run on a computer, cause the computer to execute the steps of the service fuse method described in any one of the first aspects.
  • the embodiment of the application proposes a message queue-oriented service fuse method.
  • the fuse isolation mechanism is applied to the message delivery process of message middleware, which can effectively identify abnormal consumption in the message queue, and then identify Out the abnormal message queue and the corresponding abnormal consumers, and then notify the abnormal message queue by sending a fuse signal (ie, fuse isolation information) to the message producer, so that the message producer can perceive the message queue service in time And stop sending messages to the abnormal message queue temporarily according to the instructions of the fuse isolation information, so that the fuse of the abnormal message queue serves the message producer of the message, so that as many messages as possible can be Normal consumer news, and temporarily isolate abnormal consumers, thereby improving service stability and system reliability.
  • a fuse signal ie, fuse isolation information
  • Figure 1 is a schematic diagram of message delivery using message middleware technology
  • Fig. 2a is a schematic diagram of message delivery through a message queue in a message middleware in an embodiment of the application under normal circumstances;
  • FIG. 2b is a schematic diagram of message delivery in the message queue in the message middleware through the fuse mechanism in the case of abnormal consumers in the embodiment of the application;
  • FIG. 3 is a flowchart of a service fusing method in an embodiment of the application
  • FIG. 4 is a schematic diagram of the consumption progress of consumers in the message queue in an embodiment of the application.
  • 5 is a schematic diagram of the consumption progress of two message consumer groups of a message queue in the message queue in an embodiment of the application;
  • FIG. 6 is a structural block diagram of a message middleware in an embodiment of the application.
  • FIG. 7 is a schematic structural diagram of a service fuse device in an embodiment of the application.
  • FIG. 8 is another structural diagram of the service fuse device in the embodiment of the application.
  • a plurality of may mean at least two, for example, it may be two, three or more, which is not limited in the embodiment of the present invention.
  • Message middleware also known as message middleware or message-oriented middleware, refers to the use of efficient and reliable message delivery mechanisms for platform-independent data exchange, and the integration of distributed systems based on data communication. By providing message passing and message queuing models, it can provide application decoupling, elastic scaling, redundant storage, traffic peaking, asynchronous communication, data synchronization and other functions in a distributed environment. It serves as a distributed system architecture. Important components have a pivotal position.
  • Message middleware is based on the store-and-forward mechanism of message queue (Queue), and provides a unique asynchronous transmission mechanism, which can realize application integration and data exchange based on message transmission and asynchronous transaction processing.
  • the information passed in the message middleware is collectively called a message, which is the basic unit of data exchange.
  • the message producer cluster refers to a cluster that includes multiple message producers, such as message producer A, message producer B, and message producer C as shown in Figure 1.
  • Each message producer can call the message producer individually API interface, send the message to be sent to the queue in the message middleware through the message queue service.
  • Multiple logical message queues can be deployed in the message middleware, such as the message queues Q1, Q2, Q3, and Q4 shown in Figure 1.
  • the message middleware is correspondingly deployed with a message middleware server (Broker, not shown in Figure 1. Show), Broker is used to maintain the mapping relationship between Topic (message topic) and Queue, store messages and other capabilities.
  • the Broker can also periodically and quantitatively detect the accumulation of messages in each Queue.
  • a topic can correspond to a message queue group, that is, a topic can correspond to one or more message queues, and the message queues in the message queue group are all used to provide message services for the topic.
  • a message consumer cluster refers to a cluster that includes multiple message consumers, such as message consumer E, message consumer F, and message consumer G as shown in Figure 1.
  • Each message consumer can call the API interface for receiving messages from When the message is obtained from the message middleware, this process can be understood as consuming the message, thereby completing the message transfer from the message producer to the message consumer.
  • Service fuse in order to consider the reliability of the system and prevent the overall system from slowing down or even crashing, it can be understood as disconnecting the corresponding service.
  • Fig. 2a is a schematic diagram of message delivery through message middleware under normal circumstances, and messages are delivered in this manner in the prior art.
  • Q1, Q2, Q3, and Q4 can be message queue groups for the same topic.
  • the message producer uses polling to send messages to each message queue.
  • Message consumer 1 consumes Q1 and Q2, message consumer 2Consumption Q2, Q3, and Q4, that is, a message queue may be consumed by one or more message consumers at the same time, and the message consumer 1 and message consumer 2 in Figure 2a can both refer to a type of homogeneous consumption In other words, a message queue may be consumed by multiple message consumer groups at the same time.
  • a type of homogeneous consumer or a message consumer is collectively referred to as a message consumer group.
  • a message consumer group a type of homogeneous consumer or a message consumer is collectively referred to as a message consumer group.
  • the embodiment of the present application proposes a message queue-oriented service fuse method.
  • the fuse isolation mechanism is applied to the message delivery process of message middleware, which can effectively identify abnormal consumption in the message queue. Then identify the abnormal message queue and the corresponding abnormal consumer, and then notify the abnormal message queue by sending a fuse signal (ie, fuse isolation information) to the message producer, so that the message producer can perceive the message in time.
  • a fuse signal ie, fuse isolation information
  • the abnormal message queue in the queue service and temporarily stop sending messages to the abnormal message queue according to the instructions of the fuse isolation information, so that the abnormal message queue is fuse to the message producer of the message service, so that as much as possible Messages are normal consumer messages, and abnormal consumers are temporarily isolated, thereby improving service stability and system reliability.
  • Figure 2b is a schematic diagram of message delivery after the fuse isolation mechanism for message queues in the embodiment of the present application in the presence of abnormal consumers.
  • the fuse isolation information for Q4 can be sent to the message producer to inform the message producer that Q4 needs to be temporarily isolated through the fuse isolation information.
  • the message producer is below In the second poll, Q4 will be isolated and no longer polled, that is, messages will not be sent to Q4.
  • the isolation protection of Q4 can be achieved to avoid In Q4, a large number of messages continue to accumulate and cause system exceptions, which improves the stability of the message queue service of the entire message middleware, and in turn improves the reliability of the entire system.
  • the embodiment of the present application provides a service fusing method, which can be deployed in a message middleware, for example, each step of the method can be executed by the broker in the aforementioned message middleware, please refer to As shown in FIG. 3, the process of the service fusing method in the embodiment of the present application is described as follows.
  • Step 301 Obtain message consumption status information of each message queue in the message queue group.
  • the message queue group may be a collection of one or more message queues under a topic, or in some other implementation manners, the message queue group may also be a collection of multiple message queues under different topics, in other words
  • the message queue group in the embodiment of the present application may include one or more message queues, that is, the message consumption status information of each message queue used to provide the message queue service in the message middleware can be detected, and in the specific implementation process For example, the broker can detect the message consumption status information of each message queue in real time or regularly.
  • the message consumption status information of a message queue in the embodiment of the present application is information used to indicate the real-time situation of consumption of messages in the message queue.
  • the message consumption status information in the embodiment of the present application may include, for example, the following information: Which consumer groups consume messages in the message queue, the current consumption progress of each message consumer group, the historical consumption number of each message consumer group, the current total number of messages in the message queue, and so on.
  • Step 302 According to the message consumption status information of each message queue, a target message queue that meets the preset isolation condition is determined from the message queue.
  • the current message queues that may have consumption abnormalities can be determined according to the message consumption status information of each message queue.
  • the current The message queue that may have consumption exceptions and needs to be isolated and protected is called the target message queue.
  • the abnormal message queue can be judged after obtaining the message consumption status information of all message queues; or in another possible implementation manner, it can also be obtained after obtaining a message queue After the message consumption status information, the message queue is dynamically judged whether there is a consumption abnormality in the current message queue in a timely manner, so as to ensure the timeliness of detection, thereby achieving more timely and effective control.
  • the following two methods can be used to determine the target message queue.
  • a message queue may be consumed by only one message consumer group, or it may be consumed by multiple message consumer groups at the same time. Therefore, when considering the consumption situation of a message queue in this embodiment of the application, you can Comprehensively consider the consumption situation of all message consumer groups that consume the message queue. For this reason, in the embodiment of the present application, for a message queue, two concepts of consumer group queue depth (for example, represented by Depth_Q_G) and queue-level depth (for example, represented by Depth_Q) are proposed. among them:
  • the consumer group queue depth (Depth_Q_G) of a message queue for a message consumer group indicates the number of messages in the message queue that have not been consumed by the message consumer group.
  • the queue-level depth of a message queue is calculated according to the queue depths of all consumer groups corresponding to each message consumer group that consumes the message queue.
  • the queue-level depth is used to measure the response of all message consumer groups of the message queue. The overall consumption of messages in the message queue.
  • FIG. 4 a schematic diagram of the consumption progress of the consumer group in the message queue in the embodiment of the present application, where MaxOffset indicates the total amount of messages included in the message queue, and ConsumerOffset indicates the current actual consumption of a certain message consumer group schedule.
  • the current consumption progress of consumer group 1 ie ConsumerOffset1
  • Msg2 Msg2
  • Msg4 Msg4
  • the consumer group queue corresponding to each message consumer group can be calculated Depth, it can be seen that the queue depth of a consumer group is a message queue relative to a specific message consumer group.
  • the consumer group queue depth indicates the number of unconsumed messages in a message queue by a message consumer group Margin, in other words, the message accumulation of a message queue for a message consumer group can be known through the queue depth of the consumer group.
  • the attribute of the maximum allowable depth can be set for each message queue, that is, a predetermined queue-level depth threshold (for example, represented by MaxDepth) can be preset, and the threshold is compared with the actual queue-level depth. Quantitative comparison to realize the judgment of abnormal message consumption.
  • a predetermined queue-level depth threshold for example, represented by MaxDepth
  • MaxDepth can be set for each message queue, or MaxDepth can be adjusted appropriately according to the consumer performance corresponding to each message queue, and then a differentiated MaxDepth can be set for each message queue to try to Consistent with the actual message consumer object.
  • the Depth_Q of the message queue is greater than MaxDepth, it means that the message accumulation in the message queue is large. At this time, it can be considered that the corresponding consumer may have consumption abnormalities, which means that the message queue appears If the consumption is abnormal, then it can be determined as the target message queue. In addition, in order to ensure the accuracy of the judgment and minimize temporary transient network abnormalities due to network jitter, etc., it can be judged whether Depth_Q continues to be greater than MaxDepth within a certain period of time (such as the first predetermined period of time). If so, you can finally send the message The queue is determined to be the target message queue that needs to be temporarily isolated by fuse.
  • a message queue may correspond to one or more message consumer groups. The following describes how to determine the queue-level depth Depth_Q for different situations.
  • Scenario 1 A message queue is only consumed by one message consumer group. At this time, the consumption status of the message queue is completely determined by the consumption status of the message consumer group. Therefore, the message queue can be directly used for the message consumer The group's consumer group queue depth is determined as the queue-level depth of the message queue.
  • Scenario 2 A message queue is consumed by multiple message consumer groups at the same time. At this time, the queue depth of the message queue can be comprehensively determined according to the queue depth of the message queue for the multiple consumer groups of the multiple message consumer groups.
  • a possible implementation manner is that, according to a predetermined selection rule, a consumer group queue depth that meets the predetermined selection rule among multiple consumer group queue depths may be determined as the queue-level depth of the message queue. For example, there are 4 message consumer groups corresponding to a message queue. The queue depths of these 4 message consumer groups corresponding to the message queue are represented by Depth_Q_G1, Depth_Q_G2, Depth_Q_G3, and Depth_Q_G4. Then the Depth_Q can be expressed by the following formula Calculation:
  • Depth_Q ⁇ Depth_Q_G1, Depth_Q_G2, Depth_Q_G3, Depth_Q_G4 ⁇ .
  • the Depth_Q of the message queue is one of multiple consumer group queue depths, such as the largest consumer group queue depth, or the smallest consumer group queue depth, or the consumer group whose value is approximately in the middle Queue depth, etc.
  • the largest consumer group queue depth is directly used as the Depth_Q of the message queue, that is, the message consumer group with the slowest consumption will prevail, so that possible exceptions can be determined as far as possible as those that actually require fusing isolation.
  • the timeliness of the fuse isolation as much as possible, and to ensure the reliability of the system as much as possible.
  • the predetermined selection rule in the embodiment of the present application indicates that one of multiple consumer group queue depths is directly selected as the queue-level depth of the message queue, that is, the consumption situation of a message consumer group can roughly represent all message consumers The consumption situation of the group, which can improve the flexibility of choice, and can choose flexibly according to different actual business needs.
  • another possible implementation is to calculate the queue depth of multiple consumer groups using a predetermined calculation method, and determine the calculation result as the queue-level depth of the message queue. For example, an average algorithm can be used. Or you can use the algorithm of calculating the average after weighting, and so on. In this embodiment, all the queue depths of the consumer groups can be considered as a part of it, because the queue-level depth can be generalized to a certain extent to ensure the accuracy of isolation as much as possible.
  • Method 1 Distributed real-time calculation.
  • the consumption progress update and total message total update of a message queue for each message consumer group can be detected in real time, and the message queue is determined for each message according to the total message total and consumption progress after real-time update
  • the consumer group queue depth of the consumer group For each message consumer group corresponding to a message queue, after each change in MaxOffset (if there is a new message) and each change in ConsumerOffset (for example, the message is normally consumed), it can Increase or decrease the Depth_Q_G of the message consumer group dynamically in time. Through dynamic and real-time calculation, the delay can be reduced as much as possible to ensure the accuracy and timeliness of the queue depth of each message consumer group.
  • the locally maintained queue status record file can be scanned at a preset frequency, and the total amount of messages and consumption progress of each message queue after the update recorded in the queue status record file determines that the message queue is The queue depth of the consumer group for each message consumer group.
  • the Broker side can bypass scanning the locally maintained Topic, and use the Topic as the index to query the MaxOffset and ConsumerOffset recorded in the message queue of the corresponding consumption for each message consumer group, so as to find the record file by bypassing Calculate the consumption group queue depth of each message consumer group of a message queue at a certain frequency.
  • the calculation frequency can be adjusted according to the actual use scenario. It can be seen that centralized asynchronous calculation can reduce a large number of calculation times, and because of bypass , The impact on the actual message generation, storage and consumption process is small.
  • the first determination method through the queue depth of the consumer group and the queue-level depth, when judging whether a message queue is abnormal, the actual consumption situation of the corresponding message consumer group is taken into consideration. In this way, considering the two dimensions of the queue itself and the corresponding message consumer group, the accuracy and effectiveness of the judgment of the abnormal message queue can be ensured to a certain extent.
  • the message consumption rate can be determined by the rate of change of the number of messages. Means, so the message consumption rate can reflect the fluctuation of messages in the message queue being consumed within a certain period of time.
  • the message consumption rate is used to indirectly reflect whether the message consumption is abnormal.
  • a possible implementation manner is that if the multiple message consumption rates of a message queue are all less than the predetermined message consumption rate, then the message queue is determined to be the target message queue that needs to be isolated. Because if the multiple message consumption rates of multiple adjacent detection cycles are less than the predetermined message consumption rate, it can indicate that the corresponding message queue is consumed by an abnormally small amount within a certain period of time, which is generally the same as normal consumption. Different, so you can use this method to determine abnormal consumption.
  • Another possible implementation is that if the consumption rate of multiple messages in a message queue is gradually decreasing, then the message queue is determined to be the target message queue that needs to be isolated, because if there are multiple adjacent detection cycles The consumption rate of multiple messages gradually decreases, which means that the messages in the message queue are being consumed more and more slowly. This can also be regarded as an abnormal consumption situation, so this method can be used to determine abnormal consumption.
  • Step 303 Determine the fuse isolation information for the target message queue.
  • fuse isolation information for these target message queues can be generated, and the generated fuse isolation information is used to indicate that these target messages need to be aligned. Fuse isolation.
  • fuse isolation By fuse isolation, these target message queues can be temporarily isolated and protected to a certain degree to prevent more messages from being continuously sent to the target message queue, thereby achieving isolation of abnormal consumers. It also avoids the disk overflow of the message middleware to ensure the stability of the service and the reliability of the system.
  • Step 304 Send the fuse isolation information to the message producer to fuse the message service of the message producer by the target message queue.
  • the message producer can no longer poll when sending messages. By inquiring these target message queues, no more messages will be sent to the target message queue, thereby realizing the message service of the target message queue to the message producer and ensuring the reliability of the system.
  • the isolation time required for each target message queue to be isolated can be further calculated.
  • the Broker can predict the abnormal recovery time based on the abnormal consumption of the abnormal consumers corresponding to these target message queues, and then determine the time as the isolation duration for the corresponding target message queues to be isolated. For example, if it is determined that it is due to network jitter, because in general, the duration of network jitter is relatively short, the isolation duration can be predicted as 3 seconds. Further, the determined isolation duration can be carried in the fuse isolation information and sent to the message producer. In this way, after receiving the fuse isolation information, the message producer can simultaneously determine the isolation duration for each target message queue to be isolated. Furthermore, after the indicated isolation period, the isolation of the target message queue can be automatically cancelled, that is, it can resume sending messages to it, and the message queue service of the message middleware can be fully utilized in a timely manner.
  • the fuse isolation information does not include the isolation duration
  • the fuse isolation information can be checked whether the target message queue being isolated no longer meets the aforementioned preset Once the isolation condition is found to be unsatisfied, it can be determined that the abnormal consumption problem on the consumer side has been resolved.
  • the fuse cancellation message can be sent to the message producer in time to indicate the end of the fuse of the target message queue through the fuse cancellation message Isolation means restoring the right to continue sending messages to the target message queue, and making full use of the message queue service of the message middleware in a timely manner.
  • the fuse isolation mechanism is cleverly used in the message middleware technology.
  • the fuse isolation method for message queues Through the fuse isolation method for message queues, abnormal message consumers can be isolated to a certain extent to ensure the stability of the message service And the reliability of the entire middleware system.
  • the stability of the business can be ensured as much as possible, and the user experience can be enhanced.
  • an embodiment of the present application provides a message middleware.
  • the message middleware may be the message middleware mentioned in the foregoing method embodiment, and the service fusing method in the foregoing embodiment can be implemented based on the message middleware.
  • the message middleware in the embodiment of the present application includes an obtaining module 601, a first determining module 602, a second determining module 603, and a sending module 604, where:
  • the obtaining module 601 is used to obtain the message consumption status information of each message queue in the message queue group;
  • the first determining module 602 is configured to determine a target message queue that meets the preset isolation condition from the message queue group according to the message consumption status information of each message queue;
  • the second determining module 603 is configured to determine the fuse isolation information for the target message queue, where the fuse isolation information is used to indicate the fuse isolation of the target message queue;
  • the sending module 604 is used to send the fuse isolation information to the message producer to fuse the message service of the target message queue to the message producer.
  • the first determining module 602 is configured to:
  • a predetermined queue-level depth threshold is used to determine that the message queue is a target message queue that meets the preset isolation condition.
  • the first determining module 602 is configured to:
  • the consumption group queue depth of the message queue for the message consumer group is determined as the queue-level depth of the message queue
  • the queue-level depth of the message queue is determined according to the queue depth of the multiple consumer groups of the multiple message consumer groups.
  • the first determining module 602 is configured to:
  • Real-time detection of the consumption progress update and total message total update of a message queue for each message consumer group and determine the consumption group queue depth of the message queue for each message consumer group according to the real-time updated message total volume and consumption progress ;
  • the first determining module 602 is configured to:
  • a predetermined calculation method is used to calculate the queue depth of multiple consumer groups corresponding to a message queue, and the calculation result is determined as the queue-level depth of the message queue.
  • the first determining module 602 is configured to:
  • the multiple message consumption rates of a message queue are all less than the predetermined message consumption rate, it is determined that the message queue is the target message queue meeting the preset isolation conditions; or,
  • the consumption rate of multiple messages in a message queue is gradually decreasing, it is determined that the message queue is a target message queue that meets the preset isolation condition.
  • the fuse isolation information is also used to indicate the isolation duration for fuse isolation of the target message queue.
  • the sending module 604 is further configured to:
  • the fuse cancellation information is sent to the message producer cluster, where the fuse cancellation information is used to indicate the end of the fuse of the target message queue isolation.
  • the division of modules in the embodiments of the present application is illustrative, and is only a logical function division. In actual implementation, there may be other division methods.
  • the functional modules in the various embodiments of the present application may be integrated into one process. In the device, it can also exist alone physically, or two or more modules can be integrated into one module.
  • the above-mentioned integrated modules can be implemented in the form of hardware or software functional modules.
  • an embodiment of the present application also provides a service fuse device.
  • the service fuse device is, for example, the message middleware described in the foregoing method embodiment or the broker server in the message middleware, such as
  • the service fuse device in the embodiment of the present application includes at least one processor 701, and a memory 702 and a communication interface 703 connected to the at least one processor 701.
  • the embodiment of the present application does not limit the processor 701 and the memory 702.
  • the specific connection medium between the processor 701 and the memory 702 is connected through the bus 700 as an example in FIG. 7.
  • the bus 700 is represented by a thick line in FIG. 7.
  • the connection mode between other components is only for illustration. Sexual description is not limited.
  • the bus 700 can be divided into an address bus, a data bus, a control bus, etc. For ease of presentation, only a thick line is used in FIG. 7 to represent, but it does not mean that there is only one bus or one type of bus.
  • the memory 702 stores instructions that can be executed by at least one processor 701. By executing the instructions stored in the memory 702, the at least one processor 701 can execute the steps included in the aforementioned full-link performance test method. .
  • the processor 701 is the control center of the service fuse device. It can use various interfaces and lines to connect the various parts of the entire computing device. By running or executing the instructions stored in the memory 702 and calling the data stored in the memory 702, computing Various functions and processing data of the equipment, so as to monitor the computing equipment as a whole.
  • the processor 701 may include one or more processing modules, and the processor 701 may integrate an application processor and a modem processor.
  • the processor 701 mainly processes an operating system, a user interface, and application programs, etc.
  • the adjustment processor mainly deals with wireless communication. It can be understood that the foregoing modem processor may not be integrated into the processor 701.
  • the processor 701 and the memory 702 may be implemented on the same chip, and in some embodiments, they may also be implemented on separate chips.
  • the processor 701 may be a general-purpose processor, such as a central processing unit (CPU), a digital signal processor, an application specific integrated circuit, a field programmable gate array or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, Implement or execute the methods, steps, and logical block diagrams disclosed in the embodiments of this application.
  • the general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed and completed by a hardware processor, or executed and completed by a combination of hardware and software modules in the processor.
  • the memory 702 as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules.
  • the memory 702 may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (Random Access Memory, RAM), static random access memory (Static Random Access Memory, SRAM), Programmable Read Only Memory (PROM), Read Only Memory (ROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), magnetic memory, disk , CD, etc.
  • the memory 702 is any other medium that can be used to carry or store desired program codes in the form of instructions or data structures and that can be accessed by a computer, but is not limited thereto.
  • the memory 702 in the embodiment of the present application may also be a circuit or any other device capable of realizing a storage function for storing program instructions and/or data.
  • the communication interface 703 is a transmission interface that can be used for communication. It can receive data or send data through the communication interface 703. For example, the communication interface 703 can receive data required for performance testing of the business system sent by other devices, and, The obtained performance test results are sent to other devices through the communication interface 703.
  • the service fuse device also includes a basic input/output system (I/O system) 801 that helps to transmit information between the various devices in the service fuse device.
  • I/O system input/output system
  • a mass storage device 805 that stores an operating system 802, application programs 803, and other program modules 804.
  • the basic input/output system 801 includes a display 806 for displaying information and an input device 807 such as a mouse and a keyboard for the user to input information.
  • the display 806 and the input device 807 are both connected to the processor 701 through the basic input/output system 801 connected to the system bus 700.
  • the basic input/output system 801 may also include an input and output controller for receiving and processing input from multiple other devices such as a keyboard, a mouse, or an electronic stylus.
  • the I/O controller also provides output to a display screen, printer or other type of output device.
  • the mass storage device 805 is connected to the processor 701 through a mass storage controller (not shown) connected to the system bus 700.
  • the mass storage device 805 and its associated computer readable medium provide non-volatile storage for the server package. That is, the mass storage device 805 may include a computer-readable medium (not shown) such as a hard disk or a CD-ROM drive.
  • the service fuse package can also be operated by a remote computer connected to the network via a network such as the Internet. That is, the service fuse device can be connected to the network 806 through the communication interface 703 connected to the system bus 700, or in other words, can also be connected to other types of networks or remote computer systems (not shown) using the communication interface 703 .
  • the embodiments of the present application also provide a storage medium.
  • the storage medium is, for example, a computer-readable storage medium.
  • the computer-readable storage medium stores computer instructions. When the computer instructions run on the computer, the computer Perform the steps of the aforementioned service fusing method.
  • the various aspects of the service fusing method provided in the embodiments of the present application can also be implemented in the form of a program product, which includes program code.
  • program product runs on a computer
  • the program The code is used to make the computer execute the steps in the service fusing method according to various exemplary embodiments of the present invention described above.
  • the embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may be in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, optical storage, etc.) containing computer-usable program codes.
  • a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, optical storage, etc.) containing computer-usable program codes.
  • These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
  • the device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
  • These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment.
  • the instructions provide steps for implementing functions specified in a flow or multiple flows in the flowchart and/or a block or multiple blocks in the block diagram.

Abstract

本发明公开了一种服务熔断方法、装置及消息中间件,用于提高消息中间件的可靠性。所述方法包括:获得消息队列组中的各个消息队列的消息消费状态信息;根据各个消息队列的消息消费状态信息,从所述消息队列组中确定满足预设隔离条件的目标消息队列;确定针对所述目标消息队列的熔断隔离信息,其中,所述熔断隔离信息用于指示对所述目标消息队列进行熔断隔离;将所述熔断隔离信息发送给消息生产者,以熔断所述目标消息队列对所述消息生产者的消息服务。将熔断隔离机制应用到消息中间件的消息传递过程中,能够有效地识别消息队列中的异常消费情况,进而对异常消费的消息队列进行隔离,以提高服务的稳定性和系统的可靠性。

Description

一种服务熔断方法、装置及消息中间件
相关申请的交叉引用
本申请要求在2019年07月04日提交中国专利局、申请号为201910599006.8、申请名称为“一种服务熔断方法、装置及消息中间件”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及金融(Fintech)科技的计算机技术领域,尤其涉及一种服务熔断方法、装置及消息中间件。
背景技术
随着计算机技术的发展,越来越多的技术应用在金融领域,传统金融行业正在逐步向金融科技(Fintech)转变,消息传输技术也不例外,但由于金融行业、支付行业的安全性、实时性要求,也对消息传输技术提出了更高的要求。
消息中间件是一种利用消息队列进行消息传输的中间件技术,消息中间件的消息队列中的消息的消费者往往是多个,以此来增加消息的消费能力和消费可靠性,但与此同时也带来了另外的问题,比如多个消费者中往往会出现个例,由于例如机器故障、网络抖动、程序故障等原因而导致消息消费不正常或者堵塞缓慢,但是由于消息的发送者无法感知到异常的消费者,这会导致消息生产者持续发送的消息堆积在消息队列中,从而可能产生业务故障,导致服务的稳定性和系统的可靠性较差。
发明内容
本申请实施例提供一种服务熔断方法、装置及消息中间件,用于提高消息中间件的可靠性。
第一方面,提供一种服务熔断方法,所述方法包括:
获得消息队列组中的各个消息队列的消息消费状态信息;
根据各个消息对列的消息消费状态信息,从所述消息队列组中确定满足预设隔离条件的目标消息队列;
确定针对所述目标消息队列的熔断隔离信息,其中,所述熔断隔离信息用于指示对所述目标信息队列进行熔断隔离;
将所述熔断隔离信息发送给消息生产者,以熔断所述目标消息队列对所述消息生产者的消息服务。
在一种可能的实现方式中,根据各个消息队列的消息消费状态信息,从所述消息队列组中确定满足预设隔离条件的目标消息队列,包括:
确定每个消息队列对于消费该消息队列的各个消息消费者组的消费组队列深度;其中,一个消息队列对于一个消息消费者组的消费组队列深度表明该消息队列中还未被该消息消费者组消费的消息的数量;
根据每个消息队列对应的所有消费组队列深度,确定该消息队列的队列级深度;
若一个消息队列的队列级深度在第一预定时长内持续大于预定队列级深度阈值,则确 定该消息队列为满足所述预设隔离条件的目标消息队列。
在一种可能的实现方式中,根据每个消息队列对应的所有消费组队列深度,确定该消息队列的队列级深度,包括:
若一个消息队列仅被一个消息消费者组消费,则将该消息队列对于该消息消费者组的消费组队列深度确定为该消息队列的队列级深度;
若一个消息队列被多个消息消费者组消费,则根据该消息队列分别对于所述多个消息消费者组的多个消费组队列深度确定该消息队列的队列级深度。
在一种可能的实现方式中,按照以下方式确定各个消息队列对于各个消息消费者组的消费组队列深度:
实时检测一个消息队列对于各个消息消费者组的消费进度更新和消息总量更新;并根据实时更新后的消息总量和消费进度确定该消息队列对于每个消息消费者组的消费组队列深度;
或者,
按照预设频率扫描本地维护的队列状态记录文件;并从所述队列状态记录文件中记录的各个消息队列更新后的消息总量和消费进度确定该消息队列对于每个消息消费者组的消费组队列深度。
在一种可能的实现方式中,根据一个消息队列分别对于多个消息消费者组的多个消费组队列深度确定该消息队列的队列级深度,包括:
将一个消息队列对应的多个消费组队列深度中满足预定选择规则的消费组队列深度确定为该消息队列的队列级深度;或者,
采用预定计算方式对一个消息队列对应的多个消费组队列深度进行计算处理,并将计算结果确定为该消息队列的队列级深度。
在一种可能的实现方式中,根据各个消息队列的消息消费状态信息,从所述消息队列组中确定满足预设隔离条件的目标消息队列,包括:
确定各个消息队列在第二预定时长内的多个相邻周期的多个消息消费速率;
若一个消息队列的多个消息消费速率均小于预定消息消费速率,则确定该消息队列为满足所述预设隔离条件的目标消息队列;或者,
若一个消息队列的多个消息消费速率呈逐渐减小的变化趋势,则确定该消息队列为满足所述预设隔离条件的目标消息队列。
在一种可能的实现方式中,所述熔断隔离信息还用于指示对于所述目标消息队列进行熔断隔离的隔离时长。
在一种可能的实现方式中,在将所述熔断隔离信息发送给消息生产者之后,所述方法还包括:
在所述目标消息队列不再满足所述预设隔离条件时,向所述消息生产者集群发送熔断撤销信息,其中,所述熔断撤销信息用于指示结束对所述目标消息队列的熔断隔离。
第二方面,本提供一种消息中间件,包括:
获得模块,用于获得消息队列组中的各个消息队列的消息消费状态信息;
第一确定模块,用于根据各个消息队列的消息消费状态信息,从所述消息队列组中确定满足预设隔离条件的目标消息队列;
第二确定模块,用于确定针对所述目标消息队列的熔断隔离信息,其中,所述熔断隔 离信息用于指示对所述目标消息队列进行熔断隔离;
发送模块,用于将所述熔断隔离信息发送给消息生产者,以熔断所述目标消息队列对所述消息生产者的消息服务。
在一种可能的实现方式中,所述第一确定模块用于:
确定每个消息队列对于消费该消息队列的各个消息消费者组的消费组队列深度;其中,一个消息队列对于一个消息消费者组的消费组队列深度表明该消息队列中还未被该消息消费者组消费的消息的数量;
根据每个消息队列对应的所有消费组队列深度,确定该消息队列的队列级深度;
若一个消息队列的队列级深度在第一预定时长内持续大于预定队列级深度阈值,则确定该消息队列为满足所述预设隔离条件的目标消息队列。
在一种可能的实现方式中,所述第一确定模块用于:
若一个消息队列仅被一个消息消费者组消费,则将该消息队列对于该消息消费者组的消费组队列深度确定为该消息队列的队列级深度;
若一个消息队列被多个消息消费者组消费,则根据该消息队列分别对于所述多个消息消费者组的多个消费组队列深度确定该消息队列的队列级深度。
在一种可能的实现方式中,所述第一确定模块用于:
实时检测一个消息队列对于各个消息消费者组的消费进度更新和消息总量更新;并根据实时更新后的消息总量和消费进度确定该消息队列对于每个消息消费者组的消费组队列深度;
或者,
按照预设频率扫描本地维护的队列状态记录文件;并从所述队列状态记录文件中记录的各个消息队列更新后的消息总量和消费进度确定该消息队列对于每个消息消费者组的消费组队列深度。
在一种可能的实现方式中,所述第一确定模块用于:
将一个消息队列对应的多个消费组队列深度中满足预定选择规则的消费组队列深度确定为该消息队列的队列级深度;或者,
采用预定计算方式对一个消息队列对应的多个消费组队列深度进行计算处理,并将计算结果确定为该消息队列的队列级深度。
在一种可能的实现方式中,所述第一确定模块用于:
确定各个消息队列在第二预定时长内的多个相邻周期的多个消息消费速率;
若一个消息队列的多个消息消费速率均小于预定消息消费速率,则确定该消息队列为满足所述预设隔离条件的目标消息队列;或者,
若一个消息队列的多个消息消费速率呈逐渐减小的变化趋势,则确定该消息队列为满足所述预设隔离条件的目标消息队列。
在一种可能的实现方式中,所述熔断隔离信息还用于指示对于所述目标消息队列进行熔断隔离的隔离时长。
在一种可能的实现方式中,所述发送模块还用于:
在将所述熔断隔离信息发送给消息生产者之后,在所述目标消息队列不再满足所述预设隔离条件时,向所述消息生产者集群发送熔断撤销信息,其中,所述熔断撤销信息用于指示结束对所述目标消息队列的熔断隔离。
第三方面,提供一种服务熔断装置,包括至少一个处理器、以及至少一个存储器,其中,所述存储器存储有计算机程序,当所述程序被所述处理器执行时,使得所述处理器执行上述第一方面中任一所述的服务熔断方法的步骤。
第四方面,提供一种存储介质,所述存储介质存储有计算机指令,当所述计算机指令在计算机上运行时,使得计算机执行上述第一方面中任一所述的服务熔断方法的步骤。
本申请实施例提出了一种面向消息队列的服务熔断方法,在该方法中,将熔断隔离机制应用到消息中间件的消息传递过程中,能够有效地识别消息队列中的异常消费情况,进而识别出存在异常的消息队列以及对应的异常的消费者,进而通过向消息生产者发送熔断信号(即熔断隔离信息)的方式来通知异常的消息队列,使得消息生产者能够及时地感知到消息队列服务中的异常消息队列,并根据熔断隔离信息的指示暂时停止向异常的消息队列继续发送消息,从而熔断异常的消息队列对消息生产者的消息服务,这样,可以尽可能地让更多的消息被正常的消费者消息,而暂时地隔离异常的消费者,进而提高服务的稳定性和系统的可靠性。
应当理解的是,以上的一般描述和后文的细节描述仅是示例性和解释性的,并不能限制本公开。
附图说明
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据提供的附图获得其他的附图。
图1为利用消息中间件技术传递消息的示意图;
图2a为本申请实施例中在正常情况下,通过消息中间件中的消息队列传递消息的示意图;
图2b为本申请实施例中在存在异常消费者的情况下,通过熔断机制在消息中间件中的消息队列传递消息的示意图;
图3为本申请实施例中的服务熔断方法的流程图;
图4为本申请实施例中的消息队列中的消费者的消费进度的示意图;
图5为本申请实施例中的一个消息队列的两个消息消费者组在该消息队列中的消费进度的示意图;
图6为本申请实施例中的消息中间件的结构框图;
图7为本申请实施例中的服务熔断装置的结构示意图;
图8为本申请实施例中的服务熔断装置的另一结构示意图。
具体实施方式
为使本发明的目的、技术方案和优点更加清楚明白,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。在不冲突的情况下,本发明中的实施例及实施例中的特征可以相互任意组合。并且,虽然在 流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。
本发明的说明书和权利要求书及上述附图中的术语“第一”和“第二”是用于区别不同对象,而非用于描述特定顺序。此外,术语“包括”以及它们任何变形,意图在于覆盖不排他的保护。例如包含了一系列步骤或单元的过程、方法、系统、产品或设备没有限定于已列出的步骤或单元,而是可选地还包括没有列出的步骤或单元,或可选地还包括对于这些过程、方法、产品或设备固有的其它步骤或单元。
本发明实施例中,“多个”可以表示至少两个,例如可以是两个、三个或者更多个,本发明实施例不做限制。
另外,本文中术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中字符“/”,在不做特别说明的情况下,一般表示前后关联对象是一种“或”的关系。
以下对本文中涉及的部分技术用语进行说明。
1、消息中间件,又称作消息的中间件或面向消息的中间件,是指利用高效可靠的消息传递机制进行与平台无关的数据交流,并基于数据通信来进行分布式系统的集成。通过提供消息传递和消息排队模型,它可以在分布式环境下提供应用解耦、弹性伸缩、冗余存储、流量削峰、异步通信、数据同步等等功能,其作为分布式系统架构中的一个重要组件,有着举足轻重的地位。
消息中间件基于消息队列(Queue)的存储-转发机制,并提供特有的异步传输机制,能够基于消息传输和异步事物处理实现应用整合与数据交换。在消息中间件中传递的信息统称为消息,它是数据交换的基本单位。
请参见图1所示的利用消息中间件进行消息传递的示意图,包括消息中间件、消息生产者集群和消息消费者集群这三部分。
其中,消息生产者集群是指包括多个消息生产者的集群,如图1中所示的消息生产者A、消息生产者B和消息生产者C,每个消息生产者可以各自调用发送消息的API接口,将需要发送的消息通过消息队列服务发送到消息中间件中的队列中。
消息中间件中可以部署有多个逻辑上的消息队列,例如图1中所示的消息队列Q1、Q2、Q3、Q4,消息中间件对应部署有消息中间件服务端(Broker,图1中未示出),Broker用于提供维护Topic(消息主题)与Queue的映射关系,存储消息等能力,同时,Broker端还可以定时定量检测每个Queue的消息堆积情况。在消息中间件中,一个Topic可以对应维护有一个消息队列组,即一个Topic可以对应一个或多个消息队列,该消息队列组中的消息队列均用于为该Topic提供消息服务。
消息消费者集群是指包括多个消息消费者的集群,如图1中所示的消息消费者E、消息消费者F和消息消费者G,每个消息消费者可以调用接收消息的API接口从消息中间件处获得消息,这个过程即可以理解为是消费消息,从而完成了到消息生产者到消息消费者之间的消息传递。
2、服务熔断,为考虑系统的可靠性,防止系统的整体缓慢甚至奔溃的一种安全机制,可以理解为断开相应的服务。
以下介绍本申请的设计思想。
如前所述的,现有的消息中间件技术中,若消息消费者中出现例如由于网络抖动或机器故障的异常消费者时,而由于消息生产者无法感知这一异常,还是正常的往消息队列中发送消息,由于异常消费者无法再正常的消费该消息队列中的消息,这将会导致消息队列中的消息出现大量堆积,直至Broker磁盘写满,消息生产者可能才能感知到前述的异常,而Broker磁盘写满可能引起其它消息队列的消费也出现异常,例如出现雪崩现象,所以,现有的消息中间件技术中,容易出现消息传递异常而导致服务稳定性下降,系统的可靠性较差,这种情况不符合银行等金融机构开展业务(如存款业务、查账业务等)的需求。
如参见图2a所示,图2a为在正常情况下通过消息中间件传递消息的示意图,现有技术中均是按照此方式传递消息。在图2a中,Q1、Q2、Q3和Q4可以是针对同一Topic的消息队列组,消息生产者采用轮询的方式往各个消息队列中发送消息,消息消费者1消费Q1和Q2,消息消费者2消费Q2、Q3和Q4,也就是说,一个消息队列可能同时被一个或多个消息消费者消费,而图2a中的消息消费者1和消息消费者2均可以是指一类同质消费者实例的消息消费者组,换言之,一个消息队列可能同时被多个消息消费组消费,所以,本申请实施例中将一类同质消费者或者一个消息消费者均统称为消息消费者组。按照现有的方式,即使某个消息消费者组出现消费异常而导致对应消费的消息队列出现异常,由于消息生产者无法感知这些异常,所以仍然会正常的往各个消息队列中发送消息,进而影响系统的可靠性。
鉴于此,本申请实施例提出了一种面向消息队列的服务熔断方法,通过该方法,将熔断隔离机制应用到消息中间件的消息传递过程中,能够有效地识别消息队列中的异常消费情况,进而识别出存在异常的消息队列以及对应的异常的消费者,进而通过向消息生产者发送熔断信号(即熔断隔离信息)的方式来通知异常的消息队列,使得消息生产者能够及时地感知到消息队列服务中的异常消息队列,并根据熔断隔离信息的指示暂时停止向异常的消息队列继续发送消息,从而熔断异常的消息队列对消息生产者的消息服务,这样,可以尽可能地让更多的消息被正常的消费者消息,而暂时地隔离异常的消费者,进而提高服务稳定性和系统的可靠性。
请参见图2b所示,图2b为在存在异常消费者的情况下,通过本申请实施例中的面向消息队列的熔断隔离机制后的消息传递的示意图,以Q4出现异常为例,当Broker端检测到Q4出现异常之后,则可以向消息生产者发送针对Q4的熔断隔离信息,以通过该熔断隔离信息及时地告知消息生产者需要暂时隔离Q4,根据该熔断隔离信息的指示,消息生产者在下次轮询时则会对Q4进行隔离而不再对其进行轮询,即不会继续向Q4中发送消息,通过熔断Q4对消息生产者的消息服务,可以实现对Q4的隔离保护,以避免Q4中持续堆积大量消息而导致系统异常,提高整个消息中间件的消息队列服务的稳定性,依次提高整个系统的可靠性。
为进一步说明本申请实施例提供的技术方案,下面结合附图以及具体实施方式对此进行详细的说明。虽然本申请实施例提供了如下述实施例或附图所示的方法操作步骤,但基于常规或者无需创造性的劳动在所述方法中可以包括更多或者更少的操作步骤。在逻辑上不存在必要因果关系的步骤中,这些步骤的执行顺序不限于本申请实施例提供的执行顺序。所述方法在实际的处理过程中或者装置执行时,可按照实施例或者附图所示的方法顺序执行或者并行执行。
基于上述内容,本申请实施例提供一种服务熔断方法,该服务熔断方法可以部署到消 息中间件中,例如可以由前述提到的消息中间件中的Broker端执行该方法的各个步骤,请参见图3所示,本申请实施例中的服务熔断方法的流程描述如下。
步骤301:获得消息队列组中的各个消息队列的消息消费状态信息。
其中,消息队列组可以是一个Topic下的一个或多个消息队列的集合,或者在其它的一些实施方式中,该消息队列组也可能是针对不同的Topic下的多个消息队列的集合,换言之,本申请实施例中的消息队列组可以包括一个或多个消息队列,也就是说,可以检测消息中间件中用于提供消息队列服务的每个消息队列的消息消费状态信息,在具体实施过程中,例如可以由Broker端实时或者定时地检测各个消息队列的消息消费状态信息。
本申请实施例中的一个消息队列的消息消费状态信息,是用于表明该消息队列中的消息被消费的实时情况的信息,本申请实施例中的消息消费状态信息例如可以包括以下信息:该消息队列中的消息被哪些消费者组消费、每个消息消费者组的当前消费进度、每个消息消费者组的历史消费数量、该消息队列中当前的总消息数量,等等。
步骤302:根据各个消息队列的消息消费状态信息,从消息队列中确定满足预设隔离条件的目标消息队列。
在获得了各个消息队列的消息消费状态信息之后,则可以根据每个消息队列的消息消费状态信息来确定当前可能出现消费异常的消息队列,为了便于描述,本申请实施例中将确定出的当前可能出现消费异常而需要被隔离保护的消息队列称作目标消息队列。
需要说明的是,在具体实施过程中,可以将所有消息队列的消息消费状态信息获取之后才进行异常消息队列的判断;或者另一种可能的实施方式中,也可以是在获得一个消息对列的消息消费状态信息之后,就及时地对该消息队列当前是否出现消费异常进行动态的判断,这样确保检测的及时性,从而实现更及时更有效的控制。
在具体实施过程中,例如可以采用以下两种方式确定目标消息队列。
第一种确定方式
如前所述的,一个消息队列有可能仅被一个消息消费者组消费,或者也可能同时被多个消息消费者组消费,所以本申请实施例中在考虑一个消息队列的消费情况时,可以综合消费该消息队列的所有消息消费者组的消费情况综合考虑。为此,本申请实施例中,针对一个消息队列,提出了消费组队列深度(例如以Depth_Q_G表示)和队列级深度(例如以Depth_Q表示)这两个概念。其中:
一个消息队列对于一个消息消费者组的消费组队列深度(Depth_Q_G)表明该消息队列中还未被该消息消费者组消费的消息的数量。
一个消息队列的队列级深度是根据消费该消息队列的各个消息消费者组对应的所有消费组队列深度计算得到的,队列级深度是用于衡量该消息队列的所有消息消费者组的对该消息队列中的消息的总体消费情况。
如图4所示的本申请实施例中的消息队列中的消费者组的消费进度的示意图,其中MaxOffset表明消息队列中包括的消息总量,而ConsumerOffset表明某个消息消费者组当前实际的消费进度。再结合图5理解,假设同时有两个消息消费者(即消费组1和消费组2)对同一消息队列消费,消费组1的当前消费进度(即ConsumerOffset1)为Msg2,即可以理解为消费组1当前正消费到编号为“2”的消息,以及消费组2的当前消费进度(即ConsumerOffset2)为Msg4,即可以理解为消费组2当前正消费到编号为“4”的消息。
进一步地,在确定消息队列中的消息总量和每个消息消费者组的当前消费进度之后, 按照Depth_Q_G=MaxOffset-ConsumerOffset的公式,则可以计算出每个消息消费者组对应的消费组队列深度,可见,消费组队列深度是一个消息队列相对于一个特定的消息消费者组而言的,消费组队列深度表明了一个消息消费者组在一个消息队列中的还未消费的消息的余量,换言之,通过消费组队列深度可以知晓一个消息队列对于一个消息消费者组的消息堆积情况。
所以,在第一种确定方式中,可以先确定每个消息队列对于消费该消息队列的各个消息消费者组的消费组队列深度,再根据每个消息队列对应的所有消费组队列深度,确定该消息队列的队列级深度,进一步地,再根据一个消息队列的队列级深度来判断该消息队列是否是消费出现异常的目标消息队列。
在一种可能的实施方式中,例如可以为每个消息队列设置最大容许深度的属性,即可以预先设置一个预定队列级深度阈值(例如以MaxDepth表示),通过该阈值与实际的队列级深度的量化比较来实现异常消息消费的判断。在具体实施过程中,可以为每个消息队列设置相同的MaxDepth,或者也可以根据每个消息队列对应的消费者性能对MaxDepth进行适当调整,进而可以为各个消息队列设置差异化的MaxDepth,以尽量与实际的消息消费对象相符。
进一步地,对于一个消息队列,若该消息队列的Depth_Q大于MaxDepth,即表明该消息队列中的消息堆积量较大,此时则可以认为对应的消费者可能出现消费异常,即表明该消息队列出现消费异常,此时则可以将其确定为目标消息队列。另外,为了确保判断准确,以尽量减少由于网络抖动等临时的瞬态的网络异常,可以判断在一定时长(例如第一预定时长)内,Depth_Q是否持续大于MaxDepth,若是,则可以最终将该消息队列确定为是需要暂时被熔断隔离的目标消息队列。
如前所述的,在实际中,一个消息队列可能对应一个或多个消息消费者组,针对不同情形以下分别说明队列级深度Depth_Q的确定方式。
情形1:一个消息队列仅被一个消息消费者组消费,此时该消息队列的消费情况则完全通过该消息消费者组消费的消费情况决定,所以,可以直接将该消息队列对于该消息消费者组的消费组队列深度确定为该消息队列的队列级深度。
情形2:一个消息队列同时被多个消息消费者组消费,此时则可以根据该消息队列分别对于多个消息消费者组的多个消费组队列深度综合确定该消息队列的队列级深度。
针对情形2,一种可能的实施方式是,可以按照预定选择规则,将多个消费组队列深度中满足预定选择规则的消费组队列深度确定为该消息队列的队列级深度。例如,一个消息队列对应的消息消费者组有4个,这4个消息消费者组对应该消息队列的消费组队列深度分别以Depth_Q_G1、Depth_Q_G2、Depth_Q_G3和Depth_Q_G4表示,那么则可以以下公式表示Depth_Q的计算:
Depth_Q={Depth_Q_G1,Depth_Q_G2,Depth_Q_G3,Depth_Q_G4}。
即,消息队列的Depth_Q为多个消费组队列深度中的可能的一个,例如是最大的消费组队列深度,或者是最小的消费组队列深度,或者是取值大概处于中间的消费组队列深度,等等。例如当以最大的消费组队列深度直接作为消息队列的Depth_Q时,即以消费最慢的消息消费者组为准,这样可以尽量地将可能出现的异常就确定为实际需要熔断隔离的异常,以尽量确保熔断隔离的及时性,尽量确保系统可靠性。所以,本申请实施例中的预定选择规则即表明从多个消费组队列深度中直接选择其中一个作为消息队列的队列级深度,即可 以一个消息消费者组的消费情况大致代表所有消息消费者组的消费情况,这样可以提高选择的灵活性,可以针对不同的实际业务需求灵活选择。
针对情形2,另一种可能的实施方式是,采用预定计算方式对多个消费组队列深度进行计算处理,并将计算结果确定为该消息队列的队列级深度,例如可以采用平均值算法,或者可以采用加权后再求平均值的算法,等等。在该实施方式中,可以综合将所有的消费组队列深度完全作为其中的一部分考虑因为,可以在一定程度上将队列级深度进行泛化,以尽量确保隔离的准确性。
另外,在具体实施过程中,对于各个消息消费者组的消费组队列深度,大致可以采用以下两种方式来进行计算。
方式一:分散式实时计算。
对于分散式实时计算的方式,可以实时检测一个消息队列对于各个消息消费者组的消费进度更新和消息总量更新,并根据实时更新后的消息总量和消费进度确定该消息队列对于每个消息消费者组的消费组队列深度。具体来说,对于一个消息队列对应的每个消息消费者组来说,在每产生一次MaxOffset的变化(如有新消息)以及每产生一次ConsumerOffset的变化(如消息被正常消费)后,都能及时动态地对该消息消费者组的Depth_Q_G进行增减。通过动态地实时地计算,可以尽量的减少时延,以尽量确保各个消息消费者组的消费组队列深度的准确性和时效性。
方式二:集中式异步计算。
对于集中式异步计算的方式,可以按照预设频率扫描本地维护的队列状态记录文件,并从该队列状态记录文件中记录的各个消息队列更新后的消息总量和消费进度确定该消息队列对于每个消息消费者组的消费组队列深度。具体来说,Broker端可以旁路扫描本地维护的Topic,以Topic为索引,针对各个消息消费者组查询对应消费的消息队列中记录的MaxOffset与ConsumerOffset,从而通过旁路查找记录文件的方式可以以一定频率计算出一个消息队列的各个消息消费者组的消费组队列深度,计算频次可以根据实际使用场景调整,可以看出,集中式异步计算可以减少大量的计算次数,且因为旁路的原因,对实际消息的产生存储与消费过程的影响较小。
综上,在第一种确定方式中,通过消费组队列深度和队列级深度,在对一个消息队列是否异常进行判断时,是将与其对应的消息消费者组的实际消费情况考虑在内,这样从队列本身以及与其对应的消息消费者组这两个维度来综合考虑,可以在一定程度上确保异常消息队列判断的准确性和有效性。
第二种确定方式
在第二种确定方式中,可以先确定各个消息队列在一定时长(例如第二预定时长)的多个相邻周期的多个消息消费速率,其中,消息消费速率可以通过消息数量的变化速率来表示,所以消息消费速率,可以反映消息队列中的消息在一定时间内被消费的波动情况。因为一般来说,在未出现异常消费的情况下,消费者是以比较均匀的消费速率来消费消息的,一般不会长时间的出现较大幅度的消费波动,基于此,本申请实施例中通过消息消费速率来间接的反映消息消费是否异常。
一种可能的实施方式是,若一个消息队列的多个消息消费速率均小于预定消息消费速率,则确定该消息队列为需要隔离的目标消息队列。因为若相邻的多个检测周期的多个消息消费速率均小于预定消息消费速率,则可以表明对应该消息队列在一定时长内均被异常 的小数量消费,这与正常的消费情况一般是存在差异的,所以可以采用该方式来确定异常的消费。
另一种可能的实施方式是,若一个消息队列的多个消息消费速率呈逐渐减小的变化趋势,则确定该消息队列为需要隔离的目标消息队列,因为,若相邻的多个检测周期的多个消息消费速率逐渐减小,则说明该消息队列中的消息被消费的越来越慢,这也可以认为是一种异常的消费情况,所以可以采用该方式来确定异常的消费。
步骤303:确定针对目标消息队列的熔断隔离信息。
在采用上述介绍的方式确定出需要被隔离的目标消息队列之后,则可以生成针对这些目标消息队列的熔断隔离信息,而针对生成的熔断隔离信息,则是用于指示需要对这些目标消息对列进行熔断隔离,通过熔断隔离的方式,可以暂时地对这些目标消息队列进行一定程度的隔离保护,以避免更多的消息持续的发送到目标消息队列中,从而实现对异常消费者的隔离,同时也避免了消息中间件的磁盘溢出,以确保服务的稳定和系统的可靠性。
步骤304:将熔断隔离信息发送给消息生产者,以熔断目标消息队列对该消息生产者的消息服务。
进一步地,在生成上述的熔断隔离信息之后,则可以将其发送给这些目标消息队列的消息生产者,消息生产者根据该熔断隔离信息的指示,则在轮询发送消息时就可以不再轮询这些目标消息队列,进而也就不会再往目标消息队列发送消息,从而实现目标消息队列对消息生产者的消息服务,确保系统的可靠性。
在本申请实施例中,在确定出需要被熔断隔离的目标消息队列之后,还可以进一步地计算各个目标消息队列需要给隔离的隔离时长。具体来说,Broker端可以根据这些目标消息队列对应的异常消费者的消费异常原因来预测异常恢复的时间,进而将该将时间确定为对应的目标消息队列需要被隔离的隔离时长。例如,若确定是由于网络抖动原因,因为一般来说网络抖动持续时间较短,则可以将隔离时长预测为3秒。进一步地,可以将确定出的隔离时长携带在熔断隔离信息中一并发送给消息生产者,这样,消息生产者在收到熔断隔离信息之后,可以同时确定各个目标消息队列被隔离的隔离时长,进而可以在经过所指示的隔离时长后,自动撤销对目标消息队列的隔离,即恢复对其继续发送消息,以及时充分地利用消息中间件的消息队列服务。
在另一种实施方式中,若熔断隔离信息中并未包括隔离时长,那么在向消息生产者发送熔断隔离信息之后,则可以再检测正在被隔离的目标消息队列是否不再满足前述的预设隔离条件,一旦发现不满足,则可以确定消费者端的异常消费问题已经解决,此时则可以及时地再向消息生产者发送熔断撤销信息,以通过该熔断撤销信息指示结束对目标消息队列的熔断隔离,即恢复继续向目标消息队列发送消息的权限,以及时充分地利用消息中间件的消息队列服务。
本申请实施例,将熔断隔离机制巧妙地运用在了消息中间件技术中,通过面向消息队列的熔断隔离方式,可以在一定程度上对异常的消息消费者进行隔离,以确保消息服务的稳定性以及整个中间件系统的可靠性。这样,例如在银行等金融机构开展的存款业务、查账业务、支付业务等业务场景中,可以尽量确保业务的稳定性,增强用户的使用体验。
基于同一发明构思,本申请实施例提供一种消息中间件。该消息中间件可以是前述方法实施例中所提到的消息中间件,基于该消息中间件可以实现前述实施例中的服务熔断方法。请参见图6所示,本申请实施例中的消息中间件包括获得模块601、第一确定模块602、 第二确定模块603和发送模块604,其中:
获得模块601,用于获得消息队列组中的各个消息队列的消息消费状态信息;
第一确定模块602,用于根据各个消息队列的消息消费状态信息,从消息队列组中确定满足预设隔离条件的目标消息队列;
第二确定模块603,用于确定针对目标消息队列的熔断隔离信息,其中,熔断隔离信息用于指示对目标消息队列进行熔断隔离;
发送模块604,用于将熔断隔离信息发送给消息生产者,以熔断目标消息队列对消息生产者的消息服务。
在一种可能的实施方式中,第一确定模块602用于:
确定每个消息队列对于消费该消息队列的各个消息消费者组的消费组队列深度,其中,一个消息队列对于一个消息消费者组的消费组队列深度表明该消息队列中还未被该消息消费者组消费的消息的数量;并根据每个消息队列对应的所有消费组队列深度,确定该消息队列的队列级深度;以及若一个消息队列的队列级深度在第一预定时长内持续大于预定队列级深度阈值,则确定该消息队列为满足预设隔离条件的目标消息队列。
在一种可能的实施方式中,第一确定模块602用于:
若一个消息队列仅被一个消息消费者组消费,则将该消息队列对于该消息消费者组的消费组队列深度确定为该消息队列的队列级深度;
若一个消息队列被多个消息消费者组消费,则根据该消息队列分别对于多个消息消费者组的多个消费组队列深度确定该消息队列的队列级深度。
在一种可能的实施方式中,第一确定模块602用于:
实时检测一个消息队列对于各个消息消费者组的消费进度更新和消息总量更新;并根据实时更新后的消息总量和消费进度确定该消息队列对于每个消息消费者组的消费组队列深度;
或者,
按照预设频率扫描本地维护的队列状态记录文件;并从队列状态记录文件中记录的各个消息队列更新后的消息总量和消费进度确定该消息队列对于每个消息消费者组的消费组队列深度。
在一种可能的实施方式中,第一确定模块602用于:
将一个消息队列对应的多个消费组队列深度中满足预定选择规则的消费组队列深度确定为该消息队列的队列级深度;或者,
采用预定计算方式对一个消息队列对应的多个消费组队列深度进行计算处理,并将计算结果确定为该消息队列的队列级深度。
在一种可能的实施方式中,第一确定模块602用于:
确定各个消息队列在第二预定时长内的多个相邻周期的多个消息消费速率;
若一个消息队列的多个消息消费速率均小于预定消息消费速率,则确定该消息队列为满足预设隔离条件的目标消息队列;或者,
若一个消息队列的多个消息消费速率呈逐渐减小的变化趋势,则确定该消息队列为满足预设隔离条件的目标消息队列。
在一种可能的实施方式中,熔断隔离信息还用于指示对于目标消息队列进行熔断隔离的隔离时长。
在一种可能的实施方式中,发送模块604还用于:
在将熔断隔离信息发送给消息生产者之后,在目标消息队列不再满足预设隔离条件时,向消息生产者集群发送熔断撤销信息,其中,熔断撤销信息用于指示结束对目标消息队列的熔断隔离。
前述的服务熔断方法的实施例涉及的各步骤的所有相关内容均可援引到本申请施例中的图像处理装置所对应的功能模块的功能描述,在此不再赘述。
本申请实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,另外,在本申请各个实施例中的各功能模块可以集成在一个处理器中,也可以是单独物理存在,也可以两个或两个以上模块集成在一个模块中。上述集成的模块既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。
基于同一发明构思,基于同一发明构思,本申请实施例还提供一种服务熔断装置,该服务熔断装置例如是前述方法实施例中所说明的消息中间件或消息中间件中的Broker服务端,如图7所示,本申请实施例中的服务熔断装置包括至少一个处理器701,以及与至少一个处理器701连接的存储器702和通信接口703,本申请实施例中不限定处理器701与存储器702之间的具体连接介质,图7中是以处理器701和存储器702之间通过总线700连接为例,总线700在图7中以粗线表示,其它部件之间的连接方式,仅是进行示意性说明,并不引以为限。总线700可以分为地址总线、数据总线、控制总线等,为便于表示,图7中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。
在本申请实施例中,存储器702存储有可被至少一个处理器701执行的指令,至少一个处理器701通过执行存储器702存储的指令,可以执行前述的全链路性能测试方法中所包括的步骤。
其中,处理器701是服务熔断装置的控制中心,可以利用各种接口和线路连接整个计算设备的各个部分,通过运行或执行存储在存储器702内的指令以及调用存储在存储器702内的数据,计算设备的各种功能和处理数据,从而对计算设备进行整体监控。可选的,处理器701可包括一个或多个处理模块,处理器701可集成应用处理器和调制解调处理器,其中,处理器701主要处理操作系统、用户界面和应用程序等,调制解调处理器主要处理无线通信。可以理解的是,上述调制解调处理器也可以不集成到处理器701中。在一些实施例中,处理器701和存储器702可以在同一芯片上实现,在一些实施例中,它们也可以在独立的芯片上分别实现。
处理器701可以是通用处理器,例如中央处理器(CPU)、数字信号处理器、专用集成电路、现场可编程门阵列或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件,可以实现或者执行本申请实施例中公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件处理器执行完成,或者用处理器中的硬件及软件模块组合执行完成。
存储器702作为一种非易失性计算机可读存储介质,可用于存储非易失性软件程序、非易失性计算机可执行程序以及模块。存储器702可以包括至少一种类型的存储介质,例如可以包括闪存、硬盘、多媒体卡、卡型存储器、随机访问存储器(Random Access Memory,RAM)、静态随机访问存储器(Static Random Access Memory,SRAM)、可编程只读存储器(Programmable Read Only Memory,PROM)、只读存储器(Read Only Memory,ROM)、带电可擦除可编程只读存储器(Electrically Erasable Programmable Read-Only Memory, EEPROM)、磁性存储器、磁盘、光盘等等。存储器702是能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质,但不限于此。本申请实施例中的存储器702还可以是电路或者其它任意能够实现存储功能的装置,用于存储程序指令和/或数据。
通信接口703是能够用于进行通信的传输接口,可以通过通信接口703接收数据或者发送数据,例如可以通过通信接口703接收其它设备发送的对业务系统进行性能测试所需的数据,以及,还可以通过该通信接口703将获得的性能测试结果发送给其它设备。
参见图8所示的服务熔断装置的进一步地的结构示意图,该服务熔断装置还包括帮助服务熔断装置内的各个器件之间传输信息的基本输入/输出系统(I/O系统)801、用于存储操作系统802、应用程序803和其他程序模块804的大容量存储设备805。
基本输入/输出系统801包括有用于显示信息的显示器806和用于用户输入信息的诸如鼠标、键盘之类的输入设备807。其中显示器806和输入设备807都通过连接到系统总线700的基本输入/输出系统801连接到处理器701。所述基本输入/输出系统801还可以包括输入输出控制器以用于接收和处理来自键盘、鼠标、或电子触控笔等多个其他设备的输入。类似地,输入输出控制器还提供输出到显示屏、打印机或其他类型的输出设备。
所述大容量存储设备805通过连接到系统总线700的大容量存储控制器(未示出)连接到处理器701。所述大容量存储设备805及其相关联的计算机可读介质为该服务器包提供非易失性存储。也就是说,大容量存储设备805可以包括诸如硬盘或者CD-ROM驱动器之类的计算机可读介质(未示出)。
根据本发明的各种实施例,该服务熔断装置包还可以通过诸如因特网等网络连接到网络上的远程计算机运行。也即该服务熔断装置可以通过连接在所述系统总线700上的通信接口703连接到网络806,或者说,也可以使用通信接口703来连接到其他类型的网络或远程计算机系统(未示出)。
基于同一发明构思,本申请实施例还提供一种存储介质,该存储介质例如是计算机可读存储介质,该计算机可读存储介质存储有计算机指令,当该计算机指令在计算机上运行时,使得计算机执行如前述的服务熔断方法的步骤。
在一些可能的实施方式中,本申请实施例提供的服务熔断方法的各个方面还可以实现为一种程序产品的形式,其包括程序代码,当所述程序产品在计算机上运行时,所述程序代码用于使所述计算机执行前文述描述的根据本发明各种示例性实施方式的服务熔断方法中的步骤。
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。
本发明是参照根据本申请实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用 于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
显然,本领域的技术人员可以对本发明进行各种改动和变型而不脱离本发明的精神和范围。这样,倘若本发明的这些修改和变型属于本发明权利要求及其等同技术的范围之内,则本发明也意图包含这些改动和变型在内。

Claims (11)

  1. 一种服务熔断方法,其特征在于,所述方法包括:
    获得消息队列组中的各个消息队列的消息消费状态信息;
    根据各个消息队列的消息消费状态信息,从所述消息队列组中确定满足预设隔离条件的目标消息队列;
    确定针对所述目标消息队列的熔断隔离信息,其中,所述熔断隔离信息用于指示对所述目标消息队列进行熔断隔离;
    将所述熔断隔离信息发送给消息生产者,以熔断所述目标消息队列对所述消息生产者的消息服务。
  2. 如权利要求1所述的方法,其特征在于,根据各个消息队列的消息消费状态信息,从所述消息队列组中确定满足预设隔离条件的目标消息队列,包括:
    确定每个消息队列对于消费该消息队列的各个消息消费者组的消费组队列深度;其中,一个消息队列对于一个消息消费者组的消费组队列深度表明该消息队列中还未被该消息消费者组消费的消息的数量;
    根据每个消息队列对应的所有消费组队列深度,确定该消息队列的队列级深度;
    若一个消息队列的队列级深度在第一预定时长内持续大于预定队列级深度阈值,则确定该消息队列为满足所述预设隔离条件的目标消息队列。
  3. 如权利要求2所述的方法,其特征在于,根据每个消息队列对应的所有消费组队列深度,确定该消息队列的队列级深度,包括:
    若一个消息队列仅被一个消息消费者组消费,则将该消息队列对于该消息消费者组的消费组队列深度确定为该消息队列的队列级深度;
    若一个消息队列被多个消息消费者组消费,则根据该消息队列分别对于所述多个消息消费者组的多个消费组队列深度确定该消息队列的队列级深度。
  4. 如权利要求3所述的方法,其特征在于,按照以下方式确定各个消息队列对于各个消息消费者组的消费组队列深度:
    实时检测一个消息队列对于各个消息消费者组的消费进度更新和消息总量更新;并根据实时更新后的消息总量和消费进度确定该消息队列对于每个消息消费者组的消费组队列深度;
    或者,
    按照预设频率扫描本地维护的队列状态记录文件;并从所述队列状态记录文件中记录的各个消息队列更新后的消息总量和消费进度确定该消息队列对于每个消息消费者组的消费组队列深度。
  5. 如权利要求3所述的方法,其特征在于,根据一个消息队列分别对于多个消息消费者组的多个消费组队列深度确定该消息队列的队列级深度,包括:
    将一个消息队列对应的多个消费组队列深度中满足预定选择规则的消费组队列深度确定为该消息队列的队列级深度;或者,
    采用预定计算方式对一个消息队列对应的多个消费组队列深度进行计算处理,并将计算结果确定为该消息队列的队列级深度。
  6. 如权利要求1所述的方法,其特征在于,根据各个消息队列的消息消费状态信息, 从所述消息队列组中确定满足预设隔离条件的目标消息队列,包括:
    确定各个消息队列在第二预定时长内的多个相邻周期的多个消息消费速率;
    若一个消息队列的多个消息消费速率均小于预定消息消费速率,则确定该消息队列为满足所述预设隔离条件的目标消息队列;或者,
    若一个消息队列的多个消息消费速率呈逐渐减小的变化趋势,则确定该消息队列为满足所述预设隔离条件的目标消息队列。
  7. 如权利要求1-6任一所述的方法,其特征在于,所述熔断隔离信息还用于指示对于所述目标消息队列进行熔断隔离的隔离时长。
  8. 如权利要求1-6任一所述的方法,其特征在于,在将所述熔断隔离信息发送给消息生产者之后,所述方法还包括:
    在所述目标消息队列不再满足所述预设隔离条件时,向所述消息生产者集群发送熔断撤销信息,其中,所述熔断撤销信息用于指示结束对所述目标消息队列的熔断隔离。
  9. 一种消息中间件,其特征在于,包括:
    获得模块,用于获得消息队列组中的各个消息队列的消息消费状态信息;
    第一确定模块,用于根据各个消息队列的消息消费状态信息,从所述消息队列组中确定满足预设隔离条件的目标消息队列;
    第二确定模块,用于确定针对所述目标消息队列的熔断隔离信息,其中,所述熔断隔离信息用于指示对所述目标消息队列进行熔断隔离;
    发送模块,用于将所述熔断隔离信息发送给消息生产者,以熔断所述目标消息队列对所述消息生产者的消息服务。
  10. 一种服务熔断装置,其特征在于,包括至少一个处理器、以及至少一个存储器,其中,所述存储器存储有计算机程序,当所述程序被所述处理器执行时,使得所述处理器执行权利要求1-8任一项所述方法的步骤。
  11. 一种存储介质,其特征在于,所述存储介质存储有计算机指令,当所述计算机指令在计算机上运行时,使得计算机执行如权利要求1-8任一项所述方法的步骤。
PCT/CN2020/094418 2019-07-04 2020-06-04 一种服务熔断方法、装置及消息中间件 WO2021000693A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910599006.8A CN110377434A (zh) 2019-07-04 2019-07-04 一种服务熔断方法、装置及消息中间件
CN201910599006.8 2019-07-04

Publications (1)

Publication Number Publication Date
WO2021000693A1 true WO2021000693A1 (zh) 2021-01-07

Family

ID=68251973

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/094418 WO2021000693A1 (zh) 2019-07-04 2020-06-04 一种服务熔断方法、装置及消息中间件

Country Status (2)

Country Link
CN (1) CN110377434A (zh)
WO (1) WO2021000693A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11636000B2 (en) * 2019-10-21 2023-04-25 EMC IP Holding Company LLC Method, device, and computer program product for managing processes based on reading speed of a message queue

Families Citing this family (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110377434A (zh) * 2019-07-04 2019-10-25 深圳前海微众银行股份有限公司 一种服务熔断方法、装置及消息中间件
CN111083199A (zh) * 2019-11-23 2020-04-28 上海畅星软件有限公司 基于高并发、高可用性、服务可扩展的平台处理架构
CN112988434B (zh) * 2019-12-13 2024-05-03 中国银联股份有限公司 一种服务熔断器、服务熔断方法以及计算机可读存储介质
CN111290696A (zh) * 2020-02-26 2020-06-16 平安银行股份有限公司 一种应用程序组件的流控方法及装置
CN111459819B (zh) * 2020-03-31 2023-08-29 北京百度网讯科技有限公司 软件测试方法及装置、电子设备、计算机可读介质
CN111522672B (zh) * 2020-04-24 2023-02-28 北京思特奇信息技术股份有限公司 一种用于熔断数据重复消费的方法及系统
CN111552587A (zh) * 2020-04-30 2020-08-18 武汉众邦银行股份有限公司 一种基于滑动时间窗的服务熔断方法
CN113965624A (zh) * 2020-06-29 2022-01-21 中国电信股份有限公司 用于消息处理的方法、消息缓存中间件和业务系统
CN113676398B (zh) * 2021-08-26 2023-11-03 深信服科技股份有限公司 一种数据恢复方法、装置、设备及可读存储介质
CN113849325A (zh) * 2021-09-29 2021-12-28 四川新网银行股份有限公司 基于分布式消费信贷RabbitMQ熔断方法及系统

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170139767A1 (en) * 2015-11-18 2017-05-18 International Business Machines Corporation Dynamically detecting and interrupting excessive execution time
CN108664337A (zh) * 2018-03-23 2018-10-16 北京奇艺世纪科技有限公司 一种分布式系统的消息减压方法和装置
CN109240765A (zh) * 2018-08-28 2019-01-18 中国联合网络通信集团有限公司 服务资源的熔断方法、装置、设备及计算机可读存储介质
CN109347757A (zh) * 2018-11-09 2019-02-15 锐捷网络股份有限公司 消息拥塞控制方法、系统、设备及存储介质
CN109710421A (zh) * 2018-11-16 2019-05-03 深圳证券交易所 消息中间件的接收者异常处理方法、服务器及存储介质
CN110377434A (zh) * 2019-07-04 2019-10-25 深圳前海微众银行股份有限公司 一种服务熔断方法、装置及消息中间件

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170139767A1 (en) * 2015-11-18 2017-05-18 International Business Machines Corporation Dynamically detecting and interrupting excessive execution time
CN108664337A (zh) * 2018-03-23 2018-10-16 北京奇艺世纪科技有限公司 一种分布式系统的消息减压方法和装置
CN109240765A (zh) * 2018-08-28 2019-01-18 中国联合网络通信集团有限公司 服务资源的熔断方法、装置、设备及计算机可读存储介质
CN109347757A (zh) * 2018-11-09 2019-02-15 锐捷网络股份有限公司 消息拥塞控制方法、系统、设备及存储介质
CN109710421A (zh) * 2018-11-16 2019-05-03 深圳证券交易所 消息中间件的接收者异常处理方法、服务器及存储介质
CN110377434A (zh) * 2019-07-04 2019-10-25 深圳前海微众银行股份有限公司 一种服务熔断方法、装置及消息中间件

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11636000B2 (en) * 2019-10-21 2023-04-25 EMC IP Holding Company LLC Method, device, and computer program product for managing processes based on reading speed of a message queue

Also Published As

Publication number Publication date
CN110377434A (zh) 2019-10-25

Similar Documents

Publication Publication Date Title
WO2021000693A1 (zh) 一种服务熔断方法、装置及消息中间件
US11347549B2 (en) Customer resource monitoring for versatile scaling service scaling policy recommendations
TWI761349B (zh) 風險識別方法、客戶端設備及風險識別系統
US20180234379A1 (en) Intelligent message queue management
CN104063293A (zh) 一种数据备份方法及流计算系统
CN109240836B (zh) 一种用于配置消息队列的消息的方法和装置
CN112579304A (zh) 基于分布式平台的资源调度方法、装置、设备及介质
US11921745B2 (en) Preventing data loss in event driven continuous availability systems
WO2021174382A1 (zh) 一种消息拉取方法、装置以及计算机存储介质
CN114153635A (zh) 消息处理方法、装置、存储介质及计算机设备
CN111913807A (zh) 一种基于多个存储区域的事件处理方法、系统及装置
JP2009025971A (ja) 情報処理装置、ログデータ収集システム
JP2007265244A (ja) ウェブシステムの性能監視装置
US11003600B2 (en) Method and system for scheduling I/O operations for processing
WO2023223599A1 (ja) 計算機システム及びメトリクスの算出方法
KR102613655B1 (ko) 이상징후 선별대응에 기반한 클라우드서버 관리 방법 및 이를 구현하는 클라우드서버 관리 시스템
CN114844810B (zh) 心跳数据处理方法、装置、设备及介质
CN110377578B (zh) 一种基于改进的Flume的数据处理方法和装置
US20230126193A1 (en) Predictive Remediation Action System
CN116881296A (zh) 缓存数据的监控管理方法、装置、设备及存储介质
CN117651026A (zh) 外部系统的业务资源数据获取方法、装置和计算机设备
JP2022075548A (ja) トランザクション処理方法、システム、プログラム
CN116545949A (zh) 数据处理方法、装置、计算机设备和存储介质
CN116501488A (zh) 交易处理方法、装置、设备及存储介质
CN117880053A (zh) 提供报警的方法、装置、设备、存储介质及程序产品

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20834578

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 160522)

122 Ep: pct application non-entry in european phase

Ref document number: 20834578

Country of ref document: EP

Kind code of ref document: A1