Open clofab opened 8 years ago
I've managed to sort of fix it by listening a postUpdate Event. But the onStateChange event still seems to not be triggered when the job state change from running state to any ending state (failed, succes or incomplete).
I could make it work:
app.listener.job:
class: App\CoreBundle\Listener\JobListener
arguments:
- @doctrine.orm.default_entity_manager
tags:
- { name: kernel.event_listener, event: jms_job_queue.job_state_change, method: onStateChange }
<?php
namespace App\CoreBundle\Listener;
use App\CoreBundle\Entity\Queue;
use Doctrine\Common\Persistence\ObjectManager;
use JMS\JobQueueBundle\Event\JobEvent;
class JobListener {
protected $em;
/**
* @param ObjectManager $em
*/
public function __construct(ObjectManager $em)
{
$this->em = $em;
}
public function onStateChange(JobEvent $event)
{
$job = $event->getJob();
$queue = $job->findRelatedEntity('App\CoreBundle\Entity\Queue');
if ($queue instanceof Queue) {
$queue->setJobState($event->getNewState());
$this->em->persist($queue);
$this->em->flush();
}
}
}
Hi, I have the same problem.
The final event is never triggered.
Here, the first condition return false, $this->dispatcher is null, unless when finish Job, thus the event is not dispatched.
Why is null?
Any ideas to fix this ?
I have solved as follows:
In app/AppKernel.php
new JMS\DiExtraBundle\JMSDiExtraBundle($this),
new JMS\AopBundle\JMSAopBundle(),
Hello,
I use this bundle to mass process files into database and I would like to use Event Listener to mark a file processing as failed as soon as the associated job state is set to failed as well, but it never happen. There is the code :
And the event Listener (which for the moment write in a log file for debug):
log.txt
So its seems that onStateChange is never triggered when the job will be closed. Any idea why?