Apache Kafka example error: Failed to send message after 3 tries

后端 未结 8 1538
南旧
南旧 2021-02-19 08:39

I am running this kafka producer example mentioned in its site

The code:

public class TestProducer {

    public static void main(String[] args) {
               


        
8条回答
  •  别跟我提以往
    2021-02-19 09:33

    I got the error from apache kafka:

    bin/kafka-console-producer.sh --broker-list localhost:9092 --topic test
    SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    SLF4J: Defaulting to no-operation (NOP) logger implementation
    SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details
    

    My Setup:

    OS: Ubuntu 14.04
    sbt: sbt launcher version 0.13.5
    scala: Scala code runner version 2.9.2
    

    Was able to fix it with these commands:

    cd /home/el/apachekafka/kafka_2.10-0.8.1.1/libs
    wget http://www.slf4j.org/dist/slf4j-1.7.7.tar.gz
    tar -xvf slf4j-1.7.7.tar.gz
    cd /home/el/apachekafka/kafka_2.10-0.8.1.1/libs/slf4j-1.7.7
    cp slf4j-api-1.7.7.jar ..
    cp slf4j-nop-1.7.7.jar ..
    

    Then re-run the command and the producer doesn't throw any error.

提交回复
热议问题