laravel队列:工人无所事事

时间:2019-02-04 06:55:00

标签: laravel

我的控制器上有此代码。

// Queue job, Send notification
ExportCsvJob::dispatch(json_encode($exportdata))
    ->onConnection('database')
    ->onQueue('default');

.env文件

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

config / queue.php

return [
    'default' => env('QUEUE_DRIVER', 'sync'),

    'connections' => [

        'sync' => [
            'driver' => 'sync',
        ],

        'database' => [
            'driver' => 'database',
            'table' => 'jobs',
            'queue' => 'default',
            'retry_after' => 90,
        ],

        'beanstalkd' => [
            'driver' => 'beanstalkd',
            'host' => 'localhost',
            'queue' => 'default',
            'retry_after' => 90,
        ],

        'sqs' => [
            'driver' => 'sqs',
            'key' => 'your-public-key',
            'secret' => 'your-secret-key',
            'prefix' => 'https://sqs.us-east-1.amazonaws.com/your-account-id',
            'queue' => 'your-queue-name',
            'region' => 'us-east-1',
        ],

        'redis' => [
            'driver' => 'redis',
            'connection' => 'default',
            'queue' => 'default',
            'retry_after' => 90,
        ],

    ],

    'failed' => [
        'database' => env('DB_CONNECTION', 'mysql'),
        'table' => 'failed_jobs',
    ],

但是在运行php artisan queue:work --timeout=3600时千万不要做任何事情,

我在工作表中有这两个记录

+-----+-----------------+------------------------------------------------------------------------------------------------------+----------+-------------+--------------+------------+
| id  | queue           | payload                                                                                              | attempts | reserved_at | available_at | created_at |
+-----+-----------------+------------------------------------------------------------------------------------------------------+----------+-------------+--------------+------------+
| 168 | shipment_export | {"displayName":"App\\Jobs\\ExportCsvJob","job":"Illuminate\\Queue\\CallQueuedHandler@call","maxTries |        0 |        NULL |   1549262600 | 1549262600 |
| 169 | default         | {"displayName":"App\\Jobs\\ExportCsvJob","job":"Illuminate\\Queue\\CallQueuedHandler@call","maxTries |        0 |        NULL |   1549262834 | 1549262834 |
+-----+-----------------+------------------------------------------------------------------------------------------------------+----------+-------------+--------------+------------+

但是当我将QUEUE_DRIVER=sync更改为QUEUE_DRIVER=database时有效

能给我关于我的问题的解释和可能的解决方法吗?

0 个答案:

没有答案