Skip to content

Instantly share code, notes, and snippets.

@miguno
Last active December 14, 2015 21:19
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miguno/5150416 to your computer and use it in GitHub Desktop.
Save miguno/5150416 to your computer and use it in GitHub Desktop.
Building Apache Kafka 0.8 (trunk) for Scala 2.9.2

Building Apache Kafka 0.8 (trunk) for Scala 2.9.2

Instructions below based on:

Download and build

$ git clone git@github.com:miguno/kafka.git
$ cd kafka
# this branch of mine includes a patched bin/kafka-run-class.sh
$ git checkout -b scala-2.9.2 remotes/origin/scala-2.9.2
$ ./sbt update
$ ./sbt "++2.9.2 package"

Start the server daemons

# ZooKeeper
$ bin/zookeeper-server-start.sh config/zookeeper.properties

# Kafka broker
$ bin/kafka-server-start.sh config/server.properties

Create a topic called "zerg.hydra"

$ bin/kafka-topics.sh --zookeeper localhost:2181 --create --topic zerg.hydra --partitions 1 --replication-factor 1
$ bin/kafka-topics.sh --zookeeper localhost:2181 --list
<snipp>
zerg.hydra
</snipp>

Start a producer

Start a console producer:

$ bin/kafka-console-producer.sh --broker-list localhost:9092 --sync --topic zerg.hydra

You can now enter new messages, one per line.

Start a consumer

Start a console consumer:

$ bin/kafka-console-consumer.sh --zookeeper localhost:2181 --topic zerg.hydra --from-beginning

The consumer will see a new message whenever you enter a message in the producer above.

Notes

  • Kafka persists its topics in the log directory /tmp/kafka-logs (default location; see config/server.properties)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment