Skip to content

jakehoward/grokking-kafka

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

grokking-kafka

Convincing my brain cells to form a quorum.

None of this code is in any way intended for production use. It's completely untested and is only intended to aid learning at the first stage of using Kafka.

Starting Kafka

This is from https://kafka.apache.org/quickstart, ideally we could spin up a docker container but for some reason the networking wasn't playing ball. Will come back to that (https://github.com/wurstmeister/kafka-docker, https://github.com/wurstmeister/kafka-docker/wiki/Connectivity).

  1. Download Kafka from: https://kafka.apache.org/downloads
  2. Download the sha and check it, e.g: gpg --print-md SHA512 ~/Downloads/kafka_2.12-2.5.0.tgz
  3. Unzip it: tar -xf kafka_2.12-2.5.0.tgz
  4. Open two tabs, in one start zookeeper: bin/zookeeper-server-start.sh config/zookeeper.properties
  5. In the other start kafka: bin/kafka-server-start.sh config/server.properties

Usage

Run with lein:

lein run {command-name}

Build uberjar and run it:

lein uberjar
java -jar target/uberjar/grokking-kafka-0.1.0-SNAPSHOT-standalone.jar {command-name}

where command name is one of the available commands. Run with no args to get a list of available commands printed to the console.

Example working usage:

lein run basic-pub-sub

When the program starts, it will publish a stream of randomly generated events to one topic and updates to a user profile to another (full profile, not diffs). Each of the commands will then consume it in some way to demonstrate how the consumption of topics works in Kafka.

Useful commands

See where your consumer has got to in the logs:

bin/kafka-run-class.sh kafka.admin.ConsumerGroupCommand --group event-stream-consumer --bootstrap-server localhost:9092 --describe

List topics:

bin/kafka-topics.sh --list --bootstrap-server localhost:9092

Consume topic:

bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic event-count-by-user --from-beginning

Guides/Docs/Resources

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published