RabbitMQ随手笔记(十五)持久化(.netCore2.0)

交换器持久化:

//
// 摘要:
//     Declare an exchange.
//
// 备注:
//     The exchange is declared non-passive and non-internal. The "nowait" option is
 //     not exercised.
[AmqpMethodDoNotImplement(null)]
void ExchangeDeclare(string exchange, string type, bool durable, bool autoDelete, IDictionary<string, object> arguments);bool durable, bool autoDelete, IDictionary<string, object> arguments);

队列持久化:

 //
 // 摘要:
 //     Declare a queue.
[AmqpMethodDoNotImplement(null)]
QueueDeclareOk QueueDeclare(string queue, bool durable, bool exclusive, bool autoDelete, IDictionary<string, object> arguments);bool durable, bool exclusive, bool autoDelete, IDictionary<string, object> arguments);

消息持久化:

var properties = channel.CreateBasicProperties();
properties.Persistent = true;
channel.BasicPublish(EXCHANGE_NAME, ROUTING_KEY,true, properties, body);

注意:

1.交换器没有持久化,RabbitMQ重启后,消息不回丢失,但是交换器丢失,不能再发送消息到这个交换器了。

2.设置了队列和消息持久化之后,当rabbitMQ重启服务,消息依旧存在;单独设置队列持久化,重启后消息会丢失;单独设置消息持久化,重启之后队列会消失,继而消息也会丢失。

3.交换器、队列、消息都持久化也并不一定完全保证消息不回丢失。

 

更多精彩请关注公众号:隔壁王小猿(gbwxy-happy)

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值