ivanovaolya / spring-boot-kafka

Pet project for publishing / subscribing messages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

spring-boot-kafka

Pet project for publishing / subscribing messages

Quickstart for Apache Kafka (Mac)

  1. Install the latest version of Apache Kafka using Brew package manager
brew install kafka
  1. Start Apache ZooKeeper server
brew services start zookeeper
  1. Start the Kafka server
brew services start kafka
  1. 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
  1. Start a command line consumer
sh kafka-console-consumer --bootstrap-server localhost:9092 --topic myTopic --from-beginning

Quickstart for Apache Kafka (Windows)

  1. Download the latest version of Apache Kafka
  2. Start Apache ZooKeeper server
$ bin/windows/zookeeper-server-start.bat config/zookeeper.properties
  1. Start the Kafka server
$ bin/windows/kafka-server-start.bat config/server.properties
  1. Create a topic
$ bin/windows/kafka-topics.bat --create --zookeeper localhost:2181 \ 
  --replication-factor 1 --partitions 1 --topic myTopic
  1. 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/

About

Pet project for publishing / subscribing messages


Languages

Language:Java 100.0%