channel(); $channel->queue_declare('progress', false, true, false, false); $this->info(" [*] Waiting for messages. To exit press CTRL+C"); $callback = function ($msg) { $message = json_decode($msg->body); $ok = $this->call('upgrade:progress',['--book'=>$message->book, '--para'=>$message->para, '--channel'=>$message->channel, ]); $ok2 = $this->call('upgrade:progress.chapter',['--book'=>$message->book, '--para'=>$message->para, '--channel'=>$message->channel, ]); $this->info("Received book=".$message->book.' progress='.$ok.' chapter='.$ok2); }; $channel->basic_consume('progress', '', false, true, false, false, $callback); while ($channel->is_open()) { $channel->wait(); } return 0; } }