WO2020259354A1 - 队列调整方法、装置、设备及计算机可读存储介质 - Google Patents

队列调整方法、装置、设备及计算机可读存储介质 Download PDF

Info

Publication number
WO2020259354A1
WO2020259354A1 PCT/CN2020/096385 CN2020096385W WO2020259354A1 WO 2020259354 A1 WO2020259354 A1 WO 2020259354A1 CN 2020096385 W CN2020096385 W CN 2020096385W WO 2020259354 A1 WO2020259354 A1 WO 2020259354A1
Authority
WO
WIPO (PCT)
Prior art keywords
queue
topic
consumers
writable
queues
Prior art date
Application number
PCT/CN2020/096385
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 WO2020259354A1 publication Critical patent/WO2020259354A1/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
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/50Queue scheduling
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/2866Architectures; Arrangements
    • H04L67/2871Implementation details of single intermediate entities
    • 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

  • This application relates to the field of financial technology (Fintech) technology, and in particular to a queue adjustment method, device, equipment, and computer-readable storage medium.
  • Financial technology Fetech
  • message middleware is commonly used to achieve decoupling between different systems to improve the overall service flexibility.
  • the specific method is that the producer (message producer) produces messages and sends them to the Topic, Consumer of the message middleware. (Message Consumer) Subscribe to Topic and consume the messages in Topic.
  • the producer messages producer
  • Message Consumer Subscribes Topic and consume the messages in Topic.
  • each queue is an independent logical partition, and for a consumer group, each The queue can only be used by one consumer in the consumer group at the same time.
  • the number of configured queues is less than the number of consumers, there will be consumers that cannot be allocated to the queue.
  • the main purpose of this application is to propose a queue adjustment method, device, device, and computer-readable storage medium, aiming to realize adaptive adjustment of the number of topic queues according to changes in the number of consumers subscribing to the topic.
  • this application provides a method, which includes the following steps:
  • the acquired Topic subscription information determine whether the message consumer currently has a newly subscribed Topic or an unsubscribed Topic;
  • the queue reduction operation is performed on the unsubscribed topic.
  • the step of judging whether the message consumer currently has a newly subscribed topic or an unsubscribed topic according to the acquired topic subscription information includes:
  • the step of performing a queue expansion operation on the newly subscribed Topic includes:
  • the number of the second consumers is greater than the number of the first writable queue and less than or equal to the number of the second readable queue, the number of the first writable queue is modified to the number of the first writable queue 2. The number of consumers.
  • the step of performing a queue reduction operation on the topic that is unsubscribed includes:
  • the number of the second writable queue is greater than the number of the third consumer, determine the writable queue to be reduced, and modify the number of the second writable queue according to the writable queue to be reduced Is the number of said third consumers;
  • the number of third readable queues of the topic that is currently unsubscribed and the number of fourth consumers in the message consumer group are obtained, and the third readable queue Compare the number with the number of the fourth consumers;
  • the number of the third readable queue is modified to the number of the fourth consumer.
  • the queue adjustment method further includes:
  • the present application also provides a queue adjustment device, the queue adjustment device including:
  • the first obtaining module is configured to obtain topic subscription information carried in the heartbeat signal when the heartbeat signal of the message consumer is detected;
  • the judging module is used to judge whether the message consumer currently has a newly subscribed topic or an unsubscribed topic according to the acquired topic subscription information;
  • An expansion module configured to perform a queue expansion operation on the newly subscribed topic if the message consumer has a newly subscribed topic
  • the first reduction module is configured to perform a queue reduction operation on the unsubscribed topic if the message consumer has an unsubscribed topic.
  • the present application also provides a queue adjustment device, the queue adjustment device includes: a memory, a processor, and a queue adjustment program stored on the memory and running on the processor, so When the queue adjustment program is executed by the processor, the steps of the queue adjustment method described above are implemented.
  • the present application also provides a computer-readable storage medium having a queue adjustment program stored on the computer-readable storage medium, and when the queue adjustment program is executed by a processor, the above-mentioned queue adjustment is realized. Method steps.
  • the topic topic subscription information carried in the heartbeat signal is acquired; according to the acquired topic subscription information, it is determined whether the message consumer currently has a newly subscribed topic or Unsubscribe Topic; if the message consumer has a newly subscribed Topic, perform the queue expansion operation on the newly subscribed Topic; if the message consumer has an unsubscribed Topic, then perform the unsubscribed Topic Perform queue reduction operations.
  • the topic queue can be expanded adaptively.
  • the topic queue can be reduced adaptively, so this application realizes the adaptive adjustment of the number of topic queues according to the change in the number of message consumers subscribing to the topic.
  • FIG. 1 is a schematic diagram of a device structure of a hardware operating environment involved in a solution of an embodiment of the present application
  • FIG. 2 is a schematic flowchart of the first embodiment of the queue adjustment method of this application.
  • FIG. 1 is a schematic diagram of the device structure of the hardware operating environment involved in the solution of the embodiment of the present application.
  • the queue adjustment device in the embodiment of the present application may be a PC, a server, or other devices.
  • the queue adjustment device may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002.
  • the communication bus 1002 is used to implement connection and communication between these components.
  • the user interface 1003 may include a display screen (Display) and an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface.
  • the network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface).
  • the memory 1005 may be a high-speed RAM memory, or a non-volatile memory (non-volatile memory), such as a magnetic disk memory.
  • the memory 1005 may also be a storage device independent of the foregoing processor 1001.
  • FIG. 1 does not constitute a limitation on the device, and may include more or fewer components than those shown in the figure, or a combination of certain components, or different component arrangements.
  • the memory 1005 which is a computer-readable storage medium, may include an operating system, a network communication module, a user interface module, and a queue adjustment program.
  • the network interface 1004 is mainly used to connect to a back-end server and communicate with the back-end server;
  • the user interface 1003 is mainly used to connect to a client (user side) and communicate with the client;
  • the processor 1001 can be used to call a queue adjustment program stored in the memory 1005, and perform operations in the following embodiment of the queue adjustment method.
  • FIG. 2 is a schematic flowchart of a first embodiment of a queue adjustment method according to this application. The method includes:
  • Step S10 when the heartbeat signal of the message consumer is detected, the topic subscription information carried in the heartbeat signal is acquired;
  • RocketMQ Message Queue, message queue
  • RocketMQ is a pure java, distributed, and queue model open source message middleware. It plays an important role in various financial transactions, such as transferring out service scenarios in current accounts. For security reasons, a SMS notification is sent for each user's current account transfer.
  • the account transfer system does not need to pay attention to the dependence of other systems on it, but only needs to generate account transfer events.
  • the message is sent to RocketMQ, and other services (such as anti-fraud services) need to go to RocketMQ to subscribe to this message, thereby achieving decoupling between different systems.
  • the queue adjustment method of this embodiment is applied to a queue adjustment device, which is a part of a distributed system on which a message middleware is deployed.
  • the message middleware may be currently common message middleware, such as RabbitMQ, Kafka, ActiveMQ , RocketMQ, etc., may also be other message middleware, which is not limited in this embodiment.
  • the message delivery mode is: Producer (the message producer, that is, the client that generates the message of a specific topic) produces a message and sends it to the Topic (topic) of the message middleware, and Consumer (the message consumer, that is, Clients that consume messages on a specific topic or topics) subscribe to Topic and consume the messages in Topic.
  • Topic is the category name of the same type of message, and a topic stores the same type of messages.
  • the queue adjustment method of this embodiment can be implemented by Broker.
  • Broker is the core component of message middleware responsible for message storage and forwarding.
  • the Broker can detect in real time whether the heartbeat of the message consumer is received, and when the heartbeat signal of the message consumer is detected, it obtains the Topic subscription information carried in the heartbeat signal.
  • the Topic subscription information includes the message consumer's Topic for which subscription is requested.
  • Step S20 According to the acquired Topic subscription information, determine whether the message consumer currently has a newly subscribed Topic or an unsubscribed Topic;
  • the Broker determines whether the message consumer has a newly subscribed topic or an unsubscribed topic based on the topic subscription information obtained above.
  • this step S20 may include: determining whether the message consumer's Topic subscription information is pre-registered on the message middleware; if so, combining the obtained Topic subscription information with the pre-registered Topic The subscription information is compared to determine whether the message consumer currently has a newly subscribed topic or an unsubscribed topic.
  • the Broker first judges whether the message consumer's Topic subscription information is pre-registered on the message middleware. If the message consumer's Topic subscription information is pre-registered on the message middleware, it will compare the currently acquired Topic subscription information with The pre-registered Topic subscription information is compared to determine whether the message consumer currently has a newly subscribed Topic or an unsubscribed Topic. For example, if the pre-registered Topic subscription information includes Topic1 and Topic2, the currently acquired Topic subscription information If Topic1, Topic2, and Topic3 are included, it can be determined that Topic3 is currently a newly subscribed Topic.
  • step S30 is executed to perform a queue expansion operation on the newly subscribed topic
  • Queue is a logical division of Topic, and each queue is an independent logical partition.
  • each queue can only be used by one message consumer in the consumer group at the same time.
  • the message producer sends messages to the Topic queue in a polling manner, it can be considered that the amount of messages in each queue is equal.
  • the queue expansion operation needs to be performed on the newly subscribed topic, where the expansion refers to Is the number of extended queues.
  • the preferred method of expansion is: extended queues so that the number of newly subscribed topic queues is equal to the number of message consumers currently subscribed to the topic. In this way, each message consumer can be assigned to The queues are equal, thereby balancing the traffic load of each message consumer and improving the read and write performance of messages.
  • step S40 is executed to perform a queue reduction operation on the unsubscribed topic.
  • the preferred method of reduction is to reduce the queues so that the number of queues for unsubscribed topics is equal to the number of message consumers currently subscribed to the topic. In this way, each message consumer can be allocated to The queues are equal, thereby balancing the traffic load of each message consumer and improving the read and write performance of messages.
  • the topic queue can be expanded adaptively.
  • the topic queue can be reduced adaptively, so this embodiment realizes the adaptive adjustment of the number of topic queues according to the change in the number of message consumers subscribing to the topic.
  • the step of performing a queue expansion operation on the newly subscribed Topic may specifically include: obtaining the current number of the first readable queues of the newly subscribed Topic and the consumer to which the message consumer belongs For the number of first consumers in the group, compare the number of first readable queues with the number of first consumers; when the number of first consumers is greater than the number of first readable queues When counting, modify the number of first readable queues to the number of first consumers; after asynchronously waiting for the first preset period of time, obtain the number of first writable queues of the newly subscribed topic, The number of second readable queues, and the number of second consumers in the message consumer group, the number of first writable queues and the number of second readable queues are respectively compared with the number of second consumers When the number of the second consumer is greater than the number of the first writable queue and less than or equal to the number of the second readable queue, the number of the first writable queue is Modified to the number of second consumers.
  • the number of readable queues refers to the queues that can be read by message consumers
  • the writable queue refers to the queues that can be written to messages by the message producer, in order to prevent the message producer from writing in a certain queue If the queue is not monitored by any message consumer, for a topic, it should satisfy "the number of readable queues is greater than or equal to the number of writable queues" at any time.
  • the Topic queue needs to be expanded.
  • the expansion is specifically divided into the following steps:
  • the first preset duration can be flexibly set, such as 10s; the purpose of asynchronously waiting for the first preset duration is to ensure that the message consumer listens to the readable queue expanded in step b and then expands the writable queue correspondingly, thereby preventing expansion The writable queue is closed but no message consumer is listening.
  • the above method first expands the readable queue, and ensures that the message consumer monitors the expanded readable queue, and then expands the writable queue correspondingly, so that when the number of message consumers increases, the topic readable queue can be adaptively expanded.
  • the number and the number of writable queues meet the requirement that the number of readable queues after expansion is equal to the number of message consumers and greater than or equal to the number of writable queues.
  • the step of performing a queue reduction operation on the unsubscribed topic may specifically include: obtaining the number of the second writable queue of the current unsubscribed topic, and the first number in the message consumer group Three number of consumers, compare the number of the second writable queue with the number of the third consumer; when the number of the second writable queue is greater than the number of the third consumer, determine The writable queue to be reduced, and the number of the second writable queue is modified to the number of the third consumer according to the writable queue to be reduced; after asynchronously waiting for the second preset time, the current all The number of third readable queues of the topic that is unsubscribed, and the number of fourth consumers in the message consumer group, the number of third readable queues and the number of fourth consumers Comparison; when the number of the third readable queue is greater than the number of the fourth consumer, determine whether the messages on the writable queue to be reduced are consumed; if the writable queue to be
  • the Topic queue needs to be reduced.
  • the reduction is specifically divided into the following steps:
  • the method of determining the writable queue to be reduced may be randomly selected from the existing writable queues, or may be selected according to a predetermined rule, which is not limited in this embodiment.
  • the second preset duration can be flexibly set.
  • the second preset duration can be set to be longer, such as 5 minutes. In this way, within 5 minutes, if the message consumer goes online (restarted) again, the actual There is no change in the number of message consumers before and after, and there is no need to perform queue reduction operations on Topic at this time; the purpose of asynchronously waiting for the second preset duration is to ensure that the message producer knows the writable queue reduced in step b'before corresponding reduction The readable queue prevents the message producer from writing to the reduced writable queue.
  • Nr Nc2
  • Nw is modified to Nc2.
  • the above method first reduces the writable queue and ensures that the message producer knows the reduced writable queue, and then correspondingly reduces the readable queue, so that when the number of message consumers is reduced, the topic's readable queue is adaptively reduced.
  • the number and the number of writable queues meet the requirement that the number of readable queues after reduction is equal to the number of message consumers and greater than or equal to the number of writable queues.
  • the queue adjustment method may further include: when the abnormal shutdown of the message consumer is detected, obtaining the current Topic subscription list of the message consumer; and executing the queue on the Topic in the Topic subscription list Reduce operations.
  • the application also provides a queue adjustment device.
  • the queue adjustment device includes:
  • the first obtaining module is configured to obtain topic subscription information carried in the heartbeat signal when the heartbeat signal of the message consumer is detected;
  • the judging module is used to judge whether the message consumer currently has a newly subscribed topic or an unsubscribed topic according to the acquired topic subscription information;
  • An expansion module configured to perform a queue expansion operation on the newly subscribed topic if the message consumer has a newly subscribed topic
  • the first reduction module is configured to perform a queue reduction operation on the unsubscribed topic if the message consumer has an unsubscribed topic.
  • judgment module is also used for:
  • expansion module is also used for:
  • the number of the second consumers is greater than the number of the first writable queue and less than or equal to the number of the second readable queue, the number of the first writable queue is modified to the number of the first writable queue 2. The number of consumers.
  • the first reduction module is also used for:
  • the number of the second writable queue is greater than the number of the third consumer, determine the writable queue to be reduced, and modify the number of the second writable queue according to the writable queue to be reduced Is the number of said third consumers;
  • the number of third readable queues of the topic that is currently unsubscribed and the number of fourth consumers in the message consumer group are obtained, and the third readable queue Compare the number with the number of the fourth consumers;
  • the number of the third readable queue is modified to the number of the fourth consumer.
  • the queue adjustment device further includes:
  • the second acquiring module is configured to acquire the current Topic subscription list of the message consumer when it is detected that the message consumer is abnormally shut down;
  • the second reduction module is further configured to perform a queue reduction operation on topics in the topic subscription list.
  • the application also provides a computer-readable storage medium.
  • the computer-readable storage medium of the present application stores a queue adjustment program, and when the queue adjustment program is executed by a processor, the steps of the queue adjustment method described above are implemented.
  • the method of the above embodiments can be implemented by means of software plus the necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases the former is better. ⁇
  • the technical solution of this application 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 is stored in a computer-readable storage medium as described above (such as The ROM/RAM, magnetic disk, optical disk) includes several instructions to make a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) execute the methods described in the various embodiments of the present application.
  • a terminal device which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

