The keycloak project ended with four open questions that design could not
settle. A two-VM lab was built to answer them by measurement, and this is
that material: 26 experiments, 125 raw command outputs, 22 browser captures.
Follows the import procedure in README.md.
source/ the originating repository verbatim — 78 documents, 28 SVGs,
8 manifests, plus .source-revision recording the commit
final/ the SSOT
document.md 729 lines written from the 29 experiment documents, not
concatenated: what was predicted, what was measured, and
where the measurement itself was wrong
evidence/raw 125 outputs, flattened to <experiment>__<file> because
the originals collided (01-baseline.txt appeared three
times) and the audit only globs the top level
evidence/meta one per raw file; command and exitCode are null and the
README says why rather than inventing them
evidence/browser 22 captures
assets/ three diagrams through techviz
.techviz/ their VizSpecs
A separate project rather than an addition to keycloak: the B-layer answers
that project's four questions, but the A, C and D layers are about cluster
failure, SSO and operations, and one document.md should hold one subject.
The four question records there can point here through 관계.
Recorded rather than papered over: only three of the 28 diagrams were
remade. The repository forbids hand-drawn SVG and forbids titles inside the
canvas; all 28 originals carry both, so converting them is redrawing, not
reformatting. They stay in source/ and the gap is written into the document.
verify-pipeline.py passes. audit-records.py reports no issues.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
68 lines
3.9 KiB
Markdown
68 lines
3.9 KiB
Markdown
---
|
|
kind: CONCEPT
|
|
slug: messaging-policy-c03
|
|
title: 거절이 전송 전에 끝나는 것이 설계의 핵심이다
|
|
topic: state-machines-and-ownership
|
|
project: clean-architecture-backend-template
|
|
status: 게시 전
|
|
sourceRevision: 21234e38cdb9a926cbc92bb97a2aee2e4a7d2916
|
|
rootTreeNode: concept:messaging-policy-c03
|
|
evidenceCapturedOn: 2026-09-01
|
|
assets:
|
|
- key: messaging-policy-c03
|
|
file: ../../../final/evidence/rendered/messaging-policy-c03.svg
|
|
- key: messaging-policy-c03-diagram
|
|
file: ../../../final/assets/diagrams/messaging-policy-c03.svg
|
|
evidence:
|
|
- ../../../final/evidence/raw/messaging-policy-c03.txt
|
|
source:
|
|
- 원본 분석 절은 analysis/messaging/messaging-policy.md#L135 이다.
|
|
module: messaging-policy
|
|
---
|
|
|
|
# 거절이 전송 전에 끝나는 것이 설계의 핵심이다
|
|
|
|
`DestinationProfileValidator.validate`가 15가지 모순을 순서대로 거절하고, `admit`은 네 단계를 전송 전에 통과시킨다.
|
|
|
|
## 관계
|
|
|
|
- **구성 오류는 한 예외 타입과 안정 코드로 보고한다**
|
|
같은 분석 리프에서 끌어낸 규칙이다.
|
|
- **저장소 밖 문서를 절 번호로 인용하지 않는다**
|
|
같은 분석 리프에서 끌어낸 규칙이다.
|
|
- **부팅 경로의 알고리즘 복잡도는 문서화한다**
|
|
같은 분석 리프에서 끌어낸 규칙이다.
|
|
|
|
## 본문
|
|
|
|
<!-- body:start -->
|
|
|
|
`DestinationProfileValidator.validate`가 프로파일 하나에 대해 15가지 모순을 순서대로 거절한다. 11번과 12번이 짝이다 — 전자는 목적지 수준 동시성(`orderingScope == DESTINATION && consumer.concurrency > 1`), 후자는 순서 단위 안 동시성(`isOrdered() && maxInFlightPerOrderingUnit > 1`). 둘 다 있어야 "순서 보장"이 실제로 성립한다.
|
|
|
|
## 사이클 탐색이 전역 집합이 아니라 경로를 쓰는 이유
|
|
|
|
`Edge` enum이 `RETRY`와 `DEAD_LETTER` 둘을 갖고, `walk`가 두 간선을 동시에 따라간다. **`onPath`가 전역 방문 집합이 아니라 현재 경로다.** 각 분기마다 `new LinkedHashSet<>(onPath)`로 복사하므로 형제 분기가 서로의 방문 기록을 오염시키지 않는다. 다이아몬드(A→C, B→C)는 사이클이 아니고, 그것을 사이클로 판정하면 정상 구성이 부팅에 실패한다. 테스트가 두 경우를 각각 붙든다 — `aMixedEdgeCycleIsRejected`(retry/DLQ 교대 사이클 거절)와 `aSharedDeadLetterIsNotACycle`(다이아몬드 허용). 미등록 목적지도 여기서 잡힌다 — `anUnregisteredRetryDestinationIsRejected`.
|
|
|
|
## 어디에도 기록되지 않은 비용
|
|
|
|
매 분기마다 `onPath`와 `path`를 복사하므로 시간·공간이 경로 수에 지수적이다. 목적지 수가 수십 개인 정상 구성에서는 문제가 없지만, 이 성질이 어디에도 기록되지 않았다 — §17의 P3.
|
|
|
|
## admit의 검사 순서
|
|
|
|
:::evidence key="messaging-policy-c03-diagram" alt="payload 검사와 종료 여부와 목적지 슬롯과 전역 semaphore 가 왼쪽에서 오른쪽으로 이어지는 구조" caption="admit 의 검사 순서" zoom="false"
|
|
:::
|
|
|
|
1. `payloadGuard.checkPayload` → 초과면 `MessageTooLargeException`
|
|
1. `acceptingNewWork` 확인 → 종료 중이면 `MessageBackpressureException("SHUTTING_DOWN")`
|
|
1. `reserve(destination)` — 목적지별 CAS 루프 → 초과면 `DESTINATION_IN_FLIGHT_LIMIT_EXCEEDED`
|
|
1. `limiter.tryAcquire()` — 프로세스 전역 semaphore, 유한 대기 → 실패면 목적지 슬롯 **반납 후** `IN_FLIGHT_LIMIT_EXCEEDED`
|
|
|
|
## MessageTooLargeException 참조 위치
|
|
|
|
:::evidence key="messaging-policy-c03" alt="코드베이스에서 MessageTooLargeException 를 검색한 출력 12줄. 이 기록이 세는 참조가 그 출력에 그대로 보인다." caption="MessageTooLargeException 코드베이스 검색 — 12줄 · exit 0" zoom="true"
|
|
:::
|
|
|
|
**거절이 모호하지 않은 것이 설계의 핵심**이다 — 두 거절 모두 전송 전에 일어난다.
|
|
|
|
<!-- body:end -->
|