Laravel 5.2 $ this-> dispatch没有调用handle函数

时间:2017-05-24 11:43:31

标签: redis laravel-5.2 queue

Laravel 5.2 $this->dispatch 没有调用句柄功能

我使用以下控制器

namespace App\Http\Controllers;
use App\User;
use Illuminate\Http\Request;
use App\Jobs\SendReminderEmail;
use App\Http\Controllers\Controller;
use Redis;
class HomeController extends Controller
{
    /**
     * Send a reminder e-mail to a given user.
     *
     * @param  Request  $request
     * @param  int  $id
     * @return Response
     */
    public function sendReminderEmail()
    {
        $this->dispatch(new SendReminderEmail());
    }
}  

并且作业文件是

namespace App\Jobs;

use Redis;
use Mail;
use App\User;
use App\Jobs\Job;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;

class SendReminderEmail extends Job implements ShouldQueue
{
    use InteractsWithQueue, SerializesModels;

    public function __construct()
    {
    }
    public function handle()
    {
      $redis = Redis::connection();
      $redis->set('org', 'Mycompany');
    }
}

当我调用控制器函数并检查redis服务器的org变量时,我得到了空值!

我如何调用工作职能?

1 个答案:

答案 0 :(得分:0)

在.env文件中设置QUEUE_DRIVER = sync。