A demo spring boot application to send and receive message from
apache kafka using spring cloud stream apache kakfa libraries
- Compile the project
mvn clean package -DskipTests
This will build the jar file and also generates the docker image.
Change the username in <repository>
field in pom.xml under plugins
tab so that the docker image created will have your username.\
Or you can manually build the docker image using
docker build -t <image name> .
- Push the docker image to dockerhub
docker push <image name>:<tag>
- Note down the tag of the docker image and enter the same in
spring-cloud-stream-kafka.yml
so that kubernetes can download the image
- Run the command
kubectl apply -f spring-cloud-stream-kafka.yaml
This will create both deployment and service
- Create ingress rules to access the service
kubectl apply -f ingress.yaml
- Now you can access the endpoints
To send a message to kafka, open the below link in your browser
http://<IP address of kubernetes cluster master>/greetings/sendmessage?message=helloworld
Or
http://<IP address of kubernetes cluster master>/greetings/send/helloworld
- Retrieve all the message sent using
http://<IP address of kubernetes cluster master>/greetings/readmessage