Beispiel #1
0
 /**
  * Until there is a real extension point to doing invoked stuff, this can be used
  * by wrapping the invoke method.
  *
  * @param Envelope $envelope
  * @param Queue    $queue
  *
  * @throws \Exception
  * @throws \Throwable
  */
 public function invoke(Envelope $envelope, Queue $queue)
 {
     try {
         $this->dispatcher->dispatch(BernardEvents::INVOKE, new EnvelopeEvent($envelope, $queue));
         // for 5.3 support where a function name is not a callable
         call_user_func($this->router->map($envelope), $envelope->getMessage());
         // We successfully processed the message.
         $queue->acknowledge($envelope);
         $this->dispatcher->dispatch(BernardEvents::ACKNOWLEDGE, new EnvelopeEvent($envelope, $queue));
     } catch (\Throwable $error) {
         $this->rejectDispatch($error, $envelope, $queue);
     } catch (\Exception $exception) {
         $this->rejectDispatch($exception, $envelope, $queue);
     }
 }
Beispiel #2
0
 /**
  * Until there is a real extension point to doing invoked stuff, this can be used
  * by wrapping the invoke method.
  *
  * @param Envelope $envelope
  * @param Queue    $queue
  */
 public function invoke(Envelope $envelope, Queue $queue)
 {
     try {
         $this->dispatcher->dispatch('bernard.invoke', new EnvelopeEvent($envelope, $queue));
         // for 5.3 support where a function name is not a callable
         call_user_func($this->router->map($envelope), $envelope->getMessage());
         // We successfully processed the message.
         $queue->acknowledge($envelope);
         $this->dispatcher->dispatch('bernard.acknowledge', new EnvelopeEvent($envelope, $queue));
     } catch (\Exception $e) {
         // Make sure the exception is not interfering.
         // Previously failing jobs handling have been moved to a middleware.
         //
         // Emit an event to let others log that exception
         $this->dispatcher->dispatch('bernard.reject', new RejectEnvelopeEvent($envelope, $queue, $e));
     }
 }