-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
86ef429
commit 20f3051
Showing
5 changed files
with
86 additions
and
4 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
kafka-spring-boot/boot-concurrent-kafka-consumer/ReadMe.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Concurrent Kafka Consumer | ||
|
||
This project demonstrates a multi-threaded Kafka consumer approach using Spring Boot, with a dedicated implementation that processes messages concurrently across different threads. | ||
|
||
### Sequence Diagram | ||
|
||
|
||
|
||
### Format code | ||
|
||
```shell | ||
./mvnw spotless:apply | ||
``` | ||
|
||
### Run tests | ||
|
||
```shell | ||
./mvnw clean verify | ||
``` | ||
|
||
### Run locally | ||
|
||
```shell | ||
$ docker-compose -f docker/docker-compose.yml up -d | ||
$ ./mvnw spring-boot:run -Dspring-boot.run.profiles=local | ||
``` | ||
|
||
### Using Testcontainers at Development Time | ||
You can run `TestConcurrentKafkaConsumer.java` from your IDE directly. | ||
You can also run the application using Maven as follows: | ||
|
||
```shell | ||
./mvnw spring-boot:test-run | ||
``` | ||
|
||
|
||
### Useful Links | ||
* Actuator Endpoint: http://localhost:8080/actuator |
42 changes: 42 additions & 0 deletions
42
kafka-spring-boot/boot-concurrent-kafka-consumer/docker/docker-compose.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
services: | ||
|
||
broker: | ||
image: apache/kafka-native:3.8.1 | ||
hostname: broker | ||
ports: | ||
- "9092:9092" | ||
healthcheck: | ||
test: [ "CMD-SHELL", "nc -z localhost 9092" ] | ||
interval: 30s | ||
timeout: 5s | ||
retries: 3 | ||
environment: | ||
KAFKA_BROKER_ID: 1 | ||
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL:PLAINTEXT,EXTERNAL_HOST:PLAINTEXT,CONTROLLER:PLAINTEXT | ||
#Use two listeners with different names, it will force Kafka to communicate with itself via internal | ||
#listener when KAFKA_INTER_BROKER_LISTENER_NAME is set, otherwise Kafka will try to use the advertised listener | ||
KAFKA_LISTENERS: INTERNAL://broker:29092,EXTERNAL_HOST://0.0.0.0:9092,CONTROLLER://broker:9094 | ||
KAFKA_ADVERTISED_LISTENERS: INTERNAL://broker:29092,EXTERNAL_HOST://localhost:9092 | ||
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 | ||
KAFKA_OFFSETS_TOPIC_NUM_PARTITIONS: 32 | ||
KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0 | ||
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1 | ||
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1 | ||
KAFKA_PROCESS_ROLES: broker,controller | ||
KAFKA_NODE_ID: 1 | ||
KAFKA_CONTROLLER_QUORUM_VOTERS: 1@broker:9094 | ||
KAFKA_CONTROLLER_LISTENER_NAMES: CONTROLLER | ||
KAFKA_INTER_BROKER_LISTENER_NAME: INTERNAL | ||
KAFKA_LOG_FLUSH_INTERVAL_MESSAGES: 9223372036854775807 | ||
CLUSTER_ID: 4L6g3nShT-eMCtK--X86sw | ||
|
||
kafdrop: | ||
image: obsidiandynamics/kafdrop | ||
restart: "no" | ||
ports: | ||
- "9000:9000" | ||
environment: | ||
KAFKA_BROKERCONNECT: "broker:29092" | ||
depends_on: | ||
broker: | ||
condition: service_healthy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters