Spring Cloud AWS · open
PR #1640 — GH-1143: Add IGNORE QueueNotFoundStrategy option for SQS
Spring Cloud AWS 3.x의 QueueNotFoundStrategy에 세 번째 옵션 IGNORE를 추가. SQS 큐가 startup 시점에 없을 때 warning 로그 + listener container의 source를 조용히 skip해 application context 부팅을 막지 않음. 2.x spring-cloud-starter-aws-messaging의 기본 동작을 3.x에 복원하는 패치. 4명 이상이 v2→v3 migration pain으로 보고한 이슈 #1143, 메인테이너 직접 "PRs welcome" 표명.
맥락
Spring Cloud AWS 3.x의 QueueNotFoundStrategy는 두 가지 — FAIL (큐 없으면 throw, application startup 차단) 또는 CREATE (큐 없으면 CreateQueue 호출, sqs:CreateQueue IAM 필요 + 외부 관리 큐 설정과 충돌 가능). 둘 다 안 맞는 사용 케이스가 있음 — 예: optional feature queue, multi-region rollout에서 큐가 아직 안 만들어진 상태, deployment마다 queue 존재 여부가 다른 경우. 이런 경우 listener는 그냥 skip하고 앱은 정상 부팅돼야 함. 2.x의 spring-cloud-starter-aws-messaging는 이게 기본 동작이었는데 3.x에서 사라지면서 migration pain이 생김 (이슈에 v2→v3 사용자 4명+ 보고).
설계 — typed signal로 분리
메인테이너 (@tomazfernandes) 의 우려: "graciously handle the error thrown by the QueueAttributesResolver and interrupting container startup". 핵심은 IGNORE 신호를 generic resolver 에러와 어떻게 분리해서 source가 catch할 수 있게 만드느냐. 답은 dedicated exception 타입:
- 새 클래스
QueueNotFoundException—QueueAttributesResolvingException의 subtype. 기존 catch 사이트는 그대로 동작 (parent 타입으로 잡힘), source는 subtype으로 distinguish 가능. QueueAttributesResolver.handleException:QueueDoesNotExistException+IGNORE일 때QueueNotFoundException으로 failed future 반환.CREATEpath는 unchanged.QueueAttributesResolver.wrapException:QueueNotFoundException만 unwrap 통과 (generic 재포장 방지). 다른 모든 exception은 종전 그대로QueueAttributesResolvingException으로 wrap.AbstractSqsMessageSource.doStart:CompletionExceptioncause가QueueNotFoundException이면skipped플래그 set + warning + early return (queueAttributes/queueUrl 안 set, conversion context 안 설정).AbstractSqsMessageSource.doPollForMessages:skipped면 즉시CompletableFuture.completedFuture(emptyList())— polling loop은 source 라이프타임 동안 no-op.
FAIL / CREATE / RetryableTopic은 손 안 댐
새 IGNORE constant만 새 branch를 탐. wrapException의 QueueNotFoundException 분기는 IGNORE에서만 생성되므로 다른 strategy / 다른 exception 경로에서는 종전과 동일한 QueueAttributesResolvingException이 떨어짐. 기존 회귀 테스트 6개 모두 동일 exception 타입을 그대로 받음을 LocalStack 통합 테스트로 확인.
회귀 테스트
QueueAttributesResolverIntegrationTests#shouldIgnoreQueueWhenStrategyIsIgnore 추가. 기존 #shouldNotCreateQueue 패턴 그대로 사용, LocalStack에 존재하지 않는 큐에 IGNORE 전략을 적용했을 때 QueueNotFoundException (cause = QueueDoesNotExistException)이 surface됨을 검증. 같은 클래스의 7개 테스트(FAIL/CREATE 케이스 포함) 모두 통과.
속성 바인딩
SqsProperties에서 QueueNotFoundStrategy enum을 직접 노출하고 있어 코드 변경 없이 spring.cloud.aws.sqs.queue-not-found-strategy=IGNORE로 바로 설정 가능. sqs.adoc 표 항목에 IGNORE 동작 설명 한 줄 추가.