コード例 #1
0
ファイル: AmqpExchangeListener.php プロジェクト: loobee/ddd
 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;
         }
     }
 }
コード例 #2
0
ファイル: AmqpMessageProducer.php プロジェクト: loobee/ddd
 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()]);
 }
コード例 #3
0
 /**
  * @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);
 }