https://github.com/up2code/demo-kafka
Demostrate basic usage of Kafka in Spring boot
https://github.com/up2code/demo-kafka
java kafka kafka-consumer kafka-producer spring-boot
Last synced: about 2 months ago
JSON representation
Demostrate basic usage of Kafka in Spring boot
- Host: GitHub
- URL: https://github.com/up2code/demo-kafka
- Owner: up2code
- Created: 2021-09-28T10:35:07.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-10-19T04:36:26.000Z (over 4 years ago)
- Last Synced: 2025-04-10T09:07:35.789Z (about 1 year ago)
- Topics: java, kafka, kafka-consumer, kafka-producer, spring-boot
- Language: Java
- Homepage:
- Size: 56.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Demo Basic Apache Kafka with Spring Boot
## demo-kafka-producer
Provide simple APIs for demonstrate how spring boot produce messages to Kafka
```
[POST] /publish
[POST] /publish/random
```
See also in `demo-kafka-producer`
## demo-kafka-consumer
For demonstrate how app consume message from Kafka in Spring boot.
Simply start with mvn command or build as jar and run as multiple consumers.
See also in `demo-kafka-consumer`
## Startup Kafka in Local
```
$ docker-compose up -d zookeeper broker
```
#### Create a topic
```
$ docker exec broker \
kafka-topics --bootstrap-server broker:9092 \
--create \
--partitions 3 \
--topic test-topic
```
#### List topics
```
$ docker exec broker kafka-topics --list --zookeeper zookeeper:2181
```
#### Write messages to the topic
```
$ docker exec --interactive --tty broker \
kafka-console-producer --bootstrap-server broker:9092 \
--topic test-topic
```
#### Read messages from the topic
```
$ docker exec --interactive --tty broker \
kafka-console-consumer --bootstrap-server broker:9092 \
--topic test-topic \
--from-beginning
```
#### Kafka with UI
Check [OffsetExplorer](https://www.kafkatool.com/download.html)