RabbitMQ的隊列(Queue)的參數及其含義


 

                                      圖1 Queue類結構圖

                                       圖2  RabbitMQ web管控台添加隊列圖示

 

/**
* Construct a new queue, given a name, durability flag, and auto-delete flag, and arguments.
* @param name the name of the queue - must not be null; set to "" to have the broker generate the name.
* @param durable true if we are declaring a durable queue (the queue will survive a server restart)
* @param exclusive true if we are declaring an exclusive queue (the queue will only be used by the declarer's
* connection)
* @param autoDelete true if the server should delete the queue when it is no longer in use
* @param arguments the arguments used to declare the queue
*/
public Queue(String name, boolean durable, boolean exclusive, boolean autoDelete, Map<String, Object> arguments) {
Assert.notNull(name, "'name' cannot be null");
this.name = name;
this.actualName = StringUtils.hasText(name) ? name
: (Base64UrlNamingStrategy.DEFAULT.generateName() + "_awaiting_declaration");
this.durable = durable;
this.exclusive = exclusive;
this.autoDelete = autoDelete;
this.arguments = arguments != null ? arguments : new HashMap<>();
}

參數介紹:
1、name: 隊列的名稱;
2、actualName: 隊列的真實名稱,默認用name參數,如果name為空,則根據規則生成一個;
3、durable: 是否持久化;
4、exclusive: 是否獨享、排外的;
5、autoDelete: 是否自動刪除;
6、arguments:隊列的其他屬性參數,有如下可選項,可參看圖2的arguments:
(1)x-message-ttl:消息的過期時間,單位:毫秒;
(2)x-expires:隊列過期時間,隊列在多長時間未被訪問將被刪除,單位:毫秒;
(3)x-max-length:隊列最大長度,超過該最大值,則將從隊列頭部開始刪除消息;
(4)x-max-length-bytes:隊列消息內容占用最大空間,受限於內存大小,超過該閾值則從隊列頭部開始刪除消息;
(5)x-overflow:設置隊列溢出行為。這決定了當達到隊列的最大長度時消息會發生什么。有效值是drop-head、reject-publish或reject-publish-dlx。仲裁隊列類型僅支持drop-head;
(6)x-dead-letter-exchange:死信交換器名稱,過期或被刪除(因隊列長度超長或因空間超出閾值)的消息可指定發送到該交換器中;
(7)x-dead-letter-routing-key:死信消息路由鍵,在消息發送到死信交換器時會使用該路由鍵,如果不設置,則使用消息的原來的路由鍵值
(8)x-single-active-consumer:表示隊列是否是單一活動消費者,true時,注冊的消費組內只有一個消費者消費消息,其他被忽略,false時消息循環分發給所有消費者(默認false)
(9)x-max-priority:隊列要支持的最大優先級數;如果未設置,隊列將不支持消息優先級;
(10)x-queue-mode(Lazy mode):將隊列設置為延遲模式,在磁盤上保留盡可能多的消息,以減少RAM的使用;如果未設置,隊列將保留內存緩存以盡可能快地傳遞消息;
(11)x-queue-master-locator:在集群模式下設置鏡像隊列的主節點信息。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM