[Kafka Cookbook] Building from Source

Kafka Binaries are available for download from http://kafka.apache.org/downloads.html. Many prefer to build from a source version. Let’s see how to build from the source. Building the source download Kafka Source can be downloaded from Downloads page http://kafka.apache.org/downloads.html Once downloaded, extract the artifact. Move to the extracted folder and execute following command $gradle $./gradlew releaseTarGz The […]

Continue reading


[Kafka Cookbook] Simple Consumer

In the last post we saw Simple Producer, now let’s take a look at a Simple Consumer. Please refer Simple Producer for Pre-conditions. Jumping to next step, lets quickly look at the code. import kafka.consumer.Consumer; import kafka.consumer.ConsumerIterator; import kafka.consumer.KafkaStream; import kafka.javaapi.consumer.ConsumerConnector; import org.apache.kafka.clients.consumer.ConsumerRecord; import org.apache.kafka.clients.consumer.ConsumerRecords; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Properties; /** * […]

Continue reading


[Kafka Cookboook] Simple Producer

Now that we have completed a Quick Start, let’s see how to write a basic Java Producer for Kafka. Pre-Conditions Kafka setup is up and running (including Zookeeper) If you are using Maven, here are the needed dependencies <dependency> <groupId>org.apache.kafka</groupId> <artifactId>kafka-clients</artifactId> <version>0.8.2.1</version> </dependency> <dependency> <groupId>org.apache.kafka</groupId> <artifactId>kafka_2.10</artifactId> <version>0.8.2.1</version> </dependency> The producer is going to be simple, […]

Continue reading