This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-4.14.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-4.14.x by this push:
     new 62bb90293df4 CAMEL-22762: Prevent queueUrl from remaining null when 
the SQS queue is missing at startup (#20336)
62bb90293df4 is described below

commit 62bb90293df47984c9a285f87f6bc7b53b3cf8cf
Author: Kirill Byvshev <[email protected]>
AuthorDate: Wed Dec 10 16:40:49 2025 +0400

    CAMEL-22762: Prevent queueUrl from remaining null when the SQS queue is 
missing at startup (#20336)
---
 .../main/java/org/apache/camel/component/aws2/sqs/Sqs2Consumer.java | 6 ++++--
 .../main/java/org/apache/camel/component/aws2/sqs/Sqs2Endpoint.java | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git 
a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Consumer.java
 
b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Consumer.java
index 37e70b70f731..d50380bb362a 100644
--- 
a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Consumer.java
+++ 
b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Consumer.java
@@ -43,6 +43,7 @@ import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
+import java.util.function.Supplier;
 import java.util.regex.Pattern;
 
 import org.apache.camel.AsyncCallback;
@@ -547,7 +548,7 @@ public class Sqs2Consumer extends 
ScheduledBatchPollingConsumer {
         private final IOConsumer<SqsClient> createQueueOperation;
 
         private final String queueName;
-        private final String queueUrl;
+        private final Supplier<String> getQueueUrlOperation;
         private final int maxMessagesPerPoll;
         private final Integer visibilityTimeout;
         private final Integer waitTimeSeconds;
@@ -565,7 +566,7 @@ public class Sqs2Consumer extends 
ScheduledBatchPollingConsumer {
             createQueueOperation = endpoint::createQueue;
 
             queueName = endpoint.getConfiguration().getQueueName();
-            queueUrl = endpoint.getQueueUrl();
+            getQueueUrlOperation = endpoint::getQueueUrl;
             visibilityTimeout = 
endpoint.getConfiguration().getVisibilityTimeout();
             waitTimeSeconds = endpoint.getConfiguration().getWaitTimeSeconds();
             messageAttributeNames = 
splitCommaSeparatedValues(endpoint.getConfiguration().getMessageAttributeNames());
@@ -670,6 +671,7 @@ public class Sqs2Consumer extends 
ScheduledBatchPollingConsumer {
         }
 
         private ReceiveMessageRequest createReceiveRequest(int 
maxNumberOfMessages) {
+            String queueUrl = getQueueUrlOperation.get();
             ReceiveMessageRequest.Builder requestBuilder
                     = 
ReceiveMessageRequest.builder().queueUrl(queueUrl).maxNumberOfMessages(maxNumberOfMessages)
                             
.visibilityTimeout(visibilityTimeout).waitTimeSeconds(waitTimeSeconds);
diff --git 
a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Endpoint.java
 
b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Endpoint.java
index de0a7d9e224d..b043c865e5f9 100644
--- 
a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Endpoint.java
+++ 
b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Endpoint.java
@@ -384,7 +384,7 @@ public class Sqs2Endpoint extends ScheduledPollEndpoint 
implements HeaderFilterS
      * If queue does not exist during endpoint initialization, the queueUrl 
has to be initialized again. See
      * https://issues.apache.org/jira/browse/CAMEL-18968 for more details.
      */
-    protected String getQueueUrl() {
+    protected synchronized String getQueueUrl() {
         if (!queueUrlInitialized) {
             LOG.trace("Queue url was not initialized during the start of the 
component. Initializing again.");
             initQueueUrl();

Reply via email to