Reputation: 5233
While creating the producer I have to specify the broker port value.
For that, I need to configure that broker port value in 'server.properties' file.
What are these 'listeners' and 'advertised.listeners' parameters, and how can I configure them as broker port?
If broker port value is a mandatory, then why these parameters have commented?
If these parameters are automatically initializing from 'java.net.InetAddress.getCanonicalHostName()', then how can I specify those automatically initialized port values while creating a new producer?
Thanks.
############################# Socket Server Settings #############################
# The address the socket server listens on. It will get the value returned from
# java.net.InetAddress.getCanonicalHostName() if not configured.
# FORMAT:
# listeners = listener_name://host_name:port
# EXAMPLE:
# listeners = PLAINTEXT://your.host.name:9092
#listeners=PLAINTEXT://:9092
# Hostname and port the broker will advertise to producers and consumers. If not set,
# it uses the value for "listeners" if configured. Otherwise, it will use the value
# returned from java.net.InetAddress.getCanonicalHostName().
#advertised.listeners=PLAINTEXT://your.host.name:9092
Upvotes: 3
Views: 8249
Reputation: 34
If you do not set advertised.listeners
, it is the same as listeners
by default.
listeners
are used in the inside network IP, advertised.listeners
are used in the outside network IP. If you only need to use Kafka in the inside, you only need to configure listeners
.
listeners
are the parameters that the socketserver actually bind(). advertised.listeners
will stored in zk.
In inside Network, you can use the 192.168.0.10 to connected Kafka Broker.By outside network, so you should be config the advertised.listeners
# inside network IP, like that
listeners=PLAINTEXT://192.168.0.10:9092
# Public network ip, so you can connect the broker in any network
advertised.listeners=PLAINTEXT://xxx.xxx.xxx.xxx:9092
Other: The format of the parameter value is (protocol name)://(host name or ip):(port number)
protocol name PLAINTEXT
means clear text transmission,
protocol name SSL
means using SSL or TLS encrypted transmission, etc.
Upvotes: 1
Reputation: 191671
why these parameters have commented?
As the comments say, they have defaults
If these parameters are automatically initializing from 'java.net.InetAddress.getCanonicalHostName()', then how can I specify those automatically initialized port values while creating a new producer?
Default port is 9092, so you'd connect to that ip/hostname on port 9092.
What are these 'listeners' and 'advertised.listeners' parameters
https://www.confluent.io/blog/kafka-listeners-explained/
Upvotes: 1