RabbitMQ (Channel參數篇)


Channel 

1:方法ExchangeDeclare

void ExchangeDeclare(string exchange, string type, bool durable, bool autoDelete, IDictionary<string, object> arguments);

參數:

  1.1:exchange:交換機的名稱

  1.2:Type:交換機的類型(direct,fanout,topic)

  1.3:durable:如果為true的話,服務器重啟后該Exchange保留。(盡設置此項,不能保證重啟后消息還在)

  1.4:autoDelete:如果為true的話,當沒有消費者的時候,Exchange自動刪除。

  1.5:argments:交換機的屬性參數

2:方法BasicQos

void BasicQos(uint prefetchSize, ushort prefetchCount, bool global);

參數:

  2.1:prefetchsize:prefetchSize maximum amount of content (measured in  octets) that the server will deliver, 0 if unlimited。

  2.2:prefetchCount:prefetchCount maximum number of messages that the server will deliver, 0 if unlimited。一次推給一個消費者的消息數不會超過設置的數。一單超過。消費者將阻塞,一直等到有消息確認ACK

  2.3:global:global true if the settings should be applied to the entire channel rather than each consumer。如果設置為true,則上面的設置會應用於整個Channel,而不是單個的消費者。

 3:方法BasicPublish

void BasicPublish(string exchange, string routingKey, bool mandatory, IBasicProperties basicProperties, byte[] body);

  3.1:exchange:交換機的名稱。

  3.2:routingKey:路由鍵(# 代表匹配0個或者多個單詞,*代表匹配一個單詞)。

  3.3:mandatory:如果設置為true,如果交換機根據交換機類型和routeKey無法找到一個符合條件的Queue,那么會調用Basic.Return方法將消息返還給生產者。如果設置為false,出現上述情形momBroker會直接將消息扔掉。

  3.4:basicProperties:基本屬性:deliveryMode,0:不持久化 1:持久化 (消息的持久化),配合channel(durable=true),queue(durable)可以實現,即使服務器掛掉,消息仍然存在。

  3.5:body:指的是傳輸的數據。

 4:方法BasicAck

void BasicAck(ulong deliveryTag, bool multiple);

  4.1:deliveryTag:消息的Tag。

  4.2:multiple:如果設置為true,則將小於tag的消息一次性Ack。

5:方法BasicNack

void BasicNack(ulong deliveryTag, bool multiple, bool requeue);

  5.1:deliveryTag:消息的Tag。

  5.2:multiple:如果設置為true,則將小於tag的消息一次性NAck。

  5.3:requeue:如果設置為true,則被Nack的信息重新入隊列。

6:方法BasicReject

void BasicReject(ulong deliveryTag, bool requeue);

  6.1:deliveryTag:消息的Tag。

  6.2:requeue:如果設置為true,則被拒絕的信息重新入隊列。

7:方法BasicConsume

string BasicConsume(string queue, bool noAck, string consumerTag,  IDictionary<string, object> arguments, IBasicConsumer consumer);

剩下的有時間再寫吧。。。。。


免責聲明!

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



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