k1729p / Study05

Home Page:https://github.com/k1729p/Portfolio

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Study05 README Contents

Research the Kafka Broker and Spring Cloud Stream


In the Docker container 'spr-kafka' runs Kafka Server with single Kafka Broker.

This is the Spring Cloud Stream application with the Apache Kafka Binder.
The Apache Kafka Binder implementation maps each destination to an Apache Kafka topic.

The sections of this project:

  1. Docker Build
  2. Sender, Processor, Receiver
  3. Kafka Scripts


Java source code. Packages in modules 'kafka-sender', 'kafka-processor', 'kafka-receiver':

module 'kafka-sender' application sources :  kp
module 'kafka-sender' test sources :  kp.sender
module 'kafka-processor' application sources :  kp
module 'kafka-processor' test sources :  kp.processor
module 'kafka-receiver' application sources :  kp
module 'kafka-receiver' test sources :  kp.receiver


Java API Documentation ●  Java Test API Documentation


❶ Docker Build

Action:

1. With batch file "01 Docker build and run.bat" build the image and
start the container with the application.

1.1. Docker image is built using these files:
Dockerfile-processor, Dockerfile-receiver, Dockerfile-sender, and compose.yaml.


The screenshot of the created Docker containers.

Back to the top of the page


❷ Sender, Processor, Receiver


Docker containers for SpringBoot applications: sender, processor, and receiver

2.1. The Sender is configured in application.properties.
The container spr-sender sends Box to the destination 'kp-1'.
The 'Supplier' creation method in SpringBoot configuration: kp.sender.KpSender::sendBox.


The log from the container spr-sender.

2.2. The Processor is configured in application.properties.
The container spr-processor processes Box from the destination 'kp-1' to the destination 'kp-2'.
The 'Function' creation method in SpringBoot configuration: kp.processor.KpProcessor::processBox.


The log from the container spr-processor.

2.3. The Receiver is configured in application.properties.
The container spr-receiver receives Box from the destination 'kp-2'.
The 'Consumer' creation method in SpringBoot configuration: kp.receiver.KpReceiver::receiveBox.


The log from the container spr-receiver.

Back to the top of the page


❸ Kafka Scripts

Action:

1. With batch file "02 Kafka list topics.bat" run in Docker the Kafka script for topic listing.
2. With batch file "03 Kafka consume.bat" run in Docker the Kafka consumer console on topic 'kp-2'.

3.1. The batch file "02 Kafka list topics.bat".
The screenshot of the console log from the run of the batch file "02 Kafka list topics.bat".

3.2. The batch file "03 Kafka consume.bat".


The console log from the run of the batch file "03 Kafka consume.bat".

Back to the top of the page