shish 8 месяцев назад
Родитель
Сommit
ce846bb08a
1 измененных файлов с 2 добавлено и 0 удалено
  1. 2 0
      common/components/rabbitmq/notifyConsumer.php

+ 2 - 0
common/components/rabbitmq/notifyConsumer.php

@@ -41,6 +41,7 @@ class notifyConsumer implements ConsumerInterface
             print_r($data);
             // 根据通知类型分发处理
             $type = $data['type'] ?? null;
+            Yii::$app->db->open();//处理消息前确保连接可用
             switch ($type) {
                 case 'ghs_new_order_notify':
                     //供货商的新订单通知
@@ -58,6 +59,7 @@ class notifyConsumer implements ConsumerInterface
                     noticeUtil::push("通知的消费者提示:Unknown notify type: {$type}", '15280215347');
                     $result = false;
             }
+            Yii::$app->db->close(); // 处理完后关闭连接
             if ($result) {
                 return ConsumerInterface::MSG_ACK;
             } else {