public function onSend(QueueSendEvent $event)
 {
     try {
         $handle = $event->getHandle();
         $now = $event->getTimeout();
         # restrict selection of to a locked job, with matching handle.
         # job who's lockout is valid (lockout time <= now)
         # only pick jobs that are in waiting state (ADD,ERROR)
         $result = $this->gateway->selectQuery()->start()->filterByStateAdd()->filterByStateErrorPassedRetryWait($now)->filterByLockout($handle)->filterByLockTimmerAfter($now)->limit($event->getLimit())->orderByDateAdded()->end()->find();
         if (count($result) > 0) {
             $event->setResult($result);
         }
     } catch (DBALGatewayException $e) {
         throw new LaterJobException($e->getMessage(), 0, $e);
     }
 }
Beispiel #2
0
 public function testQueueSendEvent()
 {
     $handle = '4b336e15-cac0-3307-8b81-f1de26e6c383';
     $timeout = new DateTime();
     $limit = 5;
     $result = new \ArrayIterator(array());
     $send = new QueueSendEvent($handle, $timeout, $limit);
     $send->setResult($result);
     $this->assertEquals($handle, $send->getHandle());
     $this->assertEquals($timeout, $send->getTimeout());
     $this->assertEquals($limit, $send->getLimit());
     $this->assertEquals($result, $send->getResult());
 }
 /**
  *  Log events that occur from queue
  *
  *  @access public
  *  @param QueueSendEvent $event 
  */
 public function logQueueSendEvent(QueueSendEvent $event)
 {
     $this->log->info('QueueSendEvent:: Sending jobs to worker', array('handle' => $event->getHandle(), 'limit' => $event->getLimit(), 'timeout' => $event->getTimeout()));
 }
 /**
  *  Log events that occur from queue
  *
  *  @access public
  *  @param QueueSendEvent $event 
  */
 public function logQueueSendEvent(QueueSendEvent $event)
 {
     $this->output->writeln('QueueSendEvent:: Sending jobs to worker ' . json_encode(array('handle' => $event->getHandle(), 'limit' => $event->getLimit(), 'timeout' => $event->getTimeout())));
 }