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; } } }
public function send($exchange_name, Notification $notification) { $this->exchange->publish($notification->getEventBody(), null, AMQP_NOPARAM, ['message_id' => $notification->getOccurredOn(), 'type' => $notification->getEventType(), 'timestamp' => $notification->getOccurredOn()->getTimestamp()]); }
/** * @param string $exchange_name * @param Notification $notification */ public function send($exchange_name, Notification $notification) { $this->channel($exchange_name)->basic_publish(new AMQPMessage($notification->getEventBody(), ['message_id' => $notification->getOccurredOn(), 'type' => $notification->getEventType(), 'timestamp' => $notification->getOccurredOn()->getTimestamp()]), $exchange_name); }