Example #1
0
 /**
  * @param ConsumeEvent $event
  */
 public function onMessageConsumed(ConsumeEvent $event)
 {
     $envelope = $event->getEnvelope();
     $this->output->writeln(sprintf('<comment>[%s]</comment> processed with result: <info>%s</info>', $envelope->getDeliveryTag(), json_encode($event->getResult())));
     // see if batch is completed
     if (++$this->processed % $this->batchSize === 0) {
         $this->flush();
     }
     try {
         foreach ($this->limiters as $limiter) {
             $limiter->limitReached($this);
         }
     } catch (LimitReachedException $e) {
         $this->output->writeln($e->getMessage(), OutputInterface::VERBOSITY_VERBOSE);
         $event->stopConsuming();
     }
     // cool down
     usleep($this->coolDownTime);
 }
 /**
  * @param EnvelopeInterface $envelope
  * @param \Exception        $exception
  */
 public function __construct(EnvelopeInterface $envelope, \Exception $exception)
 {
     parent::__construct($envelope);
     $this->exception = $exception;
 }