RabbitMQ 记录
RabbitMQ 中文文檔 : http://rabbitmq.mr-ping.com/description.html
官方教程譯文:
一 http://blog.csdn.net/xiaoxian8023/article/details/48679609
二 http://blog.csdn.net/xiaoxian8023/article/details/48681987
三 http://blog.csdn.net/xiaoxian8023/article/details/48710653
四 http://blog.csdn.net/xiaoxian8023/article/details/48729479
五 http://blog.csdn.net/xiaoxian8023/article/details/48733249
六 http://blog.csdn.net/xiaoxian8023/article/details/48806871
七?http://blog.csdn.net/xiaoxian8023/article/details/48826857
?
?
1. BasicPublish發(fā)送久化消息
var properties = channel.CreateBasicProperties();properties.SetPersistent(false);channel.BasicPublish(exchange: "", routingKey: "task_queue", basicProperties: properties, body: body);Console.WriteLine(" [x] Sent {0}", message);BasicPublish方法的參數(shù)BasicProperties,SetPersistent為false的時候消息不能持久化,重啟MQ會丟失。
SetPersistent(false); 被標記為已過時,新方法為:properties.DeliveryMode = 2; 。
?
2. QueueDeclare 和 QueueBind
QueueDeclareOk QueueDeclare(string queue, bool durable, bool exclusive, bool autoDelete, IDictionary<string, object> arguments)
void QueueBind(string queue, string exchange, string routingKey);
從結(jié)果上看,兩個方法都可以做Queue綁定之后讀取Message。區(qū)別是,QueueDeclare 參數(shù)列表中所指定的 queue(實際是QueueName) 如果不存在,將會自動創(chuàng)建一個Queue,這種做法在實際研發(fā)中并不推薦。
?
3. topic 模式綁定的用法(反復(fù)幾次都記不住)
首先將 exchange 設(shè)置為 topic 模式,然后在queue綁定的時候?qū)?routingKey 設(shè)置為 #.exchange 或者 *.*.exchange 進行路由模糊匹配。
?
4. 匿名 exchange 和匿名臨時 queue
日志系統(tǒng)比較適合匿名queue,參見 http://www.rabbitmq.com/tutorials/tutorial-three-dotnet.html 。 ?
有 consumer 的時候可以正常消費 message, 沒有 consumer 連接的時候消息也不會保留。
?
?5. noAck = false 用于用于標記 consumer 接受到消息必須返回給 RabbitMQ 確認信息之后,消息才會被移除。如果 consumer 的 noAck = true ,則消息發(fā)送出去就立即被移除。
?
6. exlusive 用于標記排他型隊列,DeclareQueue 的時候,如果 exclusive:true ,則鏈接斷開的時候 Queue 將被清除。
?
轉(zhuǎn)載于:https://www.cnblogs.com/jiajinyi/p/6050700.html
總結(jié)
以上是生活随笔為你收集整理的RabbitMQ 记录的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c# winform InvokeReq
- 下一篇: Tableau10.0学习随记-分组问题