fwrite(): send of 13 bytes failed with errno=32 Broken pipe
fwrite(): send of 21 bytes failed with errno=104 Connection reset by peer
用 rabbitmq 做消息隊列時報上面的錯誤,當消費隊列一啟動,Unacked 瞬間達到好幾百。經查:RabbitMQ服務器在短時間內發送大量的消息給Consumer,如果你沒有來得及Ack的話,那么服務端會積壓大量的UnAcked消息,而Consumer如果來不急處理也會處於假死或程序崩潰。
后果就是Consmer崩潰后,UnAcked消息又ReQueue不斷消耗MQ的資源
解決方案:
$connection = new AMQPStreamConnection(HOST, PORT, USER, PASS, VHOST);
$channel = $connection->channel();
$channel->queue_declare('qos_queue', false, true, false, false);
$channel->basic_qos(null, 10, null); //加上這個就好了 這個10 就是Unacked 里面的值,表示預先取出多少值來消費 prefetch_count

