/**
  * Retrieves a queue worker
  *
  * @param \josegonzalez\Queuesadilla\Engine\Base $engine engine to run
  * @param \Psr\Log\LoggerInterface $logger logger
  * @return \josegonzalez\Queuesadilla\Worker\Base
  */
 public function getWorker($engine, $logger)
 {
     $worker = parent::getWorker($engine, $logger);
     $worker->attachListener('Worker.job.exception', function ($event) {
         $exception = $event->data['exception'];
         $exception->job = $event->data['job'];
         $sentryHandler = new SentryHandler();
         $sentryHandler->handle($exception);
     });
     $worker->attachListener('Worker.job.success', function ($event) {
         ConnectionManager::get('default')->disconnect();
     });
     $worker->attachListener('Worker.job.failure', function ($event) {
         $failedJob = $event->data['job'];
         $failedItem = $failedJob->item();
         $options = ['queue' => 'failed', 'failedJob' => $failedJob];
         Queue::push($failedItem['class'], $failedJob->data(), $options);
         ConnectionManager::get('default')->disconnect();
     });
     return $worker;
 }
Пример #2
0
 /**
  * Handle uncaught exceptions.
  *
  * @param \Exception $exception Exception instance.
  * @return void
  * @throws \Exception When renderer class not found
  * @see http://php.net/manual/en/function.set-exception-handler.php
  */
 public function handleException(Exception $exception)
 {
     $sentryHandler = new SentryHandler();
     $sentryHandler->handle($exception);
     return parent::handleException($exception);
 }
 /**
  * {@inheritDoc}
  */
 public function handleException($exception, $request, $response)
 {
     $sentryHandler = new SentryHandler();
     $sentryHandler->handle($exception);
     return parent::handleException($exception, $request, $response);
 }