/**
* get produce server offset
*
* @param string $topicName
* @param integer $partitionId
* @access public
* @return int
*/
public function getProduceOffset($timeLine = self::LAST_OFFSET)
{
$topicName = $this->topicName;
$partitionId = $this->partitionId;
$requestData = array('data' => array(array('topic_name' => $this->topicName, 'partitions' => array(array('partition_id' => $this->partitionId, 'time' => $timeLine, 'max_offset' => 1)))));
$this->encoder->offsetRequest($requestData);
$result = $this->decoder->offsetResponse();
$this->client->freeStream($this->streamKey);
if (!isset($result[$topicName][$partitionId]['offset'])) {
if (isset($result[$topicName][$partitionId]['errCode'])) {
throw new \Kafka\Exception(\Kafka\Protocol\Decoder::getError($result[$topicName][$partitionId]['errCode']));
} else {
throw new \Kafka\Exception('get offset failed. topic name:' . $this->topicName . ' partitionId: ' . $this->partitionId);
}
}
return array_shift($result[$topicName][$partitionId]['offset']);
}