This demo is a single page web site which takes a form input, sends it as a json XHR request to a simple Scala Controller in Play Framework 2.5, which then pipes it to a Kafka Unified Log. A listener then receives a notification from Kafka via an event stream via Reactive Kafka and sends it immediately back to the browser as an HTML5 EventSource event.
It's also possible also send text messages to the browser and listen to the event stream from the command line using the default command line producer/consumer that comes with Kafka.
This demo does not do anything fancy with topics, partitions groups---all messages go to and from all listening clients.
Install Confluent Kafka, then:
Terminal #1
$ ./bin/zookeeper-server-start ./etc/kafka/zookeeper.properties
Terminal #2
$ ./bin/kafka-server-start ./etc/kafka/server.properties
Terminal #3
$ ./bin/schema-registry-start ./etc/schema-registry/schema-registry.properties
$ sbt run
Wait for the internet to download.
Open a browser at: http://localhost:9000/
You can send a message directly to the browser
./bin/kafka-console-producer --broker-list localhost:9092 --topic topic1
This should send the text to the web client.
View all messages:
./bin/kafka-console-consumer --topic topic1 --zookeeper localhost:2181 --from-beginning