visuddhinanda 2 лет назад
Родитель
Сommit
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){
             if($callback !== null){
                 try{
                 try{
                     $result = $callback(json_decode($message->body));
                     $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){
                     if($result !== 0){
                         throw new \Exception('task error');
                         throw new \Exception('task error');
                     }
                     }
@@ -124,6 +128,7 @@ class Mq{
             }
             }
             $message->ack();
             $message->ack();
 
 
+
             // Send a message with the string "quit" to cancel the consumer.
             // Send a message with the string "quit" to cancel the consumer.
             /*
             /*
             if ($message->body === 'quit') {
             if ($message->body === 'quit') {