啟動生產者命令:
kafka-console-producer.bat --broker-list localhost:9092 --topic haha
啟動消費者:
kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic haha --from-beginning
kafka 配置文件:
############################# 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://localhost: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 # 外部代理地址 advertised.listeners=PLAINTEXT://localhost:9092 # Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details #listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL
解決辦法:
消費者代碼:
kafka-console-consumer.bat --bootstrap-server PLAINTEXT://localhost:9092 --topic haha --from-beginning
疑問:?
這里比較奇怪; 生產者沒有加PLAINTEXT:// 能夠正常啟動 在消費者居然能夠報錯? 詭異
kafka 版本:"
kafka_2.13-2.4.0\kafka-logs"