/** * Next message * * Method that will fetch (if we need to, according to $hasFetch) and return * the next message. * * @return Boolean|Message */ public function nextMessage() { if (time() - 10 > $this->lastCommitOffset) { $this->commitOffset(); } if (!$this->hasFetched) { $this->hasFetched = $this->consumer->fetch($this->topic, $this->partition, $this->offset, $this->maxFetchSize); if (!$this->hasFetched) { return false; } } $message = $this->consumer->nextMessage(); $this->hasCommits = true; if (!$message) { $this->hasFetched = false; } else { $this->offset = $this->consumer->getWatermark(); } return $message; }