/** * @param Command $command * @param \Exception $exception * @return void */ public function onDispatchFailed(Command $command, \Exception $exception) { $message = 'Dispatch failed!'; if ($exception instanceof NoCommandHandlerException) { $message = 'Dead letter message encountered!'; } $this->logger->error($message, ['type' => get_class($command), 'command' => $this->converter->objectToArray($command), 'exception' => $exception->getMessage()]); }
/** * @param string $identity * @param Document $document * @return void */ public function upsert(string $identity, Document $document) { $converted = $this->converter->objectToArray($document); if ($this->collection->count([$this->identityField => $identity]) > 0) { $this->collection->replaceOne([$this->identityField => $identity], $converted); } else { $this->collection->insertOne($converted); } }
/** * @param Event $event */ public function onDispatchFailed(Event $event) { $this->logger->warning('Dead letter event encountered', ['type' => get_class($event), 'event' => $this->converter->objectToArray($event)]); }