本申请涉及金融科技领域,并公开了一种队列调整方法,该方法包括:当检测到消息消费者的心跳信号时,获取所述心跳信号中携带的主题Topic订阅信息;根据获取到的所述Topic订阅信息,判断所述消息消费者当前是否有新订阅的Topic或取消订阅的Topic;若所述消息消费者有新订阅的Topic,则对所述新订阅的Topic执行队列扩展操作;若所述消息消费者有取消订阅的Topic,则对所述取消订阅的Topic执行队列缩减操作。本申请还公开了一种队列调整装置、设备和一种计算机可读存储介质。本申请实现了根据订阅Topic的消息消费者数量的变动自适应调整Topic的队列数量。

Description

队列调整方法、装置、设备及计算机可读存储介质
本申请要求于2019年6月26日提交中国专利局、申请号为201910571094.0、发明名称为“队列调整方法、装置、设备及计算机可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在申请中。
技术领域
本申请涉及金融科技(Fintech)技术领域,尤其涉及队列调整方法、装置、设备及计算机可读存储介质。
背景技术
随着计算机技术的发展,越来越多的技术(大数据、分布式、区块链Blockchain、人工智能等)应用在金融领域,传统金融业正在逐步向金融科技(Fintech)转变,但由于金融行业的安全性、实时性要求,也对技术提出了更高的要求。
在目前的金融领域,普遍采用消息中间件实现不同系统之间的解耦,以提高整体服务弹性,具体方式是producer(消息生产者)生产消息并发送到消息中间件的Topic(主题),Consumer(消息消费者)订阅Topic,并消费Topic中的消息。为了提升消息的读写性能,当某个Topic的消息量较大时,可以在该Topic下设置多个Queue(队列),每个队列为一个独立的逻辑分区,且对于一个消费组,每个队列同时只能被消费组中一个消费者使用,当配置的队列个数比消费者个数少的时候,会有消费者分不到队列,当配置的队列个数比消费者个数多的时候,在每个队列的流量均等的情况下,分到队列多的消费者的负载会比其他消费者高,因此,当Topic队列个数和消费者个数不一致时,需要将Topic队列个数调整为和消费者个数相等,以实现负载均衡。
然而,目前的Topic队列数量调整只能通过人工介入调整,即通过消息中间件提供的接口修改Topic队列配置,这种方式操作较为繁琐,无法实现对Topic队列个数的自适应调整。
发明概述
技术问题
问题的解决方案
技术解决方案
本申请的主要目的在于提出一种队列调整方法、装置、设备及计算机可读存储介质,旨在实现根据订阅Topic的消费者数量的变动自适应调整Topic的队列数量。
为实现上述目的,本申请提供一种方法,所述方法包括如下步骤:
当检测到消息消费者的心跳信号时,获取所述心跳信号中携带的主题Topic订阅信息;
根据获取到的所述Topic订阅信息,判断所述消息消费者当前是否有新订阅的Topic或取消订阅的Topic;
若所述消息消费者有新订阅的Topic,则对所述新订阅的Topic执行队列扩展操作;
若所述消息消费者有取消订阅的Topic,则对所述取消订阅的Topic执行队列缩减操作。
优选地,所述根据获取到的所述Topic订阅信息,判断所述消息消费者当前是否有新订阅的Topic或取消订阅的Topic的步骤包括:
判断消息中间件上是否预先注册有所述消息消费者的Topic订阅信息;
若是,则将获取到的所述Topic订阅信息与预先注册的所述Topic订阅信息进行比对,以判断所述消息消费者当前是否有新订阅的Topic或取消订阅的Topic。
优选地,所述对所述新订阅的Topic执行队列扩展操作的步骤包括:
获取当前所述新订阅的Topic的第一可读队列个数,以及所述消息消费者所属的消费者分组中的第一消费者个数,将所述第一可读队列个数与所述第一消费者个数进行比较;
当所述第一消费者个数大于所述第一可读队列个数时,将所述第一可读队列个数修改为所述第一消费者个数;
异步等待第一预设时长后,获取当前所述新订阅的Topic的第一可写队列个数、第二可读队列个数,以及所述消息消费者分组中的第二消费者个数,将所述第一可写队列个数、第二可读队列个数分别与所述第二消费者个数进行比较;
当所述第二消费者个数大于所述第一可写队列个数,且小于或等于所述第二可读队列个数时,将所述第一可写队列个数修改为所述第二消费者个数。
优选地,所述对所述取消订阅的Topic执行队列缩减操作的步骤包括:
获取当前所述取消订阅的Topic的第二可写队列个数,以及所述消息消费者分组中的第三消费者个数,将所述第二可写队列个数与所述第三消费者个数进行比较;
当所述第二可写队列个数大于所述第三消费者个数时,确定待缩减的可写队列,并根据所述待缩减的可写队列将所述第二可写队列个数修改为所述第三消费者个数;
异步等待第二预设时长后,获取当前所述取消订阅的Topic的第三可读队列个数,以及所述消息消费者分组中的第四消费者个数,将所述第三可读队列个数与所述第四消费者个数进行比较;
当所述第三可读队列个数大于所述第四消费者个数时,判断所述待缩减的可写队列上的消息是否被消费完;
若所述待缩减的可写队列上的消息被消费完,则将所述第三可读队列个数修改为所述第四消费者个数。
优选地,所述队列调整方法还包括:
当检测到所述消息消费者异常停机时,获取所述消息消费者当前的Topic订阅列表;
对所述Topic订阅列表中的Topic执行队列缩减操作。
此外,为实现上述目的,本申请还提供一种队列调整装置,所述队列调整装置包括:
第一获取模块,用于当检测到消息消费者的心跳信号时,获取所述心跳信号中携带的主题Topic订阅信息;
判断模块,用于根据获取到的所述Topic订阅信息,判断所述消息消费者当前是否有新订阅的Topic或取消订阅的Topic;
扩展模块,用于若所述消息消费者有新订阅的Topic,则对所述新订阅的Topic执行队列扩展操作;
第一缩减模块,用于若所述消息消费者有取消订阅的Topic,则对所述取消订阅的Topic执行队列缩减操作。
此外,为实现上述目的,本申请还提供一种队列调整设备,所述队列调整设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的队列调整程序,所述队列调整程序被所述处理器执行时实现如上所述的队列调整方法的步骤。
此外,为实现上述目的,本申请还提供一种计算机可读存储介质,所述计算机可读存储介质上存储有队列调整程序,所述队列调整程序被处理器执行时实现如上所述的队列调整方法的步骤。
本申请当检测到消息消费者的心跳信号时,获取所述心跳信号中携带的主题Topic订阅信息;根据获取到的所述Topic订阅信息,判断所述消息消费者当前是否有新订阅的Topic或取消订阅的Topic;若所述消息消费者有新订阅的Topic,则对所述新订阅的Topic执行队列扩展操作;若所述消息消费者有取消订阅的Topic,则对所述取消订阅的Topic执行队列缩减操作。通过这种方式,当消息消费者有新订阅的Topic,即订阅Topic的消息消费者数量增加时,能够自适应进行Topic队列扩展,当消息消费者有取消订阅的Topic,即订阅Topic的消息消费者数量减少时,能够自适应进行Topic队列缩减,从而本申请实现了根据订阅Topic的消息消费者数量的变动自适应调整Topic的队列数量。
发明的有益效果
对附图的简要说明
附图说明
图1是本申请实施例方案涉及的硬件运行环境的设备结构示意图;
图2为本申请队列调整方法第一实施例的流程示意图。
本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。
发明实施例
本发明的实施方式
应当理解,此处所描述的具体实施例仅仅用以解释本申请,并不用于限定本申 请。
如图1所示,图1是本申请实施例方案涉及的硬件运行环境的设备结构示意图。
本申请实施例队列调整设备可以是PC机、服务器等设备。
如图1所示,该队列调整设备可以包括:处理器1001,例如CPU,网络接口1004,用户接口1003,存储器1005,通信总线1002。其中,通信总线1002用于实现这些组件之间的连接通信。用户接口1003可以包括显示屏(Display)、输入单元比如键盘(Keyboard),可选用户接口1003还可以包括标准的有线接口、无线接口。网络接口1004可选的可以包括标准的有线接口、无线接口(如WI-FI接口)。存储器1005可以是高速RAM存储器,也可以是稳定的存储器(non-volatile memory),例如磁盘存储器。存储器1005可选的还可以是独立于前述处理器1001的存储装置。
本领域技术人员可以理解,图1中示出的设备结构并不构成对设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
如图1所示,作为一种计算机可读存储介质的存储器1005中可以包括操作系统、网络通信模块、用户接口模块以及队列调整程序。
在图1所示的设备中,网络接口1004主要用于连接后台服务器,与后台服务器进行数据通信;用户接口1003主要用于连接客户端(用户端),与客户端进行数据通信;而处理器1001可以用于调用存储器1005中存储的队列调整程序,并执行下述队列调整方法实施例中的操作。
基于上述硬件结构,提出本申请队列调整方法实施例。
参照图2,图2为本申请队列调整方法第一实施例的流程示意图,所述方法包括:
步骤S10,当检测到消息消费者的心跳信号时,获取所述心跳信号中携带的主题Topic订阅信息;
在目前的金融领域,普遍采用消息中间件实现不同系统之间的解耦,以提高整体服务弹性。以RocketMQ(Message Queue,消息队列)为例,RocketMQ是一款纯java、分布式、队列模型的开源消息中间件,在各类金融交易中承担着重要的角色,比如在活期账户转出服务场景中,出于安全考虑,每笔用户活期账户 转出都要发送一条短信通知,在部署了RocketMQ的情况下,账户转出系统不用关注其他系统对它的依赖,而只需要产生账户转出事件的消息并发送到RocketMQ,其他有需要的服务(比如反欺诈服务)各自去RocketMQ订阅这个消息就行了,由此实现了不同系统之间的解耦。
本实施例队列调整方法应用于队列调整设备,该队列调整设备作为分布式系统的一部分,其上部署有消息中间件,该消息中间件可以是当前常见的消息中间件,比如RabbitMQ、Kafka、ActiveMQ、RocketMQ等,也可以是其他消息中间件,本实施例对此不作限定。在分布式系统中,消息传递模式为:producer(消息生产者,也即产生具体主题的消息的客户端)生产消息并发送到消息中间件的Topic(主题),Consumer(消息消费者,也即消费某个或若干个具体主题的消息的客户端)订阅Topic,并消费Topic中的消息。其中Topic为同一类消息的分类名称,一个Topic存储了一类相同的消息。
具体地,本实施例队列调整方法可以通过Broker实现,Broker是消息中间件负责消息存储和转发的核心组件,当消息消费者正常上线时,会向Broker发送心跳信号注册它所订阅的Topic,当消息消费者正常下线时,会向Broker发送心跳信号去掉在Broker上注册的Topic订阅信息。
在本实施例中,Broker可以实时检测是否接收到消息消费者的心跳,当检测到消息消费者的心跳信号时,获取该心跳信号中携带的Topic订阅信息,该Topic订阅信息包括消息消费者所请求订阅的Topic。
步骤S20,根据获取到的所述Topic订阅信息,判断所述消息消费者当前是否有新订阅的Topic或取消订阅的Topic;
该步骤中,Broker根据上述获取到的Topic订阅信息,判断该消息消费者是否有新订阅的Topic或取消订阅的Topic。
在一实施方式中,该步骤S20可以包括:判断消息中间件上是否预先注册有所述消息消费者的Topic订阅信息;若是,则将获取到的所述Topic订阅信息与预先注册的所述Topic订阅信息进行比对,以判断所述消息消费者当前是否有新订阅的Topic或取消订阅的Topic。
具体地,Broker首先判断消息中间件上是否预先注册有该消息消费者的Topic订 阅信息,若消息中间件上预先注册有该消息消费者的Topic订阅信息,则将当前获取到的Topic订阅信息与预先注册的Topic订阅信息进行比对,以判断该消息消费者当前是否有新订阅的Topic或取消订阅的Topic,比如,若预先注册的Topic订阅信息包括Topic1、Topic2,当前获取到的Topic订阅信息包括Topic1、Topic2、Topic3,则可以判定Topic3为当前新订阅的Topic。
若所述消息消费者有新订阅的Topic,则执行步骤S30,对所述新订阅的Topic执行队列扩展操作;
该步骤中,队列(Queue)是对Topic的逻辑划分,每个队列为一个独立的逻辑分区。根据现有的负载均衡原则,对于一个消费组(Consumer Group),每个队列同时只能被该消费组中的一个消息消费者使用。
由于现有技术中,消息生产者向Topic队列发送消息是轮询的方式,因此可以认为每个队列的消息量是均等的。本实施例中,当判断上述消息消费者当前有新订阅的Topic时,说明新订阅的Topic对应的消息消费者数量增加,此时需要对新订阅的Topic执行队列扩展操作,其中,扩展指的是扩展队列的个数,扩展方式优选为:扩展队列,以使新订阅的Topic的队列个数和当前订阅了该Topic的消息消费者个数相等,如此,可以使得每个消息消费者分到的队列是均等的,从而均衡每个消息消费者的流量负载,提升消息的读写性能。
若所述消息消费者有取消订阅的Topic,则执行步骤S40,对所述取消订阅的Topic执行队列缩减操作。
该步骤中,当判断上述消息消费者当前有取消订阅的Topic时,说明取消订阅的Topic对应的消息消费者数量减少,此时需要对取消订阅的Topic执行队列缩减操作,其中,缩减指的是缩减队列的个数,缩减方式优选为:缩减队列,以使取消订阅的Topic的队列个数和当前订阅了该Topic的消息消费者个数相等,如此,也可以使得每个消息消费者分到的队列是均等的,从而均衡每个消息消费者的流量负载,提升消息的读写性能。
本实施例通过上述方式,当消息消费者有新订阅的Topic,即订阅Topic的消息消费者数量增加时,能够自适应进行Topic队列扩展,当消息消费者有取消订阅的Topic,即订阅Topic的消息消费者数量减少时,能够自适应进行Topic队列缩 减,从而本实施例实现了根据订阅Topic的消息消费者数量的变动自适应调整Topic的队列数量。
进一步地,基于本申请队列调整方法第一实施例,提出本申请队列调整方法第二实施例。
在本实施例中,对所述新订阅的Topic执行队列扩展操作的步骤具体可以包括:获取当前所述新订阅的Topic的第一可读队列个数,以及所述消息消费者所属的消费者分组中的第一消费者个数,将所述第一可读队列个数与所述第一消费者个数进行比较;当所述第一消费者个数大于所述第一可读队列个数时,将所述第一可读队列个数修改为所述第一消费者个数;异步等待第一预设时长后,获取当前所述新订阅的Topic的第一可写队列个数、第二可读队列个数,以及所述消息消费者分组中的第二消费者个数,将所述第一可写队列个数、第二可读队列个数分别与所述第二消费者个数进行比较;当所述第二消费者个数大于所述第一可写队列个数,且小于或等于所述第二可读队列个数时,将所述第一可写队列个数修改为所述第二消费者个数。
其中,可读队列个数指的是能够被消息消费者读取消息的队列,可写队列指的是能够被消息生产者写入消息的队列,为防止消息生产者在某一队列中写入消息而该队列没有被任何消息消费者监听的情况发生,对于一个Topic,应在任何时候满足“可读队列个数大于或等于可写队列个数”。
在本实施例中,当消息消费者个数增加时,需要扩展Topic队列,扩展具体分为以下步骤:
a、从Broker上获取当前Topic的可读队列个数Nr1,以及消息消费者所属的消息消费者分组中的消费者个数Nc1,并将两者进行比较;
b、若Nc1>Nr1,则将Nr1修改为Nc1;
c、异步等待第一预设时长后,从Broker上获取当前Topic的可写队列个数Nw、可读队列个数Nr2,以及消息消费者分组中的消费者个数Nc2,并将三者进行比较;
其中,第一预设时长可以灵活设置,比如10s;异步等待第一预设时长的目的为:保证消息消费者监听到了步骤b所扩展的可读队列后再对应扩展可写队列, 从而防止扩展了可写队列但没有消息消费者监听的情况发生。
d、当Nc2>Nw且Nc2≤Nr2时,将Nw修改为Nc2。
上述方式通过首先扩展可读队列,并确保消息消费者监听到了所扩展的可读队列后,再对应扩展可写队列,实现了在消息消费者个数增加时,自适应扩展Topic的可读队列个数和可写队列个数,且满足了扩展后的可读队列个数等于消息消费者个数,且大于或等于可写队列个数的要求。
进一步地,基于本申请队列调整方法第二实施例,提出本申请队列调整方法第三实施例。
在本实施例中,对所述取消订阅的Topic执行队列缩减操作的步骤具体可以包括:获取当前所述取消订阅的Topic的第二可写队列个数,以及所述消息消费者分组中的第三消费者个数,将所述第二可写队列个数与所述第三消费者个数进行比较;当所述第二可写队列个数大于所述第三消费者个数时,确定待缩减的可写队列,并根据所述待缩减的可写队列将所述第二可写队列个数修改为所述第三消费者个数;异步等待第二预设时长后,获取当前所述取消订阅的Topic的第三可读队列个数,以及所述消息消费者分组中的第四消费者个数,将所述第三可读队列个数与所述第四消费者个数进行比较;当所述第三可读队列个数大于所述第四消费者个数时,判断所述待缩减的可写队列上的消息是否被消费完;若所述待缩减的可写队列上的消息被消费完,则将所述第三可读队列个数修改为所述第四消费者个数。
在本实施例中,当消息消费者个数减少时,需要缩减Topic队列,缩减具体分为以下步骤:
a’、从Broker上获取当前Topic的可写队列个数Nw,以及消息消费者所属的消息消费者分组中的消费者个数Nc1,并将两者进行比较;
b’、若Nw>Nc1,则确定待缩减的可写队列,并将Nw修改为Nc1;
其中,确定待缩减的可写队列的方式可以为从现有可写队列中随机选择,也可以是按预定规则选择,本实施例对此不作限定。
c’、异步等待第二预设时长后,从Broker上获取当前Topic的可读队列个数Nr,以及消息消费者分组中的消费者个数Nc2,并将两者进行比较;
其中,第二预设时长可以灵活设置,在一实施方式中,该第二预设时长可以设置得较长,比如5分钟,如此在5分钟内,若消息消费者重新上线(重启)则实际消息消费者个数前后并无变化,此时无需对Topic执行队列缩减操作;异步等待第二预设时长的目的为:保证消息生产者获知到了步骤b’所缩减的可写队列后再对应缩减可读队列,从而防止消息生产者仍向缩减了的可写队列写消息的情况发生。
d’、当Nr>Nc2时,判断上述待缩减的可写队列上的消息是否被消费完;
e’、若上述待缩减的可写队列上的消息被消费完,则将Nw修改为Nc2。
需要说明的是,若上述待缩减的可写队列上的消息未被消费完,则可以返回步骤c’,直至判断待缩减的可写队列上的消息被消费完后,再将Nw修改为Nc2。
上述方式通过首先缩减可写队列,并确保消息生产者获知到了所缩减的可写队列后,再对应缩减可读队列,实现了在消息消费者个数减少时,自适应缩减Topic的可读队列个数和可写队列个数,且满足了缩减后的可读队列个数等于消息消费者个数,且大于或等于可写队列个数的要求。
进一步地,基于本申请队列调整方法第一实施例,提出本申请队列调整方法第四实施例。
在本实施例中,所述队列调整方法还可以包括:当检测到所述消息消费者异常停机时,获取所述消息消费者当前的Topic订阅列表;对所述Topic订阅列表中的Topic执行队列缩减操作。
在本实施例中,当消息消费者发生故障,没有正常下线或者假死的时候,可以依靠Broker对消息消费者存活性的检查,发现异常停机的消息消费者和该消息消费者订阅的Topic列表,然后对该Topic订阅列表中的Topic执行队列缩减操作。由此,保证了当消息消费者发生故障时,也能够自适应调整Topic的队列数量。
本申请还提供一种队列调整装置。所述队列调整装置包括:
第一获取模块,用于当检测到消息消费者的心跳信号时,获取所述心跳信号中携带的主题Topic订阅信息;
判断模块,用于根据获取到的所述Topic订阅信息,判断所述消息消费者当前是否有新订阅的Topic或取消订阅的Topic;
扩展模块,用于若所述消息消费者有新订阅的Topic,则对所述新订阅的Topic执行队列扩展操作;
第一缩减模块,用于若所述消息消费者有取消订阅的Topic,则对所述取消订阅的Topic执行队列缩减操作。
进一步地,所述判断模块还用于:
判断消息中间件上是否预先注册有所述消息消费者的Topic订阅信息;
若是,则将获取到的所述Topic订阅信息与预先注册的所述Topic订阅信息进行比对,以判断所述消息消费者当前是否有新订阅的Topic或取消订阅的Topic。
进一步地,所述扩展模块还用于:
获取当前所述新订阅的Topic的第一可读队列个数,以及所述消息消费者所属的消费者分组中的第一消费者个数,将所述第一可读队列个数与所述第一消费者个数进行比较;
当所述第一消费者个数大于所述第一可读队列个数时,将所述第一可读队列个数修改为所述第一消费者个数;
异步等待第一预设时长后,获取当前所述新订阅的Topic的第一可写队列个数、第二可读队列个数,以及所述消息消费者分组中的第二消费者个数,将所述第一可写队列个数、第二可读队列个数分别与所述第二消费者个数进行比较;
当所述第二消费者个数大于所述第一可写队列个数,且小于或等于所述第二可读队列个数时,将所述第一可写队列个数修改为所述第二消费者个数。
进一步地,所述第一缩减模块还用于:
获取当前所述取消订阅的Topic的第二可写队列个数,以及所述消息消费者分组中的第三消费者个数,将所述第二可写队列个数与所述第三消费者个数进行比较;
当所述第二可写队列个数大于所述第三消费者个数时,确定待缩减的可写队列,并根据所述待缩减的可写队列将所述第二可写队列个数修改为所述第三消费者个数;
异步等待第二预设时长后,获取当前所述取消订阅的Topic的第三可读队列个数,以及所述消息消费者分组中的第四消费者个数,将所述第三可读队列个数 与所述第四消费者个数进行比较;
当所述第三可读队列个数大于所述第四消费者个数时,判断所述待缩减的可写队列上的消息是否被消费完;
若所述待缩减的可写队列上的消息被消费完,则将所述第三可读队列个数修改为所述第四消费者个数。
进一步地,所述队列调整装置还包括:
第二获取模块,用于当检测到所述消息消费者异常停机时,获取所述消息消费者当前的Topic订阅列表;
第二缩减模块,还用于对所述Topic订阅列表中的Topic执行队列缩减操作。
上述各程序模块所执行的方法可参照本申请队列调整方法各个实施例,此处不再赘述。
本申请还提供一种计算机可读存储介质。
本申请计算机可读存储介质上存储有队列调整程序,所述队列调整程序被处理器执行时实现如上所述的队列调整方法的步骤。
其中,在所述处理器上运行的队列调整程序被执行时所实现的方法可参照本申请队列调整方法各个实施例,此处不再赘述。
需要说明的是,在本文中,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者系统不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者系统所固有的要素。在没有更多限制的情况下,由语句“包括一个......”限定的要素,并不排除在包括该要素的过程、方法、物品或者系统中还存在另外的相同要素。
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到上述实施例方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在如上所述的一个计算机可读存储介质(如ROM/RAM、磁碟 、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,空调器,或者网络设备等)执行本申请各个实施例所述的方法。
以上仅为本申请的优选实施例,并非因此限制本申请的专利范围,凡是利用本申请说明书及附图内容所作的等效结构或等效流程变换,或直接或间接运用在其他相关的技术领域,均同理包括在本申请的专利保护范围内。

