Skip to content

ImGdevel/Kafka

Repository files navigation

Spring Kafka Study

Spring Boot 기반으로 Kafka 메시징 흐름을 실습하고, 같은 인터페이스로 Redis Streams까지 비교하는 기록 저장소 입니다.


Wiki

학습/운영 메모는 Wiki에 정리한다.


모듈 구성

  • infra-message-queue: 메시지 발행 인터페이스와 Kafka/Redis 구현
  • kafka-study: Kafka 학습용 API, listener, DLT, 트랜잭션 실습 코드
  • kafka-redis-compare: Redis Streams 비교 실습 코드
  • kafka-notification: Producer 앱과 Worker 앱을 분리한 알림 전송 E2E 실습

빠른 실행

# 1) 인프라 실행
docker compose up -d

# 2) Kafka 실습 앱 실행
./gradlew :kafka-study:bootRun

# 3) 메시지 발행
curl -X POST http://localhost:8080/api/messages \
  -H "Content-Type: application/json" \
  -d '{"message":"hello kafka","key":"user-1"}'

kafka-notification E2E 실행

# 1) Kafka + notification 앱 실행
docker compose --profile notification up --build -d

# 2) 알림 요청 발행
curl -X POST http://localhost:8082/api/notifications \
  -H "Content-Type: application/json" \
  -d '{
    "channel":"EMAIL",
    "recipient":"user@example.com",
    "subject":"welcome",
    "body":"hello",
    "templateCode":"WELCOME"
  }'

# 3) 워커 로그 확인
docker compose logs notification-worker-app --tail=100

실패 경로 확인:

curl -X POST http://localhost:8082/api/notifications \
  -H "Content-Type: application/json" \
  -d '{
    "channel":"EMAIL",
    "recipient":"user@example.com",
    "subject":"retry",
    "body":"force failure",
    "templateCode":"FAIL_ALWAYS"
  }'

비교 실행

# Redis Streams 비교 앱
./gradlew :kafka-redis-compare:bootRun

curl -X POST http://localhost:8081/api/messages \
  -H "Content-Type: application/json" \
  -d '{"message":"redis-test"}'

참고

About

Spring Boot 기반으로 Kafka 메시징 흐름을 실습하고, 같은 인터페이스로 Redis Streams까지 비교한 기록 공간입니다

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors