Kafka\SimpleProduce::setTopic PHP Method

setTopic() public method

set topic
public setTopic ( $topicName, integer $partitionId ) : kafka\Produce
$topicName
$partitionId integer
return kafka\Produce
    public function setTopic($topicName, $partitionId = 0)
    {
        $this->topic = $topicName;
        $this->partition = $partitionId;
        $host = $this->client->getHostByPartition($topicName, $partitionId);
        $stream = $this->client->getStream($host);
        $conn = $stream['stream'];
        $this->encoder = new \Kafka\Protocol\Encoder($conn);
        if ((int) $this->requiredAck !== 0) {
            // get broker response
            $this->decoder = new \Kafka\Protocol\Decoder($conn);
        }
        return $this;
    }