简体   繁体   中英

How to use a different port for confluent-kafka?

I have a Kafka running in a port different to the default 9092.

How can I tell confluent-kafka to use that port? Because neither in the API documentation nor Github I see a "port" configuration, just the bootstrap server config, which is only to define the IP of the Kafka endpoint.

The bootstrap server parameter doesn't define only the IP. It's a list of Kafka endpoint defined as : separated by comma. So for example in your case if you have Kafka on a non standard port ie 9093 and on localhost the bootstrap server parameter can be localhost:9093.

You could see this https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md

it says the bootstrap.servers is alias for metadata.broker.list

And the metadata.broker.list description is :

Initial list of brokers as a CSV list of broker host or host:port. The application may also use rd_kafka_brokers_add() to add brokers during runtime. Type: string

Actully you could use this

{'bootstrap.server' : 'ip:your_host,...',
 ....
} 

as Kwargs to producer or consumer initiation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM