久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在運行時向兔子偵聽器動態添加隊列

Dynamic addition of queues to a rabbit listener at runtime(在運行時向兔子偵聽器動態添加隊列)
本文介紹了在運行時向兔子偵聽器動態添加隊列的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我有一個項目,我們將在 rabbit 中擁有數百個(可能數千個)隊列,并且每個隊列都需要被一個消費者池消費.

I've got a project where we are going to have hundreds (potentially thousands) of queues in rabbit and each of these queues will need to be consumed by a pool of consumers.

在 rabbit(使用 spring-amqp)中,你有 rabbitlistener 注釋,它允許我靜態分配這個特定消費者將處理的隊列.

In rabbit (using spring-amqp), you have the rabbitlistener annotation which allows me to statically assign the queues this particular consumer(s) will handle.

我的問題是 - 對于 rabbit 和 spring,我是否有一種干凈的方式來獲取一段隊列(比如說以 ac 開頭的隊列),然后還監聽在消費者運行時創建的任何隊列.

My question is - with rabbit and spring, is there a clean way for me to grab a section of queues (lets say queues that start with a-c) and then also listen for any queues that are created while the consumer is running.

示例(開始時):

  • 螞蟻隊列
  • 蘋果隊列
  • 貓隊列

消費者運行時:

  • 添加蝙蝠隊列

這是我目前擁有的(非常簡單的)代碼:

Here is the (very simple) code I currently have:

    @Component
    public class MessageConsumer {

        public MessageConsumer() {
            // ideally grab a section of queues here, initialize a parameter and give to the rabbitlistener annotation
        }

        @RabbitListener(queues= {"ant-queue", "apple-queue", "cat-queue"})
        public void processQueues(String messageAsJson) {
            < how do I update the queues declared in rabbit listener above ? >
        }
    }

我應該補充一下 - 我已經瀏覽了我在網上找到的 spring amqp 文檔,除了靜態(硬編碼或通過屬性)聲明隊列之外,我沒有找到任何東西

I should add - I've gone through the spring amqp documentation I found online and I haven't found anything outside of statically (either hardcoded or via properties) declaring the queues

推薦答案

  • 注入(@Autowired 或其他方式)RabbitListenerEndpointRegistry.

    獲取對監聽器容器的引用(使用注解上的id屬性給它一個已知的id)(registry.getListenerContainer(id)).

    Get a reference to the listener container (use the id attribute on the annotation to give it a known id) (registry.getListenerContainer(id)).

    將容器轉換為 AbstractMessageListenerContainer 并調用 addQueues()addQueueNames().

    Cast the container to an AbstractMessageListenerContainer and call addQueues() or addQueueNames().

    請注意,動態添加隊列時使用 DirectMessageListenerContainer 效率更高;使用 SimpleMessageListenerContainer 消費者會停止并重新啟動.使用直接容器,每個隊列都有自己的消費者.

    Note that is more efficient to use a DirectMessageListenerContainer when adding queues dynamically; with a SimpleMessageListenerContainer the consumer(s) are stopped and restarted. With the direct container, each queue gets its own consumer(s).

    請參閱選擇容器.

    這篇關于在運行時向兔子偵聽器動態添加隊列的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

    【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉換為公歷?)
Java: What/where are the maximum and minimum values of a GregorianCalendar?(Java:GregorianCalendar 的最大值和最小值是什么/在哪里?)
Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch(1582 年 10 月 15 日之前日期的日歷到日期轉換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當前星期幾的值)
主站蜘蛛池模板: 一区二区三区成人 | 亚洲精品欧美一区二区三区 | 亚洲成人免费网址 | 欧美精品1区 | 精品在线一区 | 中文字幕亚洲精品 | 高清av在线 | 国产精品美女久久久 | 国产欧美日韩久久久 | 成人精品一区二区 | 国产精品日本一区二区在线播放 | 七七婷婷婷婷精品国产 | 久久国产精品一区 | 久久最新 | 国产成人精品午夜视频免费 | 中文字幕在线国产 | 国产一区二区三区高清 | 中文字幕国产一区 | 亚洲国产成人av好男人在线观看 | 国产在线小视频 | 在线日韩欧美 | 欧美一区二区三区在线 | wwww.xxxx免费| 亚洲入口 | 51ⅴ精品国产91久久久久久 | 九九热这里只有精品6 | 日韩精品在线播放 | 亚洲成网站 | 91精品一区二区三区久久久久 | 久久久国产精品一区 | 亚洲高清一区二区三区 | 精品国产免费人成在线观看 | 天天射天天操天天干 | 欧美精品中文字幕久久二区 | 成人一区二区视频 | 国产精品一区二区在线观看 | 国产美女在线观看 | 日本不卡一区二区 | 日韩精品一区二区不卡 | 夜夜草| 看a网站|