Claims (20)

  1. 一种队列调整方法,其中,所述队列调整方法包括如下步骤:
    当检测到消息消费者的心跳信号时,获取所述心跳信号中携带的主题Topic订阅信息;
    根据获取到的所述Topic订阅信息,判断所述消息消费者当前是否有新订阅的Topic或取消订阅的Topic;
    若所述消息消费者有新订阅的Topic,则对所述新订阅的Topic执行队列扩展操作;
    若所述消息消费者有取消订阅的Topic,则对所述取消订阅的Topic执行队列缩减操作。
  2. 如权利要求1所述的队列调整方法,其中,所述根据获取到的所述Topic订阅信息,判断所述消息消费者当前是否有新订阅的Topic或取消订阅的Topic的步骤包括:
    判断消息中间件上是否预先注册有所述消息消费者的Topic订阅信息;
    若是,则将获取到的所述Topic订阅信息与预先注册的所述Topic订阅信息进行比对,以判断所述消息消费者当前是否有新订阅的Topic或取消订阅的Topic。
  3. 如权利要求1所述的队列调整方法,其中,所述对所述新订阅的Topic执行队列扩展操作的步骤包括:
    获取当前所述新订阅的Topic的第一可读队列个数,以及所述消息消费者所属的消费者分组中的第一消费者个数,将所述第一可读队列个数与所述第一消费者个数进行比较;
    当所述第一消费者个数大于所述第一可读队列个数时,将所述第一可读队列个数修改为所述第一消费者个数;
    异步等待第一预设时长后,获取当前所述新订阅的Topic的第一可写队列个数、第二可读队列个数,以及所述消息消费者分组中的第二消费者个数,将所述第一可写队列个数、第二可读队列个数 分别与所述第二消费者个数进行比较;
    当所述第二消费者个数大于所述第一可写队列个数,且小于或等于所述第二可读队列个数时,将所述第一可写队列个数修改为所述第二消费者个数。
  4. 如权利要求3所述的队列调整方法,其中,所述对所述取消订阅的Topic执行队列缩减操作的步骤包括:
    获取当前所述取消订阅的Topic的第二可写队列个数,以及所述消息消费者分组中的第三消费者个数,将所述第二可写队列个数与所述第三消费者个数进行比较;
    当所述第二可写队列个数大于所述第三消费者个数时,确定待缩减的可写队列,并根据所述待缩减的可写队列将所述第二可写队列个数修改为所述第三消费者个数;
    异步等待第二预设时长后,获取当前所述取消订阅的Topic的第三可读队列个数,以及所述消息消费者分组中的第四消费者个数,将所述第三可读队列个数与所述第四消费者个数进行比较;
    当所述第三可读队列个数大于所述第四消费者个数时,判断所述待缩减的可写队列上的消息是否被消费完;
    若所述待缩减的可写队列上的消息被消费完,则将所述第三可读队列个数修改为所述第四消费者个数。
  5. 如权利要求1所述的队列调整方法,其中,所述队列调整方法还包括:
    当检测到所述消息消费者异常停机时,获取所述消息消费者当前的Topic订阅列表;
    对所述Topic订阅列表中的Topic执行队列缩减操作。
  6. 一种队列调整装置,其中,所述队列调整装置包括:
    第一获取模块,用于当检测到消息消费者的心跳信号时,获取所述心跳信号中携带的主题Topic订阅信息;
    判断模块,用于根据获取到的所述Topic订阅信息,判断所述消息 消费者当前是否有新订阅的Topic或取消订阅的Topic;
    扩展模块,用于若所述消息消费者有新订阅的Topic,则对所述新订阅的Topic执行队列扩展操作;
    第一缩减模块,用于若所述消息消费者有取消订阅的Topic,则对所述取消订阅的Topic执行队列缩减操作。
  7. 如权利要求6所述的队列调整装置,其中,所述判断模块还用于:
    判断消息中间件上是否预先注册有所述消息消费者的Topic订阅信息;
    若是,则将获取到的所述Topic订阅信息与预先注册的所述Topic订阅信息进行比对,以判断所述消息消费者当前是否有新订阅的Topic或取消订阅的Topic。
  8. 如权利要求6所述的队列调整装置,其中,所述扩展模块还用于:
    获取当前所述新订阅的Topic的第一可读队列个数,以及所述消息消费者所属的消费者分组中的第一消费者个数,将所述第一可读队列个数与所述第一消费者个数进行比较;
    当所述第一消费者个数大于所述第一可读队列个数时,将所述第一可读队列个数修改为所述第一消费者个数;
    异步等待第一预设时长后,获取当前所述新订阅的Topic的第一可写队列个数、第二可读队列个数,以及所述消息消费者分组中的第二消费者个数,将所述第一可写队列个数、第二可读队列个数分别与所述第二消费者个数进行比较;
    当所述第二消费者个数大于所述第一可写队列个数,且小于或等于所述第二可读队列个数时,将所述第一可写队列个数修改为所述第二消费者个数。
  9. 如权利要求8所述的队列调整装置,其中,所述第一缩减模块还用于:
    获取当前所述取消订阅的Topic的第二可写队列个数,以及所述消息消费者分组中的第三消费者个数,将所述第二可写队列个数与 所述第三消费者个数进行比较;
    当所述第二可写队列个数大于所述第三消费者个数时,确定待缩减的可写队列,并根据所述待缩减的可写队列将所述第二可写队列个数修改为所述第三消费者个数;
    异步等待第二预设时长后,获取当前所述取消订阅的Topic的第三可读队列个数,以及所述消息消费者分组中的第四消费者个数,将所述第三可读队列个数与所述第四消费者个数进行比较;
    当所述第三可读队列个数大于所述第四消费者个数时,判断所述待缩减的可写队列上的消息是否被消费完;
    若所述待缩减的可写队列上的消息被消费完,则将所述第三可读队列个数修改为所述第四消费者个数。
  10. 如权利要求6所述的队列调整装置,其中,所述队列调整装置还包括:
    第二获取模块,用于当检测到所述消息消费者异常停机时,获取所述消息消费者当前的Topic订阅列表;
    第二缩减模块,还用于对所述Topic订阅列表中的Topic执行队列缩减操作。
  11. 一种队列调整设备,其中,所述队列调整设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的队列调整程序,所述队列调整程序被所述处理器执行时实现如下步骤:
    当检测到消息消费者的心跳信号时,获取所述心跳信号中携带的主题Topic订阅信息;
    根据获取到的所述Topic订阅信息,判断所述消息消费者当前是否有新订阅的Topic或取消订阅的Topic;
    若所述消息消费者有新订阅的Topic,则对所述新订阅的Topic执行队列扩展操作;
    若所述消息消费者有取消订阅的Topic,则对所述取消订阅的Topic执行队列缩减操作。
  12. 如权利要求11所述的队列调整设备,其中,所述队列调整程序被所述处理器执行时还实现如下步骤:
    判断消息中间件上是否预先注册有所述消息消费者的Topic订阅信息;
    若是,则将获取到的所述Topic订阅信息与预先注册的所述Topic订阅信息进行比对,以判断所述消息消费者当前是否有新订阅的Topic或取消订阅的Topic。
  13. 如权利要求11所述的队列调整设备,其中,所述队列调整程序被所述处理器执行时还实现如下步骤:
    获取当前所述新订阅的Topic的第一可读队列个数,以及所述消息消费者所属的消费者分组中的第一消费者个数,将所述第一可读队列个数与所述第一消费者个数进行比较;
    当所述第一消费者个数大于所述第一可读队列个数时,将所述第一可读队列个数修改为所述第一消费者个数;
    异步等待第一预设时长后,获取当前所述新订阅的Topic的第一可写队列个数、第二可读队列个数,以及所述消息消费者分组中的第二消费者个数,将所述第一可写队列个数、第二可读队列个数分别与所述第二消费者个数进行比较;
    当所述第二消费者个数大于所述第一可写队列个数,且小于或等于所述第二可读队列个数时,将所述第一可写队列个数修改为所述第二消费者个数。
  14. 如权利要求13所述的队列调整设备,其中,所述队列调整程序被所述处理器执行时还实现如下步骤:
    获取当前所述取消订阅的Topic的第二可写队列个数,以及所述消息消费者分组中的第三消费者个数,将所述第二可写队列个数与所述第三消费者个数进行比较;
    当所述第二可写队列个数大于所述第三消费者个数时,确定待缩减的可写队列,并根据所述待缩减的可写队列将所述第二可写队 列个数修改为所述第三消费者个数;
    异步等待第二预设时长后,获取当前所述取消订阅的Topic的第三可读队列个数,以及所述消息消费者分组中的第四消费者个数,将所述第三可读队列个数与所述第四消费者个数进行比较;
    当所述第三可读队列个数大于所述第四消费者个数时,判断所述待缩减的可写队列上的消息是否被消费完;
    若所述待缩减的可写队列上的消息被消费完,则将所述第三可读队列个数修改为所述第四消费者个数。
  15. 如权利要求11所述的队列调整设备,其中,所述队列调整程序被所述处理器执行时还实现如下步骤:
    当检测到所述消息消费者异常停机时,获取所述消息消费者当前的Topic订阅列表;
    对所述Topic订阅列表中的Topic执行队列缩减操作。
  16. 一种计算机可读存储介质,其中,所述计算机可读存储介质上存储有队列调整程序,所述队列调整程序被处理器执行时实现如下步骤:
    当检测到消息消费者的心跳信号时,获取所述心跳信号中携带的主题Topic订阅信息;
    根据获取到的所述Topic订阅信息,判断所述消息消费者当前是否有新订阅的Topic或取消订阅的Topic;
    若所述消息消费者有新订阅的Topic,则对所述新订阅的Topic执行队列扩展操作;
    若所述消息消费者有取消订阅的Topic,则对所述取消订阅的Topic执行队列缩减操作。
  17. 如权利要求16所述的计算机可读存储介质,其中,所述队列调整程序被处理器执行时还实现如下步骤:
    判断消息中间件上是否预先注册有所述消息消费者的Topic订阅信息;
    若是,则将获取到的所述Topic订阅信息与预先注册的所述Topic订阅信息进行比对,以判断所述消息消费者当前是否有新订阅的Topic或取消订阅的Topic。
  18. 如权利要求16所述的计算机可读存储介质,其中,所述队列调整程序被处理器执行时还实现如下步骤:
    获取当前所述新订阅的Topic的第一可读队列个数,以及所述消息消费者所属的消费者分组中的第一消费者个数,将所述第一可读队列个数与所述第一消费者个数进行比较;
    当所述第一消费者个数大于所述第一可读队列个数时,将所述第一可读队列个数修改为所述第一消费者个数;
    异步等待第一预设时长后,获取当前所述新订阅的Topic的第一可写队列个数、第二可读队列个数,以及所述消息消费者分组中的第二消费者个数,将所述第一可写队列个数、第二可读队列个数分别与所述第二消费者个数进行比较;
    当所述第二消费者个数大于所述第一可写队列个数,且小于或等于所述第二可读队列个数时,将所述第一可写队列个数修改为所述第二消费者个数。
  19. 如权利要求18所述的计算机可读存储介质,其中,所述队列调整程序被处理器执行时还实现如下步骤:
    获取当前所述取消订阅的Topic的第二可写队列个数,以及所述消息消费者分组中的第三消费者个数,将所述第二可写队列个数与所述第三消费者个数进行比较;
    当所述第二可写队列个数大于所述第三消费者个数时,确定待缩减的可写队列,并根据所述待缩减的可写队列将所述第二可写队列个数修改为所述第三消费者个数;
    异步等待第二预设时长后,获取当前所述取消订阅的Topic的第三可读队列个数,以及所述消息消费者分组中的第四消费者个数,将所述第三可读队列个数与所述第四消费者个数进行比较;
    当所述第三可读队列个数大于所述第四消费者个数时,判断所述待缩减的可写队列上的消息是否被消费完;
    若所述待缩减的可写队列上的消息被消费完,则将所述第三可读队列个数修改为所述第四消费者个数。
  20. 如权利要求16所述的计算机可读存储介质,其中,所述队列调整程序被处理器执行时还实现如下步骤:
    当检测到所述消息消费者异常停机时,获取所述消息消费者当前的Topic订阅列表;
    对所述Topic订阅列表中的Topic执行队列缩减操作。
