Skip to content

CAMEL-23761: Fix BaseSqs.receiveMessageFromQueue to use visibilityTimeout instead of defaultVisibilityTimeout - #1976

Merged
gnodet merged 1 commit into
apache:mainfrom
gnodet:camel-23761-fix-sqs-delayed-queue-test
Sep 14, 2026
Merged

gnodet merged 1 commit into
apache:mainfrom
gnodet:camel-23761-fix-sqs-delayed-queue-test

Conversation

@gnodet

@gnodet gnodet commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes BaseSqs.receiveMessageFromQueue to use visibilityTimeout=0 instead of defaultVisibilityTimeout=0, correcting the root cause of SqsDelayedQueueTest.delayedQueue() failing.

Root Cause

BaseSqs.receiveMessageFromQueue built its consumer endpoint URI with defaultVisibilityTimeout=0. This parameter maps to the queue-level VISIBILITY_TIMEOUT attribute in AWS SQS, causing Camel to call SetQueueAttributes({VISIBILITY_TIMEOUT: 0}) when the endpoint initializes.

On LocalStack, SetQueueAttributes with VISIBILITY_TIMEOUT=0 inadvertently resets DELAY_SECONDS to 0 as well, overwriting the 20-second delay set during queue creation. The message therefore becomes available immediately, and the Duration.between(start, now).getSeconds() >= delay assertion fails.

The two parameters are distinct:

  • defaultVisibilityTimeoutSetQueueAttributes(VISIBILITY_TIMEOUT) — queue-level attribute, called during endpoint initialization, can overwrite other queue attributes on LocalStack
  • visibilityTimeoutReceiveMessage(VisibilityTimeout) — per-request timeout, does not call SetQueueAttributes, does not affect DELAY_SECONDS

Fix

Replace defaultVisibilityTimeout=0 with visibilityTimeout=0 in BaseSqs.receiveMessageFromQueue. The per-request timeout achieves the same intent (messages re-become visible immediately for the next poll) without modifying the queue's DELAY_SECONDS attribute.

Notes

  • SqsDelayedQueueTest is still annotated @DisabledIfSystemProperty(named = "ci.env.name", matches = "github.com") since Docker is not available in the GitHub Actions environment. That annotation is unchanged — this PR fixes only the correctness of the test helper.
  • The companion fix in apache/camel (adding the test there with the correct parameter from the start): CAMEL-23761: Add SqsProducerDelayedQueueIT for the delayed queue pattern camel#26395

References


Hermes Agent (Claude Sonnet 4.6) on behalf of Guillaume Nodet

…eout

The receiveMessageFromQueue helper used defaultVisibilityTimeout=0 on the
consumer endpoint URI, which maps to SetQueueAttributes(VISIBILITY_TIMEOUT=0).
On LocalStack, this call inadvertently resets DELAY_SECONDS to 0, defeating
the delayed-queue configuration set during queue creation.

Fix: replace defaultVisibilityTimeout=0 with visibilityTimeout=0.
- visibilityTimeout: per-request ReceiveMessage timeout — does NOT call
  SetQueueAttributes, does not affect queue attributes.
- defaultVisibilityTimeout: queue-level VISIBILITY_TIMEOUT attribute —
  calls SetQueueAttributes, can corrupt DELAY_SECONDS on LocalStack.

This makes SqsDelayedQueueTest.delayedQueue() correctly observe the 20s
delay after the message is sent.

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
@gnodet
gnodet merged commit 62aab3f into apache:main Sep 14, 2026
4 checks passed
@gnodet
gnodet deleted the camel-23761-fix-sqs-delayed-queue-test branch September 14, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants