biz-framework icon indicating copy to clipboard operation
biz-framework copied to clipboard

队列执行过程中,如果前一个队列任务异常那么后面的队列会被阻塞

Open jinweijian opened this issue 2 years ago • 0 comments

src/Queue/Worker.php:105 - 113

protected function executeJob($job)
{
    // .....

    try {
        $result = $job->execute();
    } catch (\Exception $e) {
        $this->logger->error($this->createMessage("Execute job #{$job->getId()} error: {$e->getMessage()}"));
        $this->shouldQuit = true;
    } catch (\Throwable $e) {
        $this->logger->error($this->createMessage("Execute job #{$job->getId()} error: {$e->getMessage()}"));
        $this->shouldQuit = true;
    }

    // ....
}

如果 job抛出了\Exception 或者 \Throwable 那么$result 参数是没有被定义的,那么在下面使用 $result 会直接报错,导致整个处理进程被中断,从而导致后面的队列被阻塞

jinweijian avatar Sep 22 '23 03:09 jinweijian