[
https://issues.apache.org/jira/browse/CAMEL-12641?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16541182#comment-16541182
]
ASF GitHub Bot commented on CAMEL-12641:
----------------------------------------
oscerd closed pull request #2421: CAMEL-12641 : Aws-sns and aws-sqs components
not accepting Date type …
URL: https://github.com/apache/camel/pull/2421
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsProducer.java
b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsProducer.java
index cdfd52d18dc..2b447e1a0bb 100644
---
a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsProducer.java
+++
b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsProducer.java
@@ -17,6 +17,7 @@
package org.apache.camel.component.aws.sns;
import java.nio.ByteBuffer;
+import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
@@ -104,6 +105,11 @@ private String determineMessageStructure(Exchange
exchange) {
mav.setDataType("Binary");
mav.withBinaryValue((ByteBuffer)value);
result.put(entry.getKey(), mav);
+ } else if (value instanceof Date) {
+ MessageAttributeValue mav = new MessageAttributeValue();
+ mav.setDataType("String");
+ mav.withStringValue(value.toString());
+ result.put(entry.getKey(), mav);
} else {
// cannot translate the message header to message
attribute value
LOG.warn("Cannot put the message header key={}, value={}
into Sns MessageAttribute", entry.getKey(), entry.getValue());
diff --git
a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsProducer.java
b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsProducer.java
index 74c8868df44..74b3e02953d 100644
---
a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsProducer.java
+++
b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsProducer.java
@@ -17,6 +17,7 @@
package org.apache.camel.component.aws.sqs;
import java.nio.ByteBuffer;
+import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
@@ -161,6 +162,11 @@ public String toString() {
mav.setDataType(dataType);
mav.withStringValue(((Number)value).toString());
result.put(entry.getKey(), mav);
+ } else if (value instanceof Date) {
+ MessageAttributeValue mav = new MessageAttributeValue();
+ mav.setDataType("String");
+ mav.withStringValue(value.toString());
+ result.put(entry.getKey(), mav);
} else {
// 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());
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Aws-sns and aws-sqs components not accepting Date type message attributes
> -------------------------------------------------------------------------
>
> Key: CAMEL-12641
> URL: https://issues.apache.org/jira/browse/CAMEL-12641
> Project: Camel
> Issue Type: Improvement
> Components: camel-aws
> Affects Versions: 2.21.1
> Reporter: Saravanakumar Selvaraj
> Assignee: Andrea Cosentino
> Priority: Minor
> Fix For: 2.23.0
>
>
> Camel aws-sns and aws-sqs components not accepting Date type message
> attributes. For example, the camel route like,
> {{ <from id="_from1" uri="timer://foo?repeatCount=1" />}}
> {{ <to id="_to1" uri="aws-sns://***/>}}
> fails with error while publishing the message.
> {{2018-07-11 18:49:49,109 [2 - timer://foo] WARN SnsProducer
> - Cannot put the message header key=firedTime,
> value=2018-07-11T18:49:49.090+0530 into Sns MessageAttribute}}
>
> Because it carries header _firedTime_ as java.util.Date
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)