PCT/CN2020/096385 2019-06-26 2020-06-16 队列调整方法、装置、设备及计算机可读存储介质 WO2020259354A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910571094.0 2019-06-26
CN201910571094.0A CN110300067B (zh) 2019-06-26 2019-06-26 队列调整方法、装置、设备及计算机可读存储介质

Publications (1)

Publication Number Publication Date
WO2020259354A1 true WO2020259354A1 (zh) 2020-12-30

Family

ID=68029314

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/096385 WO2020259354A1 (zh) 2019-06-26 2020-06-16 队列调整方法、装置、设备及计算机可读存储介质

Country Status (2)

Country Link
CN (1) CN110300067B (zh)
WO (1) WO2020259354A1 (zh)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112769948A (zh) * 2021-01-20 2021-05-07 中信银行股份有限公司 消息处理方法及装置
CN113114538A (zh) * 2021-04-19 2021-07-13 中国工商银行股份有限公司 一种心跳检测方法及装置
CN115348222A (zh) * 2022-08-17 2022-11-15 北京蔚领时代科技有限公司 一种消息分发方法、装置、服务端及存储介质

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110300067B (zh) * 2019-06-26 2022-02-08 深圳前海微众银行股份有限公司 队列调整方法、装置、设备及计算机可读存储介质
CN111770029B (zh) * 2020-06-17 2022-06-03 江苏泰治科技股份有限公司 基于RabbitMQ和ActiveMQ的动态队列转发方法、系统及存储介质
CN111770172A (zh) * 2020-06-29 2020-10-13 深圳前海微众银行股份有限公司 消息中间件消费代理方法、装置、代理服务器及存储介质
CN115567477B (zh) * 2022-09-19 2024-05-31 上海星起源新能源科技有限公司 一种处理消息堆积的方法、设备、及存储介质

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120131597A1 (en) * 2010-11-18 2012-05-24 Qiang Han Message routing based on modeled semantic relationships
CN104092767A (zh) * 2014-07-21 2014-10-08 北京邮电大学 一种增加消息队列模型的发布/订阅系统及其工作方法
CN107197015A (zh) * 2017-05-23 2017-09-22 阿里巴巴集团控股有限公司 一种基于消息队列系统的消息处理方法和装置
CN107391271A (zh) * 2017-05-17 2017-11-24 阿里巴巴集团控股有限公司 一种基于消息队列系统的延时任务触发方法和装置
CN108021358A (zh) * 2017-12-15 2018-05-11 无线生活(杭州)信息科技有限公司 一种数据处理方法及装置
CN110300067A (zh) * 2019-06-26 2019-10-01 深圳前海微众银行股份有限公司 队列调整方法、装置、设备及计算机可读存储介质

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080104258A1 (en) * 2006-10-30 2008-05-01 Gestalt, Llc System and method for dynamic data discovery in service oriented networks with peer-to-peer based communication
CN106657349A (zh) * 2016-12-29 2017-05-10 上海理想信息产业(集团)有限公司 一种消息订阅处理装置、系统及方法
CN109286648B (zh) * 2017-07-21 2020-11-06 比亚迪股份有限公司 数据推送方法、装置、系统和终端设备
CN107395729A (zh) * 2017-07-27 2017-11-24 深圳乐信软件技术有限公司 一种消息队列的消费系统、方法及装置
CN109067844A (zh) * 2018-07-09 2018-12-21 上海瀚银信息技术有限公司 一种消息通讯系统

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120131597A1 (en) * 2010-11-18 2012-05-24 Qiang Han Message routing based on modeled semantic relationships
CN104092767A (zh) * 2014-07-21 2014-10-08 北京邮电大学 一种增加消息队列模型的发布/订阅系统及其工作方法
CN107391271A (zh) * 2017-05-17 2017-11-24 阿里巴巴集团控股有限公司 一种基于消息队列系统的延时任务触发方法和装置
CN107197015A (zh) * 2017-05-23 2017-09-22 阿里巴巴集团控股有限公司 一种基于消息队列系统的消息处理方法和装置
CN108021358A (zh) * 2017-12-15 2018-05-11 无线生活(杭州)信息科技有限公司 一种数据处理方法及装置
CN110300067A (zh) * 2019-06-26 2019-10-01 深圳前海微众银行股份有限公司 队列调整方法、装置、设备及计算机可读存储介质

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112769948A (zh) * 2021-01-20 2021-05-07 中信银行股份有限公司 消息处理方法及装置
CN113114538A (zh) * 2021-04-19 2021-07-13 中国工商银行股份有限公司 一种心跳检测方法及装置
CN115348222A (zh) * 2022-08-17 2022-11-15 北京蔚领时代科技有限公司 一种消息分发方法、装置、服务端及存储介质
CN115348222B (zh) * 2022-08-17 2023-11-17 北京蔚领时代科技有限公司 一种消息分发方法、装置、服务端及存储介质

