spring-boot-kafka
Pet project for publishing / subscribing messages
Quickstart for Apache Kafka (Mac)
- Install the latest version of Apache Kafka using Brew package manager
brew install kafka
- Start Apache ZooKeeper server
brew services start zookeeper
- Start the Kafka server
brew services start kafka
- Create a topic
cd usr/local/Cellar/kafka/2.0.0/bin/
sh kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic myTopic
- Start a command line consumer
sh kafka-console-consumer --bootstrap-server localhost:9092 --topic myTopic --from-beginning
Quickstart for Apache Kafka (Windows)
- Download the latest version of Apache Kafka
- Start Apache ZooKeeper server
$ bin/windows/zookeeper-server-start.bat config/zookeeper.properties
- Start the Kafka server
$ bin/windows/kafka-server-start.bat config/server.properties
- Create a topic
$ bin/windows/kafka-topics.bat --create --zookeeper localhost:2181 \
--replication-factor 1 --partitions 1 --topic myTopic
- Start a command line consumer
$ bin/windows/kafka-console-consumer.bat --bootstrap-server localhost:9092 --topic myTopic --from-beginning
Run the app
$ gradlew bootRun
> ./gradlew bootRun
Testing the app
curl -X POST http://localhost:8080/kafka/publish/HelloWorldMessage
curl -d '{"payload": "This is another test message", "date": "2018-11-18T18:25:43.511Z"}' \
> -H "Content-Type: application/json" -X POST http://localhost:8080/kafka/publish/