Ejemplo n.º 1
0
 /**
  * @param AMQPMessage $msg
  * @return bool
  */
 public function execute(AMQPMessage $msg)
 {
     try {
         $body = json_decode($msg->body);
         if (empty($body) || !property_exists($body, 'notificationId')) {
             $this->log('Invalid notification');
             return true;
         }
         $notificationId = $body->notificationId;
         $notification = $this->getNotification($notificationId);
         $this->dispatcher->sendNotification($notification);
         $responseHandler = $this->dispatcher->getResponseHandler();
         $responseHandler->handleResponseCollection();
         $this->processInvalidRecipients();
         if ($this->isDelivered()) {
             $this->notificationProvider->markDelivered($notificationId);
         } else {
             $this->notificationProvider->markFailed($notificationId);
         }
         return true;
     } catch (NotFoundException $e) {
         $this->log($e->getMessage());
         return true;
     } catch (\Exception $e) {
         fwrite(STDERR, sprintf("Exception: %s", $e->getMessage()));
         return false;
     }
 }