How to capture job queue details after completion in Laravel 5.1?(在 Laravel 5.1 中完成后如何捕获作业队列详细信息?)
问题描述
在 Laravel 5.1 中,我希望在作业完成时收到通知,以及有关作业的详细信息(特别是 user_id 和 customer_id).我在 AppServiceProvider 中使用 Queue::after 方法方法作为 Laravel 建议.
In Laravel 5.1, I would like to be notified when a job is completed, with details about the job (specifically, the user_id, and customer_id). I'm using the Queue::after method method in the AppServiceProvider as Laravel suggests.
如果像这样转储 $data 参数:
If a dump the $data parameter like so:
Queue::after(function ($connection, $job, $data) {
var_dump($data);
exit;
});
我得到以下信息:
array(2) { ["job"]=> string(39) "IlluminateQueueCallQueuedHandler@call" ["data"]=> array(1) { ["command"]=> string(263) "O:23:"AppJobsExportContacts":4:{s:7:"*data";a:5:{s:7:"user_id";s:1:"2";s:10:"customer_id";s:1:"1";s:6:"filter";N;s:5:"dates";a:2:{i:0;i:1445352975;i:1;i:1448034975;}s:4:"file";s:31:"/tend_10-20-2015-11-20-2015.csv";}s:5:"queue";N;s:5:"delay";N;s:6:"*job";N;}" } }
data 数组包含我所追求的 user_id 和 customer_id.这是伟大的.但是我如何解析这个响应来提取这些信息.
The data array contains both of the user_id and the customer_idthat I'm after. Which is great. But how do I parse this response to pull that information out.
我唯一的想法是使用正则表达式.但我想我会检查一下是否有更好的方法?
My only thought is to use regex. But I thought I'd check to see if there was a better way?
推荐答案
对于 Laravel 5.2:
For Laravel 5.2:
Queue::after(function (JobProcessed $event) {
$command = unserialize($event->data['data']['command']);
});
这篇关于在 Laravel 5.1 中完成后如何捕获作业队列详细信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 Laravel 5.1 中完成后如何捕获作业队列详细信息?
基础教程推荐
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何替换eregi() 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
