Spring Boot 2.0 App
This is an example how to use Apache Kafka with a Spring Boot Application, there are two main classes, the Sender, and the Receiver which are used to Produce and Consume Kafka Message, this implementation is using CLOUDKARAFKA as Kafka Server and the SASL_SSL security protocol.
There is a Rest Service used to send a message to the Kafka Server and also there is a KafkaListener class which is receiving all the messages published on one topic.
- Register on https://www.cloudkarafka.com/ and get the Credential to get access its Kafka Server.
- Maven
- Java 8: Any compliant JVM should work.
Capabilities are provided through dependencies in the pom.xml file and the application.properties for the main properties.
The ports are set to the defaults of 8080 for http.
The Kafka configuration properties are in application.properties, there you can find all the CloudKarafka credentials you need full fill in order to configure the access to the Kafka Server
To build and run the application:
mvn clean compile install
java -jar ./target/kafka-connector-0.0.1-SNAPSHOT.jar
The application exposes the following endpoints:
- Kafka Connector endpoint:
<host>:<port>/kafka/produce
e.g. [POST]ย http://localhost:8080/kafka/produce Send in the Body the Message
The Consumer is logging in the console all the received messages