Laravel队列不起作用 [英] Laravel queues not working
问题描述
我正在使用laravel队列在Facebook帖子上发表评论.每当我从facebook webhook接收数据时,根据收到的详细信息,我就是 对帖子发表评论.为了一次处理来自Facebook webhook的100个响应,我正在使用laravel队列,以便它可以一个接一个地执行. 我使用了 https://scotch.io/中提到的分步过程教程/why-laravel-queues很棒
I am using laravel queues for commenting on the facebook post. When ever i recieve data from facebook webhook, based on the recieved details i am commenting on the post. To handle 100 responses at once from facebook webhook i am using laravel queues, so that it can execute one by one. I have used the step by step process as mentioned in https://scotch.io/tutorials/why-laravel-queues-are-awesome
public function webhooks(Request $request)
{
$data = file_get_contents('php://input');
Log::info("Request Cycle with Queues Begins");
$job = (new webhookQueue($data)->delay(10);
$this->dispatch($job);
Log::info("Request Cycle with Queues Ends");
}
这是我的工作类别结构
class webhookQueue extends Job implements ShouldQueue
{
使用InteractsWithQueue,SerializesModels;
use InteractsWithQueue, SerializesModels;
private $data;
public function __construct($data)
{
$this->data = $data;
}
public function handle()
{
//handling the data here
}
}
我连续命中webhooks()函数,所有作业同时工作但不在队列中,所有作业都没有存储在作业表中,我给出了延迟,但也无法正常工作,请有人帮我,我从昨天开始一直在尝试,但是没有结果.
I am hitting webhooks() function continuously, all the jobs are working simultaneously but not in queue, none of the jobs are storing in jobs table, i have given delay but it is also not working, please some one help me, I have been trying from yesterday, but no result.
这是我在laravel.log中的登录
And this is my log in laravel.log
[2017-02-08 14:18:42] local.INFO: Request Cycle with Queues Begins
[2017-02-08 14:18:44] local.INFO: Request Cycle with Queues Begins
[2017-02-08 14:18:47] local.INFO: Request Cycle with Queues Begins
[2017-02-08 14:18:47] local.INFO: Request Cycle with Queues Begins
[2017-02-08 14:18:47] local.INFO: Request Cycle with Queues Begins
[2017-02-08 14:18:47] local.INFO: Request Cycle with Queues Begins
[2017-02-08 14:18:48] local.INFO: Request Cycle with Queues Begins
[2017-02-08 14:18:48] local.INFO: Request Cycle with Queues Begins
[2017-02-08 14:18:48] local.INFO: Request Cycle with Queues Begins
[2017-02-08 14:18:48] local.INFO: Request Cycle with Queues Begins
[2017-02-08 14:18:48] local.INFO: Request Cycle with Queues Begins
[2017-02-08 14:18:48] local.INFO: Request Cycle with Queues Begins
[2017-02-08 14:18:55] local.INFO: Request Cycle with Queues Ends
[2017-02-08 14:18:55] local.INFO: Request Cycle with Queues Ends
[2017-02-08 14:18:55] local.INFO: Request Cycle with Queues Ends
[2017-02-08 14:18:59] local.INFO: Request Cycle with Queues Ends
[2017-02-08 14:19:00] local.INFO: Request Cycle with Queues Ends
[2017-02-08 14:19:00] local.INFO: Request Cycle with Queues Ends
[2017-02-08 14:19:00] local.INFO: Request Cycle with Queues Ends
[2017-02-08 14:19:01] local.INFO: Request Cycle with Queues Ends
[2017-02-08 14:19:01] local.INFO: Request Cycle with Queues Ends
[2017-02-08 14:19:01] local.INFO: Request Cycle with Queues Ends
[2017-02-08 14:19:01] local.INFO: Request Cycle with Queues Ends
[2017-02-08 14:19:01] local.INFO: Request Cycle with Queues Ends
推荐答案
对于使用队列,您应该做一些工作:
for use queue you should some work :
在.env文件中,您应该将queue_driver从同步更改为数据库, 因此,打开.env并执行以下操作
in .env file you should change queue_driver from sync to database, so open .env and do the follow
queue_driver=database
之后,您应该使用artisan命令在数据库中创建队列表:
after it you should create queue table in your database with artisan command :
php artisan queue:table
php artisan migrate
最后,您应该使用php artisan queue:listen
或php artisan queue:work
这篇关于Laravel队列不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!