久久久久久久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:獲取當前星期幾的值)
主站蜘蛛池模板: 国产大片黄色 | 亚洲国产成人精品女人久久久 | 久草在线中文888 | www.夜夜骑| 欧美综合在线观看 | 日本福利在线观看 | 成人午夜影院 | 美女视频网站久久 | 久久高清 | 欧美日韩第一页 | 亚洲免费成人 | 二区在线观看 | 黄色一级片aaa | 毛片免费视频 | 国产成人精品免高潮在线观看 | 欧美日韩综合 | 黑人巨大精品欧美一区二区免费 | 亚洲国产aⅴ成人精品无吗 综合国产在线 | 国产综合久久 | 插插宗合网| 欧洲一区二区三区 | 人人玩人人添人人澡欧美 | 国产视频91在线 | 色五月激情五月 | www狠狠干| 在线电影日韩 | 国产精品国产a | 亚洲精品久久久久久一区二区 | 国产精品一区二区视频 | 在线视频一区二区三区 | 中文字幕一区二区三区四区 | 97精品国产 | 国产高清在线精品一区二区三区 | 国产成人福利视频在线观看 | 亚洲成人精品国产 | 91精品国产综合久久久密闭 | 亚洲视频免费观看 | 99久久精品免费看国产高清 | 91免费在线| 精品欧美一区二区三区久久久 | 九九热精品视频 |