$worker = new Worker();
$worker->count = 100;
$worker->onWorkerStart = function ($worker) {
$client = Test::getServer();
// 訂閱
$id = $worker->id;
$client->subscribe("task-{$id}", function($data)use($id) {
var_dump(66666);
try {
$person = new ProcessPerson();
$person->step1($data);
} catch (\Exception $e) {
var_dump($e->getMessage());
}
});
};
Worker::runAll();
到這里就不往下走了暈死了
redis 擴(kuò)展的subscribe是阻塞操作,后面的代碼不會執(zhí)行,除非subscribe返回。
如果你要非阻塞subscribe,可以用 workerman/redis,參見手冊 http://doc.workerman.net/components/workerman-redis.html
http://doc.workerman.net/components/workerman-redis-queue.html
你先按照示例來,不要封裝,有問題再來發(fā)帖。