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

RabbitMQ - 獲取排隊的消息總數

RabbitMQ - Get total count of messages enqueued(RabbitMQ - 獲取排隊的消息總數)
本文介紹了RabbitMQ - 獲取排隊的消息總數的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我有一個監控 RabbitMQ 隊列的 Java 客戶端.我可以使用此代碼獲取當前隊列中的消息數

I have a Java client which monitors RabbitMQ queue. I am able to get the count of messages currently in queue with this code

@Resource
RabbitAdmin rabbitAdmin;
..........

DeclareOk declareOk = rabbitAdmin.getRabbitTemplate().execute(new ChannelCallback<DeclareOk>() {
        public DeclareOk doInRabbit(Channel channel) throws Exception {
            return channel.queueDeclarePassive("test.pending");
        }
    });
     return declareOk.getMessageCount();

我想了解更多詳細信息,例如 -

I want to get some more additional details like -

  1. 當前排隊項目的消息正文.
  2. 自隊列創建以來在隊列中排隊的消息總數.

有沒有辦法在 Java 客戶端中檢索這些數據?

Is there any way to retrieve these data in Java client?

推薦答案

使用 AMQP 協議(??包括 RabbitMQ 實現)您無法 100% 保證獲得此類信息.

With AMQP protocol (including RabbitMQ implementation) you can't get such info with 100% guarantee.

與消息計數最接近的數字是使用 queue.declare-ok (AMQP.Queue.DeclareOk 在 java AMQP 客戶端庫中).

The closest number to messages count is messages count returned with queue.declare-ok (AMQP.Queue.DeclareOk in java AMQP client library).

雖然您使用 queue.declare-ok 收到的消息計數可能與隊列中的確切消息數量匹配,但您不能依賴它,因為它不計算等待確認或發布到隊列的消息事務但尚未提交.

Whilst messages count you receive with queue.declare-ok may match exact messages number enqueues, you can't rely on it as it doesn't count messages which waiting acknowledges or published to queue during transaction but not committed yet.

這真的取決于你需要什么樣的精度.

It really depends what kind of precission do you need.

對于排隊的消息正文,您可能需要手動提取隊列中的所有消息,查看它們的正文并將它們放回隊列.這是做你想做的事的唯一方法.

As to enqueued messages body, you may want to manually extract all messages in queue, view their body and put them back to queue. This is the only way to do what you want.

您可以使用 管理插件,RabbitMQ 管理 HTTP API 和 rabbitmqctl 實用程序(參見 list_queues、list_channels).

You can get some information about messages count with Management Plugin, RabbitMQ Management HTTP API and rabbitmqctl util (see list_queues, list_channels).

自創建隊列以來,您無法獲得已發布消息的總數,而且我認為沒有人在它無用的情況下實現此類統計信息(僅供參考,消息流平均每秒 10k,您甚至不會在幾千年內達到 uint64).

You can't get total published messages count since queue was created and I think nobody implement such stats while it useless (FYI, with messages flow in average 10k per second you will not even reach uint64 in a few thousand years).

這篇關于RabbitMQ - 獲取排隊的消息總數的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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:獲取當前星期幾的值)
主站蜘蛛池模板: 亚洲日韩中文字幕 | 国产资源视频 | av国产精品| 人人澡人人射 | 亚洲精品日韩综合观看成人91 | 国产乱码久久久久久 | 亚洲精品在线视频 | 欧美日韩中文字幕在线 | 成人欧美一区二区三区黑人孕妇 | 国产精品免费在线 | 在线日韩视频 | 亚洲一二三视频 | 国产精品视频一区二区三区四蜜臂 | 久久久久9999亚洲精品 | hdfreexxxx中国妞 | 羞羞视频免费在线观看 | 我想看国产一级毛片 | 91 久久 | 国产精品久久久久久久久免费樱桃 | 久久国产欧美一区二区三区精品 | 日韩精品999 | 丝袜美腿一区二区三区 | 免费看国产a | 91影院在线观看 | 免费在线观看成人 | 狠狠操av | 欧美一级电影免费观看 | 亚洲一区二区中文字幕 | 免费一二区 | 亚洲激情第一页 | 亚洲视频二区 | 亚洲成人免费视频在线观看 | 国产美女特级嫩嫩嫩bbb片 | 欧美成年人 | 美女在线一区二区 | 美女国产精品 | 欧美一区二区三区精品免费 | 国精久久 | 狠狠干五月天 | 亚洲精品中文字幕中文字幕 | 女人一区 |