/** * @param SchedulerEvent $event */ public function onSchedule(SchedulerEvent $event) { $schedule = $event->getSchedule(); if ($schedule instanceof Schedule) { $this->logger->debug('Process schedule {schedule}', array('schedule' => $schedule)); if ($job = $schedule->getJob()) { $message = new Message($job->getType(), $job->getTicket(), $job->getTicket()); $this->queueEngine->produce($message); return; } $this->logger->error('There is no job associated with this schedule {schedule}', array('schedule' => $schedule)); } }
/** * @param JobInterface $job * @throws \Exception */ protected function publishJob(JobInterface $job) { $message = new Message($job->getType(), $job->getTicket()); try { $this->producer->produce($message); } catch (\Exception $e) { $this->logger->critical(sprintf('Failed to publish message for job %s (Error: %s)', $job->getTicket(), $e->getMessage()), ['job' => $job, 'exception' => $e]); throw $e; } }