Also Published As

Publication number Publication date
CN110300067B (zh) 2022-02-08
CN110300067A (zh) 2019-10-01

Similar Documents

Publication Publication Date Title
WO2020259354A1 (zh) 队列调整方法、装置、设备及计算机可读存储介质
US10108480B2 (en) Data stream processor and method to counteract anomalies in data streams transiting a distributed computing system
US9277030B2 (en) Stream processing using a client-server architecture
US20120016994A1 (en) Distributed system
WO2021258753A1 (zh) 一种业务处理方法、装置及电子设备和存储介质
CN112565405B (zh) 消息统一推送方法、系统、设备和计算机可读存储介质
CN110677274A (zh) 一种基于事件的云网络服务调度方法及装置
US11782756B2 (en) Method and apparatus for scheduling processor core, and storage medium
CN108337127B (zh) 应用性能监控方法、系统、终端及计算机可读存储介质
WO2019104974A1 (zh) 基于dubbo平台的服务自动启停方法、服务器及存储介质
US20230275976A1 (en) Data processing method and apparatus, and computer-readable storage medium
CN113590437B (zh) 一种告警信息处理方法、装置、设备和介质
CN111200606A (zh) 深度学习模型任务处理方法、系统、服务器及存储介质
CN112333282A (zh) 一种基于混合云的服务提供方法、装置、介质及电子设备
CN112583734A (zh) 一种突发流量控制方法、装置、电子设备及存储介质
CN110928704B (zh) 消息处理方法、消息处理系统、服务器及计算机存储介质
WO2020258653A1 (zh) 一种跨节点的数据处理方法及装置
CN110727507A (zh) 一种消息的处理方法、装置、计算机设备和存储介质
CN111078398A (zh) 一种gpu的分配方法、设备以及存储介质
CN114237896A (zh) 分布式节点资源动态调度方法及装置
US8510426B2 (en) Communication and coordination between web services in a cloud-based computing environment
US9021109B1 (en) Controlling requests through message headers
CN110913018A (zh) 一种分布式调控服务系统
CN115250276A (zh) 分布式系统及数据处理的方法和装置
CN110336847B (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: 20832914

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20832914

Country of ref document: EP

Kind code of ref document: A1