瀏覽代碼

add .stop test

visuddhinanda 2 年之前
父節點
當前提交
e69c26ed03
共有 1 個文件被更改,包括 5 次插入0 次删除
  1. 5 0
      app/Http/Api/Mq.php

+ 5 - 0
app/Http/Api/Mq.php

@@ -102,6 +102,10 @@ class Mq{
             if($callback !== null){
                 try{
                     $result = $callback(json_decode($message->body));
+                    if(\App\Tools\Tools::isStop()){
+                        Log::debug('mq worker: .stop file exist. cancel the consumer.');
+                        $message->getChannel()->basic_cancel($message->getConsumerTag());
+                    }
                     if($result !== 0){
                         throw new \Exception('task error');
                     }
@@ -124,6 +128,7 @@ class Mq{
             }
             $message->ack();
 
+
             // Send a message with the string "quit" to cancel the consumer.
             /*
             if ($message->body === 'quit') {