Hello Play Kafka
Cloud Setup
-
Install the Kafka plugin into the Heroku CLI
heroku plugins:install heroku-kafka
-
Wait for Kafka to be provisioned:
heroku kafka:wait -a YOUR_APP
-
Add a new Kafka topic:
heroku kafka:topics:create RandomNumbers --partitions 32 -a YOUR_APP
-
Add a new Kafka consumer group:
heroku kafka:consumer-groups:create main
-
Watch the Kafka log
heroku kafka:topics:tail RandomNumbers -a YOUR_APP
-
Check out the random numbers:
heroku open -a YOUR_APP
Local Setup
This uses the same Kafka system as above.
-
Clone the source:
git clone https://github.com/jamesward/hello-play-kafka
-
Associate the local source with your Heroku app:
heroku git:remote -a YOUR_APP
-
Setup a
.env
file with the necessary info:heroku config -s > .env
-
Run the web app:
set -o allexport source .env set +o allexport ./sbt ~run
-
Run the worker:
set -o allexport source .env set +o allexport ./sbt "runMain workers.RandomNumbers"
-
Check out the app: http://localhost:9000