|
|
@@ -0,0 +1,61 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Console\Commands;
|
|
|
+
|
|
|
+use Illuminate\Console\Command;
|
|
|
+use Illuminate\Support\Facades\Log;
|
|
|
+use App\Http\Api\Mq;
|
|
|
+
|
|
|
+class MqEmpty extends Command
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * The name and signature of the console command.
|
|
|
+ *
|
|
|
+ * @var string
|
|
|
+ */
|
|
|
+ protected $signature = 'mq:empty';
|
|
|
+
|
|
|
+ /**
|
|
|
+ * The console command description.
|
|
|
+ *
|
|
|
+ * @var string
|
|
|
+ */
|
|
|
+ protected $description = 'Command description';
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Create a new command instance.
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function __construct()
|
|
|
+ {
|
|
|
+ parent::__construct();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Execute the console command.
|
|
|
+ *
|
|
|
+ * @return int
|
|
|
+ */
|
|
|
+ public function handle()
|
|
|
+ {
|
|
|
+ if (\App\Tools\Tools::isStop()) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ $exchange = 'router';
|
|
|
+ $queue = 'ai_translate';
|
|
|
+ $this->info(" [*] Waiting for {$queue}. To exit press CTRL+C");
|
|
|
+ Log::debug("mq worker {$queue} start.");
|
|
|
+ Mq::worker(
|
|
|
+ $exchange,
|
|
|
+ $queue,
|
|
|
+ function ($message) {
|
|
|
+ $this->info('new message');
|
|
|
+ sleep(3);
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ );
|
|
|
+
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+}
|