Skip to content

CAMEL-23761: Add SqsProducerDelayedQueueIT for the delayed queue pattern - #26395

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

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

Conversation

@gnodet

@gnodet gnodet commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds SqsProducerDelayedQueueIT — an integration test for the SQS delayed queue pattern — and fixes the visibilityTimeout usage that caused the test to fail.

Root Cause

The test from the reporter's branch (apupier/camel:23761-sqsDelayedQueue) used defaultVisibilityTimeout=0 on the receive endpoint URL. This parameter maps to the queue-level VISIBILITY_TIMEOUT attribute and causes Camel to call SetQueueAttributes({VISIBILITY_TIMEOUT: 0}) when the endpoint initializes.

On Localstack, SetQueueAttributes with VISIBILITY_TIMEOUT=0 inadvertently resets DELAY_SECONDS to 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:

  • defaultVisibilityTimeoutSetQueueAttributes(VISIBILITY_TIMEOUT) — modifies the queue's attribute permanently
  • visibilityTimeoutReceiveMessage(VisibilityTimeout) — per-request timeout, does not call SetQueueAttributes

Fix

In receiveMessageFromQueue, replace defaultVisibilityTimeout=0 with visibilityTimeout=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's DELAY_SECONDS attribute via SetQueueAttributes.

Test

SqsProducerDelayedQueueIT.delayedQueue():

  1. Creates a queue with DELAY_SECONDS=20 via autoCreateQueue=true&delayQueue=true&delaySeconds=20
  2. Sends a message to the queue
  3. Polls every 1s (up to 120s) until the message is received
  4. Asserts that ≥20 seconds elapsed before the message was available

Localstack-backed test; requires the localstack-sqs service.

References


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

…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 gnodet-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Naming convention: All 12 existing tests in this package use the *LocalstackIT suffix (SqsConsumerLocalstackIT, SqsProducerAutoCreateQueueLocalstackIT, etc.). Consider renaming to SqsProducerDelayedQueueLocalstackIT for consistency.

Suggested change
class SqsProducerDelayedQueueIT extends Aws2SQSBaseTest {
class SqsProducerDelayedQueueLocalstackIT extends Aws2SQSBaseTest {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Localstack is no more used, it would be better to rename the other tests

@github-actions

Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions

Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • components/camel-aws/camel-aws2-sqs

🔬 Scalpel shadow comparison — Scalpel: 1 tested, 0 compile-only — current: 10 all tested

Maveniverse Scalpel detected 1 affected modules (current approach: 10).

Modules only in current approach (9)
  • camel-aws2-eventbridge
  • camel-jbang-mcp
  • camel-jbang-plugin-mcp
  • camel-jbang-plugin-route-parser
  • camel-jbang-plugin-tui
  • camel-jbang-plugin-validate
  • camel-launcher-container
  • camel-yaml-dsl-validator
  • camel-yaml-dsl-validator-maven-plugin

Skip-tests mode would test 1 modules (1 direct + 0 downstream), skip tests for 0 (generated code, meta-modules)

Modules Scalpel would test (1)
  • camel-aws2-sqs

ℹ️ Shadow mode — Scalpel observes but does not affect test execution. Learn more

All tested modules (10 modules, 1m 47s total)

Total reactor time: 1m 47s

Module Duration Status
Camel :: JBang :: Plugin :: TUI 43.6s SUCCESS
Camel :: JBang :: MCP 35.4s SUCCESS
Camel :: AWS2 Eventbridge 11.9s SUCCESS
Camel :: YAML DSL :: Validator 5.4s SUCCESS
Camel :: YAML DSL :: Validator Maven Plugin 4.6s SUCCESS
Camel :: JBang :: Plugin :: Validate 2.6s SUCCESS
Camel :: Launcher :: Container 1.4s SUCCESS
Camel :: JBang :: Plugin :: Route Parser 1.3s SUCCESS
Camel :: JBang :: Plugin :: MCP 0.9s SUCCESS
Camel :: AWS2 SQS n/a

Top 20 slowest modules:

  • Camel :: JBang :: Plugin :: TUI (43.6s)
  • Camel :: JBang :: MCP (35.4s)
  • Camel :: AWS2 Eventbridge (11.9s)
  • Camel :: YAML DSL :: Validator (5.4s)
  • Camel :: YAML DSL :: Validator Maven Plugin (4.6s)
  • Camel :: JBang :: Plugin :: Validate (2.6s)
  • Camel :: Launcher :: Container (1.4s)
  • Camel :: JBang :: Plugin :: Route Parser (1.3s)
  • Camel :: JBang :: Plugin :: MCP (0.9s)

⚙️ View full build and test results

@apupier apupier left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 oscerd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@gnodet gnodet changed the title CAMEL-23761: Fix SqsProducerDelayedQueueIT - use visibilityTimeout instead of defaultVisibilityTimeout CAMEL-23761: Add SqsProducerDelayedQueueIT for the delayed queue pattern Sep 14, 2026
@gnodet

gnodet commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @apupier for the deep-dive request — you were right to push on this.

Analysis of the Spring Boot situation:

The Spring Boot SqsDelayedQueueTest uses the same buggy defaultVisibilityTimeout=0 in BaseSqs.receiveMessageFromQueue. The test has been annotated @DisabledIfSystemProperty(named = "ci.env.name", matches = "github.com") since December 2023 (commit 94102a5), so it has never run on CI in its current form and there is no evidence it ever passed with defaultVisibilityTimeout=0 against a modern LocalStack.

The two parameters are semantically distinct:

  • defaultVisibilityTimeout → maps to SetQueueAttributes(VISIBILITY_TIMEOUT), called during Sqs2Endpoint.doInit() when the endpoint connects to an existing queue. On LocalStack, this call resets DELAY_SECONDS to 0.
  • visibilityTimeout → maps to ReceiveMessage(VisibilityTimeout) (per-request), does not call SetQueueAttributes, does not touch DELAY_SECONDS.

Title fix: Updated to "Add SqsProducerDelayedQueueIT" as requested.

Spring Boot fix: Opened apache/camel-spring-boot#1976 which applies the same defaultVisibilityTimeout→visibilityTimeout fix to BaseSqs.receiveMessageFromQueue.

@gnodet
gnodet merged commit e98287b into apache:main Sep 14, 2026
5 checks passed
@gnodet
gnodet deleted the camel-23761-sqs-delayed-queue-it branch September 14, 2026 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants