Closed billlv closed 1 year ago
推送:sync_publish(Builder::instance(), $params, null, true); 说明文档中,最后的close 参数,最好默认是true。 如果该方法应用在 controller 部分,这个会因为没有固定的 心跳监听而造成大量的发布失败。 虽然每次都会重新创建连接,那也是稳定和高效的。
process 里的消息接收。建议加入重连检查。有时候网络断开造成的消费者丢失没有重连。 或者搞个重连开关。
` public function onWorkerStart(Worker $worker): void { parent::onWorkerStart($worker);
Timer::add(10, function () { $this->checkConnection(); }); } private function checkConnection() { try { if($this->connection()->client()->isConnected() == false) { $this->logger->debug('Reconnect'); $this->connection()->consume($this->getMessage()); }else { $this->logger->debug('Connection is OK'); } } catch (\Exception $e) { $this->logger->error($e->getMessage()); } }
`
推送:sync_publish(Builder::instance(), $params, null, true); 说明文档中,最后的close 参数,最好默认是true。 如果该方法应用在 controller 部分,这个会因为没有固定的 心跳监听而造成大量的发布失败。 虽然每次都会重新创建连接,那也是稳定和高效的。
process 里的消息接收。建议加入重连检查。有时候网络断开造成的消费者丢失没有重连。 或者搞个重连开关。
` public function onWorkerStart(Worker $worker): void { parent::onWorkerStart($worker);
`