Explorar o código

add .stop test

visuddhinanda %!s(int64=2) %!d(string=hai) anos
pai
achega
e69c26ed03
Modificáronse 1 ficheiros con 5 adicións e 0 borrados
  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') {