Example #1
0
 public function listen()
 {
     if ($this->closed) {
         throw new BadMethodCallException('This listener object is closed and cannot receive any more messages.');
     }
     while ($envelope = $this->queue->get()) {
         $domain_event = Notification::getEventFromBody($envelope->getType(), $envelope->getBody());
         if ($this->listensTo($envelope->getType())) {
             $this->handle($domain_event);
         }
         if ($this->stop) {
             return;
         }
     }
 }