ThinkPHP Queue超时的问题

ThinkPHP自带的队列组件thinkphp-queue默认60秒超时,好像也没有配置的地方,只能硬改源码了。

文件路径vendor/topthink/think-queue/src/queue/command/Listen.php,修改configure方法

protected function configure()
    {
        $this->setName('queue:listen')
            ->addArgument('connection', Argument::OPTIONAL, 'The name of the queue connection to work', null)
            ->addOption('queue', null, Option::VALUE_OPTIONAL, 'The queue to listen on', null)
            ->addOption('delay', null, Option::VALUE_OPTIONAL, 'Amount of time to delay failed jobs', 0)
            ->addOption('memory', null, Option::VALUE_OPTIONAL, 'The memory limit in megabytes', 1024)
            ->addOption('timeout', null, Option::VALUE_OPTIONAL, 'Seconds a job may run before timing out', 1200)
            ->addOption('sleep', null, Option::VALUE_OPTIONAL, 'Seconds to wait before checking queue for jobs', 3)
            ->addOption('tries', null, Option::VALUE_OPTIONAL, 'Number of times to attempt a job before logging it failed', 0)
            ->setDescription('Listen to a given queue');
    }

其中timeout默认的是60秒,改长点就好了。

update

添加监听队列的时候加上timeout参数也可以,示例

php think queue:listen --queue MyQueue --timeout 6000

Leave a Comment

豫ICP备19001387号-1