コード例 #1
0
ファイル: Topic.php プロジェクト: hauptmedia/php-kafka-bundle
 public function consume($partition)
 {
     if (!$this->consumers) {
         throw new \Exception("Topic " . $this->name . " has no registered consumers");
     }
     if (!$this->rdKafkaConsumerTopic) {
         throw new \Exception("Topic " . $this->name . " is not registered as consumer topic");
     }
     $this->rdKafkaConsumerTopic->consumeStart($partition, RD_KAFKA_OFFSET_BEGINNING);
     while ($message = $this->rdKafkaConsumerTopic->consume($partition, 10000)) {
         foreach ($this->consumers as $consumer) {
             $consumer->consume($message->topic_name, $message->partition, $message->offset, $message->key, $message->payload);
         }
     }
     $this->rdKafkaConsumerTopic->consumeStop($partition);
 }
コード例 #2
0
 public function consumeStop($partition)
 {
     $this->consumerTopic->consumeStop($partition);
     $this->isConsuming = false;
 }
コード例 #3
0
ファイル: Consumer.php プロジェクト: hellofresh/reagieren
 /**
  * @param ConsumerTopic $topic
  * @param $partition
  * @param $offset
  */
 private function start(ConsumerTopic $topic, $partition, $offset)
 {
     if (!$this->isStarted) {
         $topic->consumeQueueStart($partition, $offset, $this->getQueue());
     }
 }