Kafka Maven Dependencies

nikel picture nikel · Feb 17, 2016 · Viewed 18.1k times · Source

What's the difference between the below two dependencies? Do i really need the first one to make a consumer or producer app?

<dependencies>
    <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka_2.9.2</artifactId>
        <version>0.8.2.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.kafka</groupId>
        <artifactId>kafka-clients</artifactId>
        <version>0.8.2.1</version>
    </dependency>
</dependencies>

My Producer works fine with just the first one , but the consumer needs the second one.

I had thought the "kafka-clients" artifact would work for both producer and consumer. But looks like "kafka.consumer.Consumer" comes from the other dependency. Why is there a difference?

Also, why is the first artifact named as kafka_2.9.2? i.e why is a version identifier in the name?

Answer

Martin picture Martin · Feb 17, 2016

If you want to use the latest producer and consumer API then the correct Maven coordinates are:

<dependency>
    <groupId>org.apache.kafka</groupId>
    <artifactId>kafka-clients</artifactId>
    <version>0.9.0.0</version>
</dependency>

See the API documentation for more.