RdKafka::addBrokers

(PECL rdkafka >= 0.9.1)

RdKafka::addBrokersAdd brokers

Description

public RdKafka::addBrokers ( string $broker_list ) : integer

Adds one or more brokers to the kafka handle's list of initial boostrap brokers.

Additional brokers will be discovered automatically as soon as rdkafka connects to a broker by querying the broker metadata.

If a broker name resolves to multiple addresses (and possibly address families) all will be used for connection attempts in round-robin fashion.

Parameters

broker_list

Comma-separated list of brokers in the format: <broker1>,<broker2>,...

Each broker is in either the host or URL based format:

  • <host>:[<port>]
  • <proto>://<host>[:<port>]

<proto> is either PLAINTEXT, SSL, SASL, or SASL_PLAINTEXT.

The two formats can be mixed but ultimately the value of the security.protocol config property decides what brokers are allowed.

Examples:

  • "broker1:10000,broker2"
  • "SSL://broker3:9000,ssl://broker2"

Note:

Brokers may also be defined with the metadata.broker.list or bootstrap.servers configuration property (preferred method).

Return Values

Returns the number of brokers successfully added.

Examples

Example #1 RdKafka::addBrokers() example

<?php
$kafka
->addBrokers("broker1:10000,broker2");

$kafka->addBrokers("SSL://broker3:9000,ssl://broker2");
?>