MqWbwAnalyses.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. namespace App\Console\Commands;
  3. use Illuminate\Console\Command;
  4. use App\Http\Api\Mq;
  5. use Illuminate\Support\Facades\Log;
  6. class MqWbwAnalyses extends Command
  7. {
  8. /**
  9. * The name and signature of the console command.
  10. *
  11. * @var string
  12. */
  13. protected $signature = 'mq:wbw.analyses';
  14. /**
  15. * The console command description.
  16. *
  17. * @var string
  18. */
  19. protected $description = 'Command description';
  20. /**
  21. * Create a new command instance.
  22. *
  23. * @return void
  24. */
  25. public function __construct()
  26. {
  27. parent::__construct();
  28. }
  29. /**
  30. * Execute the console command.
  31. *
  32. * @return int
  33. */
  34. public function handle()
  35. {
  36. if(\App\Tools\Tools::isStop()){
  37. return 0;
  38. }
  39. $exchange = 'router';
  40. $queue = 'wbw-analyses';
  41. $this->info(" [*] Waiting for {$queue}. To exit press CTRL+C");
  42. Log::debug("mq:wbw.analyses start.");
  43. Mq::worker($exchange,$queue,function ($message){
  44. $data = ['id'=>implode(',',$message)];
  45. $ok = $this->call('upgrade:wbw.analyses',$data);
  46. if($ok === 0){
  47. $this->info("Received count=".count($message).' ok='.$ok);
  48. Log::debug('mq:wbw.analyses done count='.count($message));
  49. }else{
  50. Log::error('mq:wbw.analyses',$data);
  51. }
  52. return $ok;
  53. });
  54. return 0;
  55. }
  56. }