Esempio n. 1
0
 /**
  * Publish domain events in stream.
  *
  * @param DomainEventStreamInterface $stream
  *
  * @return array
  * @throws \Exception
  */
 private function publish(DomainEventStreamInterface $stream)
 {
     $results = array();
     foreach ($stream->all() as $domain) {
         try {
             $results[] = $this->eventBus->dispatch($domain->getPayload());
             $this->storage->append($this->table, $domain, 'OK');
             $this->broadcast($domain->getPayload(), array('status' => 'OK', 'exception' => null));
         } catch (\Exception $e) {
             $metadata = array('code' => $e->getCode(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'message' => $e->getMessage());
             $this->storage->append($this->table, $domain, 'ERROR', $metadata);
             $this->broadcast($domain->getPayload(), array('status' => 'ERROR', 'exception' => $metadata));
             throw $e;
         }
     }
     return $results;
 }
 /**
  * {@inheritdoc}
  */
 public function replay(DomainEventStreamInterface $stream)
 {
     foreach ($stream->all() as $message) {
         $this->version++;
         $this->handleRecursively($message->getPayload());
     }
 }