Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kafka Maven Dependencies

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?

like image 211
nikel Avatar asked Feb 17 '16 11:02

nikel


People also ask

Is Kafka UDP or TCP?

Kafka uses a binary protocol over TCP. The protocol defines all APIs as request response message pairs.

Is Kafka written in C++?

modern-cpp-kafka is a header-only C++ library that uses idiomatic C++ features to provide a safe, efficient, and easy way of producing and consuming Kafka messages.

What is producer in Kafka?

The Kafka producer is conceptually much simpler than the consumer since it has no need for group coordination. A producer partitioner maps each message to a topic partition, and the producer sends a produce request to the leader of that partition.

What is Kafka spring boot?

The Spring for Apache Kafka (spring-kafka) project applies core Spring concepts to the development of Kafka-based messaging solutions. It provides a "template" as a high-level abstraction for sending messages. It also provides support for Message-driven POJOs with @KafkaListener annotations and a "listener container".


1 Answers

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.

like image 116
Martin Avatar answered Nov 16 '22 00:11

Martin