rabbitmq_坑
None of the specified endpoints were reachable
异常:
1、unable to connect to node rabbit@10: nodedown
2、Message:Already closed: The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=320, text="CONNECTION_FORCED - broker forced connection closure with reason 'shutdown'", classId=0, methodId=0, cause= StackTrace
3、Rabbitmq实际数据文件、日志文件、配置文件路径
RabbitMQ消息丢失以及解决策略
消息丢失
RabbitMQ流程
producer端
RabbitMQ Server端
Consumer端
消息乱序
RabbitMQ的ack或nack机制使用不当导致的队列堵塞或死循环问题
自动ack机制会导致消息丢失的问题;
启用ack机制后,没有及时ack导致的队列异常;
启用nack机制后,导致的死循环
启用Qos和ack机制后,没有及时ack导致的队列堵塞;
消费者串行处理,崩溃时导致未处理的预取数据丢失;
心跳时间设置太短导致的异常;
rabbitmq_坑
None of the specified endpoints were reachable
这个异常在创建连接时抛出(CreateConnection()),原因一般是ConnectionFactory参数设置不对,比如HostName、UserName、Password
标准设置:
var factory = new ConnectionFactory();
factory.UserName = QueueSetttiong.UserName; //用户名
factory.Password = QueueSetttiong.Password; //密码
factory.HostName = QueueSetttiong.HostName; //Rabbitmq服务IP,不包含端口
factory.Port = AmqpTcpEndpoint.UseDefaultPort;
factory.VirtualHost = QueueSetttiong.VirtualHost; //默认为"/"
factory.Protocol = Protocols.DefaultProtocol;
部署生产后,factory配置都ok,但是还是抛异常None of the specified endpoints were reachable,最后发现原因是生产机器防火墙未打开RabbitMQ的端口,RabbitMQ的默认端口是:5672
另外一个可能的原因:未设置VirtualHost的权限
设置方法:RabbitmqWeb管理网站-->Admin
未设置权限时:
设置权限:(点击admin进入设置页面)
异常:
1、unable to connect to node rabbit@10: nodedown
重新安装Rabbitmq服务端即可,有时候需要重启
2、Message:Already closed: The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=320, text="CONN