作者:SuperBaby蜜 | 来源:互联网 | 2023-02-12 14:04
我正在使用laravel队列在facebook帖子上发表评论.当我收到来自facebook webhook的数据时,根据收到的详细信息,我正在评论帖子.要从facebook webhook一次处理100个响应,我正在使用laravel队列,以便它可以逐个执行.我使用了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;
private $data;
public function __construct($data)
{
$this->data = $data;
}
public function handle()
{
//handling the data here
}
}
我连续点击webhooks()函数,所有作业同时工作但不在队列中,没有任何作业存储在作业表中,我已经给出延迟但它也没有工作,请一些人帮助我,我一直在从昨天开始尝试,但没有结果.
这是我登录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
Mahdi Yousef..
19
对于使用队列你应该做一些工作:
在.env文件中,您应该将queue_drive从同步更改为数据库
之后,您应该使用artisan命令在数据库中创建队列表:
queue_driver=database
最后你应该用php artisan queue:listen
或运行你的队列php artisan queue:work
1> Mahdi Yousef..:
对于使用队列你应该做一些工作:
在.env文件中,您应该将queue_drive从同步更改为数据库
之后,您应该使用artisan命令在数据库中创建队列表:
queue_driver=database
最后你应该用php artisan queue:listen
或运行你的队列php artisan queue:work
2> Haydar ŞAHİN..:
我遇到了同样的麻烦,如果您使用的是laravel 5.7,请在.env文件中使用它
QUEUE_COnNECTION=database
之后,像这样清除配置缓存
php artisan config:cache
3> Jon McClung..:
Laravel 5.7的更新:
在中.env
,进行设置,QUEUE_COnNECTION=database
以便调度的作业进入数据库驱动程序。
然后:
# Creates a migration for the database table holding the jobs
php artisan queue:table
# Executes the migration
php artisan migrate
# Kicks off the process that executes jobs when they are dispatched
php artisan queue:work