From 0eb84c899b8fbdbce36b5efda0fd4620a42fa3d6 Mon Sep 17 00:00:00 2001 From: arnel Date: Mon, 4 Sep 2023 12:43:58 +0200 Subject: [PATCH] modified README.md --- README.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/README.md b/README.md index 5793794..cb8a3bf 100644 --- a/README.md +++ b/README.md @@ -1 +1,52 @@ # kafka-demo +This project is just a sample demonstration inspired by question "How do +we monitor a kafka stream with a OneAgent and see the data on Dynatrace?" + +# setup +You need to [download](https://kafka.apache.org/downloads) kafka on your +device. For this demo project the binary Scala 2.12 - kafka_2.12-3.5.1.tgz +was downloaded, therefore kafka version 3.5.1 is used. + +# run +First you have to start and run the zookeeper server, afterwards the kafka server +and finally the consumers. +```sh +bin/zookeeper-server-start.sh config/zookeeper.properties +bin/kafka-server-start.sh config/server.properties +bin/kafka-console-consumer.sh --topic TOPIC_INSTANCE --from-beginning --bootstrap-server localhost:9092 +bin/kafka-console-consumer.sh --topic TOPIC_INSTANCE_JSON --from-beginning --bootstrap-server localhost:9092 +``` +`NOTE: MAKE SURE YOU FOLLOW THE ORDER!` + +Run this project by starting the KafkaDemoApplication! + +# demo +Once everything is running open the following link in your browser: +http://localhost:8080/api/v1/kafka/publish + +If you want to produce a message then you can add the message query parameter and +your value as following: +http://localhost:8080/api/v1/kafka/publish?message=Madrid +http://localhost:8080/api/v1/kafka/publish?message=London +http://localhost:8080/api/v1/kafka/publish?=Vienna +http://localhost:8080/api/v1/kafka/publish?=Pizza + +On one of the consumers you will see the messages! + +It is possible to send a JSON Object. To do that you will have to send a POST +request via e.g. Postman. In Postman choose the POST method and use this link: +http://localhost:8080/api/v1/kafka/publish + +Afterward under Body, pick raw and instead Text pick JSON. In the body section +you can add the following object: +```JSON +{ + "id": 1, + "vin": "V09JHY4", + "location": "New York" +} +``` +Send. + +You should be able to see the data in one of the consumers! If you encounter +any warnings after starting the consumers you can ignore them! \ No newline at end of file