1. 如果你是在虚拟机上建立集群,那么网络分区(network partition)你一定不会陌生。
最暴力的解决方式:重启所有节点app以消除警报。操作顺序:关闭ram节点 -> 关闭disc节点 -> 启动disc节点 -> 启动ram节点
rabbitmqctl stop_app
rabbitmqctl start_app
完整解决方案请参考此文:RabbitMQ网络分区解决方案
2. 即使创建了持久化队列,也并不一定能完全保证消息不丢失。
官网原文:
Note on message persistence
Marking messages as persistent doesn't fully guarantee that a message won't be lost. Although it tells RabbitMQ to save the message to disk, there is still a short time window when RabbitMQ has accepted a message and hasn't saved it yet. Also, RabbitMQ doesn't do fsync(2) for every message -- it may be just saved to cache and not really written to the disk. The persistence guarantees aren't strong, but it's more than enough for our simple task queue. If you need a stronger guarantee then you can use publisher confirms.
它可能只是被缓存了并没有真的写到磁盘!
3. 对 routing key 的理解
与 exchange、queue 有关,但不是决定性因素,即同一个exchange 与同一个 queue 之间可以定义多个 routing key ,换言之:routing key 只是用来定义 一组或多组 exchange与queue之间的绑定关系。
正因如此,由于 fanout 类型的 exchange 不关心是哪个 queue 发送了消息,所以也就不关心 routing key,因此这个参数会被忽略。