CAMEL-23761: Add SqsProducerDelayedQueueIT for the delayed queue pattern - #26395
Conversation
…usage
The SqsProducerDelayedQueueIT test verifies the delayed queue pattern:
a queue is created with DELAY_SECONDS=20, a message is sent to it, and
reception must take at least 20 seconds.
The root cause of the failure: the receive endpoint used
defaultVisibilityTimeout=0 which calls SetQueueAttributes({VISIBILITY_TIMEOUT:0}).
On Localstack, this resets DELAY_SECONDS to 0, defeating the delay.
Fix: use visibilityTimeout=0 (per-request ReceiveMessage timeout) instead
of defaultVisibilityTimeout=0 (queue-level attribute). This avoids calling
SetQueueAttributes and preserves the queue's DELAY_SECONDS attribute.
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
gnodet-bot
left a comment
There was a problem hiding this comment.
Solid test — the visibilityTimeout vs defaultVisibilityTimeout fix is correct (verified from source: visibilityTimeout maps to ReceiveMessage.visibilityTimeout per-request, while defaultVisibilityTimeout maps to SetQueueAttributes(VISIBILITY_TIMEOUT) which clobbers DELAY_SECONDS on LocalStack). One naming nit below.
This review was generated by an AI agent, Hermès on behalf of @gnodet.
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| class SqsProducerDelayedQueueIT extends Aws2SQSBaseTest { |
There was a problem hiding this comment.
💡 Naming convention: All 12 existing tests in this package use the *LocalstackIT suffix (SqsConsumerLocalstackIT, SqsProducerAutoCreateQueueLocalstackIT, etc.). Consider renaming to SqsProducerDelayedQueueLocalstackIT for consistency.
| class SqsProducerDelayedQueueIT extends Aws2SQSBaseTest { | |
| class SqsProducerDelayedQueueLocalstackIT extends Aws2SQSBaseTest { |
There was a problem hiding this comment.
Localstack is no more used, it would be better to rename the other tests
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
🔬 Scalpel shadow comparison — Scalpel: 1 tested, 0 compile-only — current: 10 all testedMaveniverse Scalpel detected 1 affected modules (current approach: 10). Modules only in current approach (9)
Skip-tests mode would test 1 modules (1 direct + 0 downstream), skip tests for 0 (generated code, meta-modules) Modules Scalpel would test (1)
All tested modules (10 modules, 1m 47s total)Total reactor time: 1m 47s
Top 20 slowest modules:
|
apupier
left a comment
There was a problem hiding this comment.
the title is wrong. The test is not "fixed" as it is a new one created.
If it is a correct analysis, where it needs be fixed is the corresponding one on Spring Boot project. It seems strange that this kind of modifications woudl have allowed to have the test working one day at all on Spring boot project. it would be better to analyze deeper there
oscerd
left a comment
There was a problem hiding this comment.
LGTM. I verified the distinction against the aws2-sqs source: visibilityTimeout is applied per-request on the ReceiveMessageRequest (Sqs2Consumer), while defaultVisibilityTimeout writes the queue-level VISIBILITY_TIMEOUT attribute via SetQueueAttributes (Sqs2Endpoint) — so for a delayed-queue IT the per-request visibilityTimeout is the correct option and avoids mutating the queue. Test-only, AssertJ + Awaitility, no Thread.sleep.
Minor: since this adds a new IT rather than editing an existing one, the title's "Fix ..." reads a touch oddly (the commit's "Add ..." is more accurate) — not important. CI (build 17/25) was still pending when I looked; worth confirming green before merge.
Reviewed with Claude Code (Opus 4.8) on behalf of @oscerd. This is an AI-generated review and may contain inaccuracies; please verify before applying.
|
Thanks @apupier for the deep-dive request — you were right to push on this. Analysis of the Spring Boot situation: The Spring Boot The two parameters are semantically distinct:
Title fix: Updated to "Add SqsProducerDelayedQueueIT" as requested. Spring Boot fix: Opened apache/camel-spring-boot#1976 which applies the same |
Summary
Adds
SqsProducerDelayedQueueIT— an integration test for the SQS delayed queue pattern — and fixes thevisibilityTimeoutusage that caused the test to fail.Root Cause
The test from the reporter's branch (
apupier/camel:23761-sqsDelayedQueue) useddefaultVisibilityTimeout=0on the receive endpoint URL. This parameter maps to the queue-levelVISIBILITY_TIMEOUTattribute and causes Camel to callSetQueueAttributes({VISIBILITY_TIMEOUT: 0})when the endpoint initializes.On Localstack,
SetQueueAttributeswithVISIBILITY_TIMEOUT=0inadvertently resetsDELAY_SECONDSto 0, destroying the 20-second delay that was set when the queue was created. This explains the failure:actual: 2L >= 20L.The two parameters are distinct:
defaultVisibilityTimeout→SetQueueAttributes(VISIBILITY_TIMEOUT)— modifies the queue's attribute permanentlyvisibilityTimeout→ReceiveMessage(VisibilityTimeout)— per-request timeout, does not callSetQueueAttributesFix
In
receiveMessageFromQueue, replacedefaultVisibilityTimeout=0withvisibilityTimeout=0. The per-request visibility timeout of 0 seconds achieves the same effect (message becomes immediately re-visible after reading, allowing the Awaitility poll loop to re-attempt) without modifying the queue'sDELAY_SECONDSattribute viaSetQueueAttributes.Test
SqsProducerDelayedQueueIT.delayedQueue():DELAY_SECONDS=20viaautoCreateQueue=true&delayQueue=true&delaySeconds=20Localstack-backed test; requires the
localstack-sqsservice.References
apupier/camel:23761-sqsDelayedQueueHermes Agent (Claude Sonnet 4.6) on behalf of Guillaume Nodet