From c4ed2c8ad39f56b0c82fee0039c5e8970c894a61 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 14 Sep 2026 11:20:49 +0000 Subject: [PATCH] CAMEL-23761: Fix BaseSqs.receiveMessageFromQueue to use visibilityTimeout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .../apache/camel/component/aws2/sqs/BaseSqs.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/components-starter/camel-aws2-sqs-starter/src/test/java/org/apache/camel/component/aws2/sqs/BaseSqs.java b/components-starter/camel-aws2-sqs-starter/src/test/java/org/apache/camel/component/aws2/sqs/BaseSqs.java index e7a237658dc1..7e1dacce1c5f 100644 --- a/components-starter/camel-aws2-sqs-starter/src/test/java/org/apache/camel/component/aws2/sqs/BaseSqs.java +++ b/components-starter/camel-aws2-sqs-starter/src/test/java/org/apache/camel/component/aws2/sqs/BaseSqs.java @@ -16,6 +16,7 @@ */ package org.apache.camel.component.aws2.sqs; +import java.util.UUID; import org.apache.camel.CamelContext; import org.apache.camel.ConsumerTemplate; import org.apache.camel.ProducerTemplate; @@ -32,8 +33,6 @@ import org.springframework.context.annotation.Configuration; import software.amazon.awssdk.services.sqs.SqsClient; -import java.util.UUID; - public class BaseSqs { @Autowired @@ -66,10 +65,13 @@ String sendSingleMessageToQueue(String queueName) { } String receiveMessageFromQueue(String queueName, boolean deleteMessage) { - return consumerTemplate.receiveBody( - String.format("aws2-sqs://%s?deleteAfterRead=%s&deleteIfFiltered=%s&defaultVisibilityTimeout=0", - queueName, deleteMessage, deleteMessage), - 10000, String.class); + // Use visibilityTimeout (per-request ReceiveMessage timeout) rather than + // defaultVisibilityTimeout (queue-level SetQueueAttributes). The latter calls + // SetQueueAttributes({VISIBILITY_TIMEOUT:0}) which on LocalStack inadvertently + // resets DELAY_SECONDS to 0, breaking delayed-queue tests. + return consumerTemplate + .receiveBody(String.format("aws2-sqs://%s?deleteAfterRead=%s&deleteIfFiltered=%s&visibilityTimeout=0", + queueName, deleteMessage, deleteMessage), 10000, String.class); } // *************************************