feat(S15P11A705-290): Context→AI 요청 경로의 인메모리 큐를 Kafka로 교체 - #179
Draft
minyongP wants to merge 8 commits into
Draft
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
발행 실패는 삼킨다 — PENDING이 커밋되어 있어 재스캔이 복구한다(기존 의미론 유지). aiCallExecutor·@EnableAsync는 이 리스너 전용이었으므로 함께 제거한다. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
5xx·연결 실패는 백오프를 늘려 가며 재시도하고, 4xx·역직렬화 실패는 몇 번을 보내도 같으므로 재시도 없이 DLT로 직행한다. DLT 격리는 ERROR 로그로 남긴다 — 상태는 PENDING으로 남아 있어 최종 처분은 여전히 재스캔·Finalizer의 몫이다. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
at-least-once 전달에서 중복은 전제다. 걸러 내는 근거는 브로커가 아니라 진실의 원본인 ai.context_ai_state다 — 두 단계 모두 PENDING을 지났으면 생략한다. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
캐시된 컨텍스트들이 토픽·그룹을 공유하면 리밸런스 재전달이 다른 클래스의 '호출 없음' 검증 구간에 흘러든다. Hikari 풀도 5로 줄인다 — 컨텍스트가 하나 늘며 Postgres max_connections(100)를 넘겼다. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
요약
Record 저장 커밋 후 FastAPI 호출에 쓰던 인메모리 큐(
@Async+aiCallExecutor)를 Kafka 발행 → back 내부 컨슈머 경로로 교체합니다. FastAPI 계약과 재스캔 안전망은 그대로입니다. 브로커 선택(Kafka)의 근거와 트레이드오프, back#129의 AI 파트 질문 5개에 대한 답은 BD-48에 있습니다.Jira (필수)
관련 GitHub Issue (선택)
변경 사항
context-ai.process)에 발행 (ContextAiProcessPublisher). 발행 실패는 기존 의미론대로 삼키고(PENDING유지 → 재스캔 복구),max.block.ms=1000으로 브로커 장애가 요청 스레드를 붙잡는 상한을 걸었습니다ContextAiProcessConsumer)가 소비해 기존과 동일한POST /internal/v1/context/process호출 수행 — AI 파트 코드·계약 변경 없음@RetryableTopic재시도 토픽 체인(지수 백오프 1s→2s→4s), 4xx·역직렬화 실패는 DLT 직행, DLT 격리는 ERROR 로그ai.context_ai_state기준 — 두 단계 모두 PENDING을 지난 Context는 중복 전달을 생략aiCallExecutor·@EnableAsync제거(이 리스너 전용이었음),AiProcessClient에 던지는 진입점processOrThrow()추가(삼키는process()는 재스캔용 불변)compose.yaml에 Kafka(KRaft 단일 노드) 추가. 테스트: Testcontainersapache/kafka:4.1.0, 컨텍스트별 토픽·그룹 격리테스트 / 검증
./gradlew clean check --no-daemon— BUILD SUCCESSFUL (3m 52s, 테스트·checkstyle·jacoco 80% 게이트 포함)RED → GREEN (이 세션의 TDD 기록):
ContextAiKafkaPipelineTests.messageOnTheTopicReachesFastApiThroughTheConsumerFAILED (발행만 되고 호출 없음)serverErrorsExhaustTheRetryChainAndLandInTheDlt·badRequestGoesStraightToTheDltWithoutRetryFAILEDduplicateDeliveryForAnAlreadyHandledContextIsSkippedFAILED./gradlew test --tests ContextAiKafkaPipelineTests --tests ContextAiEnqueueTests— 13 tests, BUILD SUCCESSFULContextAiEnqueueTests8개(커밋-호출 순서·롤백·삭제 생략)가 새 경로 위에서 그대로 통과배경
리뷰 포인트
ContextAiProcessConsumer·AiRescanSchedulerJavadoc과 BD-48에 있습니다미결 / 후속
KAFKA_BOOTSTRAP_SERVERS주입 필요 (BD-46과 같은 원칙)docs/ai/spec/ai-integration.md4장이 인메모리 큐·@Async를 서술 — 갱신을 요청드립니다. 공용 계약10_MVP_기능범위§2(MQ 제외)는 back#129 합의로 대체 — docs 레포 후속 PR 필요/metricsprod 승격 승인 이후 후속. 안 B(완료 이벤트 역방향)는 별도 논의🤖 Generated with Claude Code