Jelajahi Sumber

timeout =15

visuddhinanda 1 tahun lalu
induk
melakukan
b0c99df64d
1 mengubah file dengan 10 tambahan dan 2 penghapusan
  1. 10 2
      api-v8/app/Http/Api/Mq.php

+ 10 - 2
api-v8/app/Http/Api/Mq.php

@@ -165,11 +165,19 @@ class Mq
         };
 
         register_shutdown_function($shutdown, $channel, $connection);
+
+        $timeout = 15;
+        $deadline = time() + $timeout;
         // Loop as long as the channel has callbacks registered
         while ($channel->is_consuming()) {
-            $channel->wait(null, true);
+            try {
+                $channel->wait(null, false, $deadline - time());
+            } catch (\Throwable $th) {
+                //throw $th;
+                Log::error('rabbitmq timeout');
+            }
+
             // do something else
-            usleep(300000);
         }
     }
 }