This is to demonstrate two simple spring boot microservices which uses kafka to send and receive messages.
- Producer
- Consumer
- Docker-compose-files
- Postman
This is collection of postman api's for producer and consumer. Producer can send the messages in string format or json format. ProducerMsg contains sending information via string. ProducerInformation contains informationModel as Json data.
This contains two docker-compose files
- only zookeeper and kafka
- Entire application
Here producer uses Apache.kafka library KafkaProducer to send the information.
If you want to run producer in IDE, please change kafka.server=localhost:29092 in application.properties.
Consumer uses Apache kafka library KafkaConsumer to retrive messages from the kafka. Executors [Thread] is used to read the information from the kafka bus. Upon reading the information, it is placed in internal queue. This used when user try to do get request for messages. Upon performing get operation, messages in the queue are cleared.
If you want to run producer in IDE, please change kafka.server=localhost:29092 in application.properties.
Please pull the latest zookeeper and kafka images
docker pull confluentinc/cp-kafka
docker pull confluentinc/cp-zookeeper
Navigate to producer folder
./gradlew build -x test
docker build -t producer .
Navigate to consumer folder
./gradlew build -x test
docker build -t consumer .
Navigate to docker-compose-files
docker-compose up -d
Navigate to docker-compose-files
docker-compose down
Navigate to docker-compose-files
docker-compose -f docker-compose-only-kafka-zookeeper.yml up -d