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

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


The following commit(s) were added to refs/heads/main by this push:
     new 4066ec0fba7 CAMEL-18088: camel-aws2-sqs - Property 
messageHeaderExceededLimit doesn't work
4066ec0fba7 is described below

commit 4066ec0fba7c316e5fb8e173dcdd47b3e2f64b6f
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed May 11 16:54:11 2022 +0200

    CAMEL-18088: camel-aws2-sqs - Property messageHeaderExceededLimit doesn't 
work
---
 .../camel/component/aws2/sqs/Sqs2Producer.java     | 26 ++++++++++------------
 1 file changed, 12 insertions(+), 14 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 b894703e2ed..86a96d51c1e 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
@@ -56,6 +56,8 @@ public class Sqs2Producer extends DefaultProducer {
     private static final Logger LOG = 
LoggerFactory.getLogger(Sqs2Producer.class);
 
     private static final int MAX_ATTRIBUTES = 10;
+    private static final String MAX_MESSAGE
+            = "Number of message headers exceeded. At most " + MAX_ATTRIBUTES 
+ " headers is allowed when sending to AWS SQS.";
 
     private transient String sqsProducerToString;
 
@@ -302,22 +304,18 @@ public class Sqs2Producer extends DefaultProducer {
                     MessageAttributeValue mav = 
Sqs2MessageHelper.toMessageAttributeValue(entry.getValue());
                     if (mav != null) {
                         result.put(entry.getKey(), mav);
-                    } else {
-                        String action = 
getConfiguration().getMessageHeaderExceededLimit();
-                        if ("WARN".equalsIgnoreCase(action) || 
"WARN_ONCE".equalsIgnoreCase(action)) {
-                            // cannot translate the message header to message 
attribute value
-                            LOG.warn("Cannot put the message header key={}, 
value={} into SQS MessageAttribute", entry.getKey(),
-                                    entry.getValue());
-                            if ("WARN_ONCE".equalsIgnoreCase(action)) {
-                                break;
-                            }
-                        } else if ("IGNORE".equalsIgnoreCase(action)) {
+                    }
+                } else {
+                    String action = 
getConfiguration().getMessageHeaderExceededLimit();
+                    if ("WARN".equalsIgnoreCase(action) || 
"WARN_ONCE".equalsIgnoreCase(action)) {
+                        LOG.warn("Cannot put message header with key={} due: 
{}", entry.getKey(), MAX_MESSAGE);
+                        if ("WARN_ONCE".equalsIgnoreCase(action)) {
                             break;
-                        } else if ("FAIL".equalsIgnoreCase(action)) {
-                            throw new IllegalArgumentException(
-                                    "Number of message headers exceeded. At 
most " + MAX_ATTRIBUTES
-                                                               + " headers is 
allowed when sending to AWS SQS.");
                         }
+                    } else if ("IGNORE".equalsIgnoreCase(action)) {
+                        break;
+                    } else if ("FAIL".equalsIgnoreCase(action)) {
+                        throw new IllegalArgumentException(MAX_MESSAGE);
                     }
                 }
             }

Reply via email to