/**
  * {@inheritDoc}
  */
 public function replay($events, $queueName)
 {
     $adapter = $this->queueFactory->create($queueName);
     foreach ($events as $domainMessage) {
         $msg = json_encode($this->serializer->serialize($domainMessage));
         $adapter->publish($msg);
     }
     $adapter->publish('finished');
 }
 /**
  * @param string $exchangeName
  * @param string $queueName
  */
 public function listen($queueName)
 {
     $adapter = $this->queueFactory->create($queueName);
     $eventBus = $this->eventBus;
     $callback = function ($msg) use($eventBus, $adapter) {
         if ($msg->body == 'finished') {
             $msg->delivery_info['channel']->basic_ack($msg->delivery_info['delivery_tag']);
             $adapter->delete();
             exit;
         }
         $this->eventBus->publish($this->getDomainEventStream($msg->body));
     };
     $adapter->listen($callback);
 }