1
我需要Laravel隊列幫助,如果有人可以幫助我進一步,我已經做了這些步驟至今讓Laravel使用數據庫隊列,而不是同步
改變隊列司機.ENV文件數據庫
隊列表創造的就業機會遷移和失敗的作業
php artisan queue:table php artisan queue:failed-table
和我有るÑPHP人員遷移
創建了一個新的工作
php artisan make:job SendNewArticleNotification
更新:
確定我已經創建了一個路由/隊列
Route::get('/queue', function() {
dispatch(new \App\Jobs\SendNewArticleNotification);
});
和我的工作SendNewArticleNotification我有這個
<?php
namespace App\Jobs;
use App\User;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class SendNewArticleNotification implements ShouldQueue
{
use InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Execute the job.
*
* @return void
*/
public function handle()
{
$users = User::all();
$article = \App\Article::first();
foreach ($users as $user) {
$user->notify(new \App\Notifications\Published($article));
}
}
}
當我打我的/隊列路由電子郵件被髮送beeing但他們沒有使用該數據庫表....這時間超過30秒發送50個郵件...
UPDATE
好吧,我終於明白了,dispatch()需要在控制器方法裏面,因爲控制器具有特性調度作業....現在我的作業在數據庫表作業中排隊....所以我如何在幕後觸發他們?