在实现 JobQueueEvent 时,我的监听器遇到了一些问题,这是我的监听器类
类 JobStateChangeListener {
函数 onJobStateChange(StateChangeEvent $event) {
if ($event->getJob()->isFinished()) {
error_log('作业状态已完成');
}
if ($event->getJob()->isPending()) {
error_log('作业状态为 isPending');
}
if ($event->getJob()->isFailed()) {
error_log('作业状态为失败');
}
if ($event->getJob()->isRunning()) {
error_log('作业状态为 isRunning');
}
if ($event->getJob()->isNew()) {
error_log('作业状态为isNew');
}
}
}
这是我的 service.yml 用于添加监听器
服务:
工作事件监听器:
类:####\SupportBundle\Listener\JobStateChangeListener
标签:
- {名称:jms_job_queue.job_state_change,方法:onJobStateChange}
这是 JMSjobQueueBundle 调度事件的方式https://github.com/schmittjoh/JMSJobQueueBundle/blob/master/Command/RunCommand.php#L182
更新: ISSUE 是当我运行 app/console jms-job-queue:run my listener not error_log 写入 onJobStateChange func 时,这可能意味着没有在听。让我知道我做错了什么。