(PECL rdkafka >= 0.9.1)
RdKafka::addBrokers — Add brokers
$broker_list
) : integerAdds 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.
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
orbootstrap.servers
configuration property (preferred method).
Returns the number of brokers successfully added.
Example #1 RdKafka::addBrokers() example
<?php
$kafka->addBrokers("broker1:10000,broker2");
$kafka->addBrokers("SSL://broker3:9000,ssl://broker2");
?>