代码之家  ›  专栏  ›  技术社区  ›  Fil

拉维尔队列:工人什么也没做

  •  1
  • Fil  · 技术社区  · 6 年前

    // 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 回复  |  直到 6 年前