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); }
public function consumeStop($partition) { $this->consumerTopic->consumeStop($partition); $this->isConsuming = false; }
/** * @param ConsumerTopic $topic * @param $partition * @param $offset */ private function start(ConsumerTopic $topic, $partition, $offset) { if (!$this->isStarted) { $topic->consumeQueueStart($partition, $offset, $this->getQueue()); } }