Example #1
0
 private function doProcessMessage(CaplKernelInterface $kernel, Message $message)
 {
     try {
         $processor = $kernel->getAsyncMessageProcessor($message->getProcessorName());
         if (!$processor instanceof ProcessorInterface) {
             throw new \RuntimeException("invalid processor");
         }
         $processor->preProcess($message->getPayload());
         $processor->process($message->getPayload());
         $processor->postProcess($message->getPayload());
         $this->worker->ack();
         $this->writeDebug("ACKED [{$message->getId()}]", array('capl' => array('processor' => get_class($processor), 'queueName' => $this->queueName)));
     } catch (\Exception $e) {
         $this->worker->nack($this->options['requeueOnError']);
         $this->writeError("REJECTED [{$message->getId()}] in " . get_class($processor), array('capl' => array('processor' => get_class($processor), 'queueName' => $this->queueName, 'exception' => $e->__toString())));
     }
 }