eventLoop = \Workerman\Events\Fiber::class; $worker->onWorkerStart = function () { $host = config('cons.mq.host'); $port = config('cons.mq.port'); $user = config('cons.mq.user'); $password = config('cons.mq.password'); $queue = config('cons.mq.queue_t') . '-apply.sms.temp'; $client = Client::factory([ 'host' => $host, 'port' => $port, 'user' => $user, 'password' => $password, 'vhost' => '/', 'heartbeat' => 30, 'heartbeat_callback' => function () { echo " [-] coroutine-consumer-heartbeat\n"; }, 'interval' => [100, 300] ])->connect(); $channel = $client->channel(); $channel->queueDeclare($queue); $channel->consume(function (Message $message, Channel $channel, \Bunny\AbstractClient $client) { echo " [>] 接收到消息 ", $message->content, "\n"; }, $queue, '', false, true ); $client->run(); echo ' [*] Waiting for messages. To exit press CTRL+C', "\n"; }; } }