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

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

commit c44026c40d99fc62764179df83e03b63756075ae
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Jul 17 17:56:21 2026 +0200

    CAMEL-24157: camel-aws2-sqs - Defer FIFO messageGroupIdStrategy check to 
send operations
    
    Move the messageGroupIdStrategy validation from the constructor to
    processSingleMessage and sendBatchMessage where it is actually needed.
    This allows purgeQueue, deleteQueue, listQueues, and deleteMessage
    operations to work on FIFO queues without requiring a 
messageGroupIdStrategy.
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../org/apache/camel/component/aws2/sqs/Sqs2Producer.java    | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git 
a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Producer.java
 
b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Producer.java
index 0518d36791d7..1295bf948d05 100644
--- 
a/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Producer.java
+++ 
b/components/camel-aws/camel-aws2-sqs/src/main/java/org/apache/camel/component/aws2/sqs/Sqs2Producer.java
@@ -63,10 +63,6 @@ public class Sqs2Producer extends DefaultProducer {
 
     public Sqs2Producer(Sqs2Endpoint endpoint) {
         super(endpoint);
-        if (endpoint.getConfiguration().isFifoQueue()
-                && 
ObjectHelper.isEmpty(getEndpoint().getConfiguration().getMessageGroupIdStrategy()))
 {
-            throw new IllegalArgumentException("messageGroupIdStrategy must be 
set for FIFO queues.");
-        }
     }
 
     @Override
@@ -98,6 +94,10 @@ public class Sqs2Producer extends DefaultProducer {
     }
 
     public void processSingleMessage(final Exchange exchange) {
+        if (getEndpoint().getConfiguration().isFifoQueue()
+                && 
ObjectHelper.isEmpty(getEndpoint().getConfiguration().getMessageGroupIdStrategy()))
 {
+            throw new IllegalArgumentException("messageGroupIdStrategy must be 
set for FIFO queues.");
+        }
         String body = exchange.getIn().getBody(String.class);
         SendMessageRequest.Builder request = 
SendMessageRequest.builder().queueUrl(getQueueUrl()).messageBody(body);
         
request.messageAttributes(translateAttributes(exchange.getIn().getHeaders(), 
exchange));
@@ -117,6 +117,10 @@ public class Sqs2Producer extends DefaultProducer {
     }
 
     private void sendBatchMessage(SqsClient amazonSQS, Exchange exchange) {
+        if (getEndpoint().getConfiguration().isFifoQueue()
+                && 
ObjectHelper.isEmpty(getEndpoint().getConfiguration().getMessageGroupIdStrategy()))
 {
+            throw new IllegalArgumentException("messageGroupIdStrategy must be 
set for FIFO queues.");
+        }
         SendMessageBatchRequest.Builder request = 
SendMessageBatchRequest.builder().queueUrl(getQueueUrl());
         Collection<SendMessageBatchRequestEntry> entries = new ArrayList<>();
         if (exchange.getIn().getBody() instanceof Iterable) {

Reply via email to