Contribution · Spring Cloud AWS · AWS SDK v2
Spring Cloud AWS — SQS IGNORE QueueNotFoundStrategy
Spring Cloud AWS 3.x의 SQS 컨테이너에 IGNORE QueueNotFoundStrategy를 추가해, 큐가 없을 때 listener를 조용히 skip하고 application context 부팅을 차단하지 않도록 복원했습니다. spring-cloud-starter-aws-messaging (2.x) 의 기본 동작이었으나 3.x로 넘어오면서 사라져 다수의 사용자가 v2→v3 migration pain으로 보고한 항목입니다.
문제 — GH-1143
3.x의 기존 두 전략은 FAIL (큐 없으면 throw, application startup 차단)과 CREATE (큐 없으면 CreateQueue 호출, sqs:CreateQueue IAM 필요 + 외부 관리 큐 설정과 충돌 가능). 둘 다 안 맞는 케이스가 흔함 — optional feature queue, multi-region rollout에서 일부 region에만 queue가 만들어진 상태, deployment마다 queue 존재 여부가 다른 케이스. 이 때 listener는 그냥 skip하고 앱은 정상 부팅돼야 함. 2.x의 spring-cloud-starter-aws-messaging는 이게 기본 동작이었음.
수정 — typed signal 도입
메인테이너(@tomazfernandes)가 명시한 우려: "graciously handle the error thrown by the QueueAttributesResolver and interrupting container startup". 해결은 새 exception 타입을 신호로 사용해 source가 distinguish할 수 있게 하는 방향:
- 새
QueueNotFoundException클래스 (QueueAttributesResolvingException의 subtype) 도입. 기존 catch 사이트는 parent 타입으로 그대로 잡힘. QueueAttributesResolver.handleException:QueueDoesNotExistException+ IGNORE일 때만 새 exception으로 failed future. CREATE / FAIL 경로 unchanged.QueueAttributesResolver.wrapException: 새 exception만 unwrap 통과 (generic 재포장 방지).AbstractSqsMessageSource.doStart:CompletionExceptioncause가 새 exception이면skipped플래그 + warning + early return.AbstractSqsMessageSource.doPollForMessages:skipped면 empty future 즉시 반환.
회귀 테스트
QueueAttributesResolverIntegrationTests#shouldIgnoreQueueWhenStrategyIsIgnore 추가. LocalStack에 존재하지 않는 큐 + IGNORE 전략 → QueueNotFoundException (cause = QueueDoesNotExistException) surface 검증. 같은 클래스의 FAIL/CREATE 기존 6개 테스트 모두 그대로 통과 — RetryableTopic 시나리오 무영향.
PR 목록
관련 자료
- Projectawspring/spring-cloud-aws
- Authorgithub.com/BK202503
- Blogdevbilllab.tistory.com