Laravel 5.1和Redis排队工作不起作用

时间:2015-11-15 12:42:27

标签: php queue laravel-5.1

我正在使用Laravel 5.1,我试图设置一个排队的工作来获取我需要等待的细节(大约2分钟),直到我能够得到它们。 由于某种原因,排队工作对我来说不起作用,我在这里看到了一些关于它的问题,但没有答案也没有帮助。 我的config/queue.php文件如下所示:

'default' => env('QUEUE_DRIVER', 'redis'),

'connections' => [

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

    'database' => [
        'driver' => 'database',
        'table' => 'jobs',
        'queue' => 'default',
        'expire' => 60,
    ],

    'beanstalkd' => [
        'driver' => 'beanstalkd',
        'host'   => 'localhost',
        'queue'  => 'default',
        'ttr'    => 60,
    ],

    'sqs' => [
        'driver' => 'sqs',
        'key'    => 'your-public-key',
        'secret' => 'your-secret-key',
        'queue'  => 'your-queue-url',
        'region' => 'us-east-1',
    ],

    'iron' => [
        'driver'  => 'iron',
        'host'    => 'mq-aws-us-east-1.iron.io',
        'token'   => 'your-token',
        'project' => 'your-project-id',
        'queue'   => 'your-queue-name',
        'encrypt' => true,
    ],

    'redis' => [
        'driver' => 'redis',
        'connection' => 'default',
        'queue'  => 'default',
        'expire' => 60,
    ],

我尝试排队的工作看起来像这样:

<?php

namespace LM2\Jobs;

use Illuminate\Support\Facades\Log;
use LM2\Http\Controllers\AnalyticsController;
use LM2\Jobs\Job;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Bus\SelfHandling;
use Illuminate\Contracts\Queue\ShouldQueue;
use LM2\Models\Client;
use LM2\Models\GoogleIntegration;
use LM2\Models\Lead;

class CompleteLeadAnalyticsDetails extends Job implements SelfHandling, ShouldQueue
{
    use InteractsWithQueue, SerializesModels;

    private $lead;
    private $client;

    public function __construct(Lead $lead, Client $client)
    {
        $this->lead   = $lead;
        $this->client = $client;
    }

    public function handle(AnalyticsController $analyticsController)
    {
        try{
            $integration = GoogleIntegration::where('client_id', $this->client->id)->first();
            $analyticsController->getLeadDetails($integration->view_id,$this->lead->ga_details['uacid'],$this->lead->_id);
        }catch (\Google_Service_Exception $e){
            Log::error("Error!, ". $e->getMessage(). ' On client '.$this->client->name.', '.$this->client->id);
        }

    }
}

我称之为:

$complete_analytics_proccess = (new CompleteLeadAnalyticsDetails($lead, $client))->delay(120);
        $this->dispatch($complete_analytics_proccess);

当然我使用redis服务器在后台运行(我也将它用于实时的东西,并且它的工作正常)。 我没有收到任何错误,我记录的错误也没有记录。 有谁知道问题是什么?它看起来像我做的一切像​​官方文档说的那样。感谢任何帮助,谢谢! :)

0 个答案:

没有答案