[문제]
- ParticipantRegistered 이벤트 처리 시 StaleObjectStateException 발생
- 100개의 이벤트가 동시에 발행되어 EventStats 동시 업데이트 충돌
- TransactionRequiredException 발생 (트랜잭션 컨텍스트 부재)
[해결]
1. 비관적 락(Pessimistic Lock) 적용
- EventStatsRepository에 findByEventIdWithLock 메서드 추가
- PESSIMISTIC_WRITE 락으로 읽는 순간부터 다른 트랜잭션 차단
2. 트랜잭션 추가
- 모든 Consumer 메서드에 @Transactional 어노테이션 추가
- EventCreatedConsumer, ParticipantRegisteredConsumer, DistributionCompletedConsumer
3. 이벤트 발행 속도 조절
- SampleDataLoader에서 10개마다 100ms 대기
- 동시성 충돌 빈도 감소
[수정 파일]
- EventStatsRepository.java: 비관적 락 메서드 추가
- ParticipantRegisteredConsumer.java: @Transactional 추가, 락 메서드 사용
- DistributionCompletedConsumer.java: @Transactional 추가, 락 메서드 사용
- EventCreatedConsumer.java: @Transactional 추가
- SampleDataLoader.java: 이벤트 발행 속도 조절
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- content-service/build.gradle: bootJar 파일명 설정 추가
- deployment/container/Dockerfile-backend: 백엔드 서비스 Docker 이미지 파일
- deployment/container/docker-compose.yml: Docker Compose 설정 (환경변수 포함)
- deployment/container/build-and-run.sh: 자동화 빌드 및 배포 스크립트
- deployment/container/build-image.md: 상세 배포 가이드 문서
주요 환경변수:
- JWT_SECRET: 32자 이상 JWT 서명 키 (JWT 오류 해결)
- REDIS/KAFKA: 외부 서버 연결 정보
- REPLICATE_API_TOKEN: Stable Diffusion API 토큰
- AZURE_STORAGE_CONNECTION_STRING: Azure Blob Storage 연결
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com>
- Gradle 빌드 캐시 파일 제외 (.gitignore 업데이트)
- Kafka 통합 테스트 구현 (AIJobConsumerIntegrationTest)
- 단위 테스트 추가 (Controller, Service 레이어)
- IntelliJ 실행 프로파일 자동 생성 도구 추가
- Kafka 테스트 배치 스크립트 추가
- Redis 캐시 설정 개선
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- EventController: /api/events -> /api/v1/events
- JobController: /api/jobs -> /api/v1/jobs
- 모든 API 엔드포인트 테스트 완료
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- ParticipationController: @RequestMapping("/api/v1") 추가
- WinnerController: @RequestMapping("/api/v1") 추가
- 모든 API 경로가 /api/v1/* 형태로 변경됨
변경된 API 경로:
- POST /api/v1/events/{eventId}/participate
- GET /api/v1/events/{eventId}/participants
- GET /api/v1/events/{eventId}/participants/{participantId}
- POST /api/v1/events/{eventId}/draw-winners
- GET /api/v1/events/{eventId}/winners
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- DDL_AUTO를 none으로 변경하여 Hibernate 자동 스키마 변경 중지
- channel 필드를 nullable = true로 임시 변경
- 기존 데이터 마이그레이션 후 nullable = false로 변경 예정
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Participant 엔티티에 channel 필드 추가 (기본값: SNS)
- ParticipationRequest/Response DTO에 channel 필드 추가
- ParticipantRegisteredEvent에 channel 필드 추가
- ParticipationService에서 channel 정보 전달
- 참여 경로 분석 및 마케팅 효과 측정 가능
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- build.gradle에서 spring-kafka 의존성 삭제
- application*.yml에서 Kafka 설정 제거
- content-service는 Redis에 데이터를 저장하는 역할만 수행
- 서비스 간 비동기 통신이 필요 없어 Kafka 불필요
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- ParticipantId 생성 로직 수정 (prt_yyyyMMdd_xxx 형식)
- 보너스 응모권 계산 로직 수정 (매장 방문 시 5개)
- Mock 설정 추가 (ParticipationServiceUnitTest)
- Kafka 통합 테스트 Embedded Kafka로 전환 (일시적으로 비활성화)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- API 경로를 /content에서 /api/v1/content로 변경
- REST API 버저닝 패턴 적용 (/api/v1/서비스명)
- ContentController.java의 @RequestMapping 수정
- OpenAPI 명세서 경로 업데이트 (7개 엔드포인트)
- Javadoc 주석의 API 경로 정보 업데이트
영향 범위: content-service만 수정, common 모듈 변경 없음
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
## 변경사항
### 보안 강화
- gradle.properties를 .gitignore에 추가 (로컬 환경 설정 제외)
### 공통 모듈
- ErrorCode에 Legacy 호환용 에러 코드 추가 (NOT_FOUND, INVALID_INPUT_VALUE)
### Event Service
- hibernate-types 라이브러리 제거 (Hibernate 6 네이티브 지원으로 대체)
### Kafka 인프라 추가
- Kafka 메시지 DTO 3개 추가
* AIEventGenerationJobMessage: AI 이벤트 생성 작업 메시지
* EventCreatedMessage: 이벤트 생성 완료 메시지
* ImageGenerationJobMessage: 이미지 생성 작업 메시지
- Kafka Producer/Consumer 3개 추가
* EventKafkaProducer: 이벤트 메시지 발행
* AIJobKafkaConsumer: AI 작업 메시지 소비
* ImageJobKafkaConsumer: 이미지 작업 메시지 소비
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- WinnerController에 Swagger 어노테이션 추가 (Operation, Parameter, ParameterObject)
- 당첨자 목록 조회 API 기본 정렬 설정 (winnerRank ASC, size=20)
- ParticipationService에서 이벤트/참여자 구분 로직 개선
- 이벤트 없음: EventNotFoundException 발생
- 참여자 없음: ParticipantNotFoundException 발생
- EventCacheService 제거 (Redis 기반 검증에서 DB 기반 검증으로 변경)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
주요 변경사항:
- UserPrincipal 및 JWT 인증 시스템을 Long에서 UUID로 변경
- Event 엔티티 JPA 설정 최적화 (Lazy loading 및 fetch 전략 개선)
- 개발 환경용 DevAuthenticationFilter 추가 (User Service 구현 전까지 임시 사용)
- EventServiceApplication 문법 오류 수정
- Hibernate multiple bags 문제 해결 (List를 Set으로 변경)
기술 세부사항:
- common/UserPrincipal: Long → UUID 타입 변경, @Builder 어노테이션 추가
- common/JwtTokenProvider: UUID 지원 추가
- event-service/Event: Set 컬렉션 사용, Lazy loading 최적화
- event-service/EventService: Hibernate.initialize()로 컬렉션 초기화
- event-service/EventRepository: fetch join 쿼리 최적화
- event-service/SecurityConfig: DevAuthenticationFilter 통합
테스트 결과:
- 모든 Event CRUD API 정상 작동 확인
- PostgreSQL 연결 정상
- 비즈니스 로직 검증 정상 작동
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Redis 연동 구현 (패스워드 인증 지원)
- RedisConfig에 password 설정 추가
- RedisGateway에 ContentReader/Writer 인터페이스 구현
- application-dev.yml 프로파일 추가
- 이미지 삭제 기능 구현
- DeleteImageUseCase 인터페이스 추가
- DeleteImageService 구현
- ContentWriter.deleteImageById() 메서드 추가
- RedisGateway 및 MockRedisGateway 삭제 로직 구현
- 이미지 필터링 기능 추가
- GetImageListUseCase에 style, platform 파라미터 추가
- GetImageListService에 Stream filter 로직 구현
- ContentController에서 String → Enum 변환 처리
- Mock 서비스 dev 프로파일 지원
- MockGenerateImagesService dev 프로파일 추가
- MockRegenerateImageService dev 프로파일 추가
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
변경 사항:
1. EventStats에 totalViews 필드 추가 (모든 채널 노출 수 합계)
2. DistributionCompletedEvent에 expectedViews 필드 추가
3. DistributionCompletedConsumer 개선:
- ChannelStats.impressions에 expectedViews 저장
- updateTotalViews() 메서드로 전체 노출 수 집계
4. SampleDataLoader에 채널별 예상 노출 수 설정:
- 이벤트1: 총 20,000 (우리동네TV 5K, 지니TV 10K, 링고비즈 3K, SNS 2K)
- 이벤트2: 총 14,000
- 이벤트3: 총 6,000
설계 다이어그램과 일치:
- 채널별 예상 노출 수 저장
- 총 노출 수 실시간 집계
- 멱등성 및 캐시 무효화 유지
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- 다른 서비스 개발자들의 운영 토픽과 충돌 방지
- MVP용 샘플 토픽: sample.event.created, sample.participant.registered, sample.distribution.completed
- KafkaTopicConfig, SampleDataLoader, 3개 Consumer 모두 업데이트
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>