[ 
https://issues.apache.org/jira/browse/CAMEL-12641?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16540117#comment-16540117
 ] 

ASF GitHub Bot commented on CAMEL-12641:
----------------------------------------

oscerd closed pull request #2420: CAMEL-12641 : Aws-sns and aws-sqs components 
not accepting Date type message attributes
URL: https://github.com/apache/camel/pull/2420
 
 
   

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 36c4a15d9ce..7e50d4e2ca9 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 682d75e4f4c..3e792dfc399 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;
@@ -120,6 +121,11 @@ public String toString() {
                     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 Sqs MessageAttribute", entry.getKey(), entry.getValue());
diff --git 
a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
 
b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
index b465374b2a9..7bff7e24e7b 100644
--- 
a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
+++ 
b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpComponent.java
@@ -85,7 +85,7 @@
         + " Important: Only one instance of 
org.apache.camel.util.jsse.SSLContextParameters is supported per HttpComponent."
         + " If you need to use 2 or more different instances, you need to 
define a new HttpComponent per instance you need.")
     protected SSLContextParameters sslContextParameters;
-    @Metadata(label = "security", defaultValue = "false")
+    @Metadata(description = "Enable usage of global SSL context parameters", 
label = "security", defaultValue = "false")
     private boolean useGlobalSslContextParameters;
     @Metadata(label = "security", description = "To use a custom 
X509HostnameVerifier such as DefaultHostnameVerifier or NoopHostnameVerifier.")
     protected HostnameVerifier x509HostnameVerifier = new 
DefaultHostnameVerifier();
diff --git 
a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
 
b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
index 0ffaab48fa6..eb631f83e63 100644
--- 
a/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
+++ 
b/components/camel-http4/src/main/java/org/apache/camel/component/http4/HttpEndpoint.java
@@ -48,7 +48,7 @@
 /**
  * For calling out to external HTTP servers using Apache HTTP Client 4.x.
  */
-@UriEndpoint(firstVersion = "2.3.0", scheme = "http4,http4s", title = 
"HTTP4,HTTP4S", syntax = "http4:httpUri",
+@UriEndpoint(firstVersion = "2.3.0", scheme = "http4,https4", title = 
"HTTP4,HTTPS4", syntax = "http4:httpUri",
     producerOnly = true, label = "http", lenientProperties = true)
 public class HttpEndpoint extends HttpCommonEndpoint {
 
diff --git 
a/components/camel-snakeyaml/src/main/docs/yaml-snakeyaml-dataformat.adoc 
b/components/camel-snakeyaml/src/main/docs/yaml-snakeyaml-dataformat.adoc
index bcfa3c65b8b..15b56919904 100644
--- a/components/camel-snakeyaml/src/main/docs/yaml-snakeyaml-dataformat.adoc
+++ b/components/camel-snakeyaml/src/main/docs/yaml-snakeyaml-dataformat.adoc
@@ -24,7 +24,7 @@ The YAML SnakeYAML dataformat supports 11 options which are 
listed below.
 [width="100%",cols="2s,1m,1m,6",options="header"]
 |=======================================================================
 | Name | Default | Java Type | Description
-| library | SnakeYAML | YAMLLibrary | Which yaml library to use such. Is by 
default SnakeYAML
+| library | SnakeYAML | YAMLLibrary | Which yaml library to use. By default it 
is SnakeYAML
 | unmarshalTypeName |  | String | Class name of the java type to use when 
unarmshalling
 | constructor |  | String | BaseConstructor to construct incoming documents.
 | representer |  | String | Representer to emit outgoing objects.
diff --git 
a/platforms/spring-boot/components-starter/camel-http4-starter/src/main/java/org/apache/camel/component/http4/springboot/HttpComponentAutoConfiguration.java
 
b/platforms/spring-boot/components-starter/camel-http4-starter/src/main/java/org/apache/camel/component/http4/springboot/HttpComponentAutoConfiguration.java
index 4530a87bb25..e675a70981d 100644
--- 
a/platforms/spring-boot/components-starter/camel-http4-starter/src/main/java/org/apache/camel/component/http4/springboot/HttpComponentAutoConfiguration.java
+++ 
b/platforms/spring-boot/components-starter/camel-http4-starter/src/main/java/org/apache/camel/component/http4/springboot/HttpComponentAutoConfiguration.java
@@ -48,7 +48,7 @@
 public class HttpComponentAutoConfiguration {
 
     @Lazy
-    @Bean(name = "http4-component")
+    @Bean(name = {"http4-component", "https4-component"})
     @ConditionalOnClass(CamelContext.class)
     @ConditionalOnMissingBean(HttpComponent.class)
     public HttpComponent configureHttpComponent(CamelContext camelContext,
diff --git 
a/platforms/spring-boot/components-starter/camel-jetty9-starter/src/test/java/org/apache/camel/component/jetty9/Jetty9SSLTest.java
 
b/platforms/spring-boot/components-starter/camel-jetty9-starter/src/test/java/org/apache/camel/component/jetty9/Jetty9SSLTest.java
index 6b40ff64e9c..7e80043cb0a 100644
--- 
a/platforms/spring-boot/components-starter/camel-jetty9-starter/src/test/java/org/apache/camel/component/jetty9/Jetty9SSLTest.java
+++ 
b/platforms/spring-boot/components-starter/camel-jetty9-starter/src/test/java/org/apache/camel/component/jetty9/Jetty9SSLTest.java
@@ -22,7 +22,6 @@
 import org.apache.camel.spring.boot.CamelAutoConfiguration;
 import org.apache.camel.test.AvailablePortFinder;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -55,7 +54,6 @@
         "camel.component.jetty.use-global-ssl-context-parameters=true",
         "camel.component.http4.use-global-ssl-context-parameters=true",
 })
-@Ignore("Bug in https4 spring-boot configuration")
 public class Jetty9SSLTest {
 
     private static int port;
diff --git 
a/platforms/spring-boot/components-starter/camel-netty4-http-starter/src/test/java/org/apache/camel/component/netty4/http/springboot/Netty4HttpSSLTest.java
 
b/platforms/spring-boot/components-starter/camel-netty4-http-starter/src/test/java/org/apache/camel/component/netty4/http/springboot/Netty4HttpSSLTest.java
index d8451b7d8e5..68d10fa5ddb 100644
--- 
a/platforms/spring-boot/components-starter/camel-netty4-http-starter/src/test/java/org/apache/camel/component/netty4/http/springboot/Netty4HttpSSLTest.java
+++ 
b/platforms/spring-boot/components-starter/camel-netty4-http-starter/src/test/java/org/apache/camel/component/netty4/http/springboot/Netty4HttpSSLTest.java
@@ -16,12 +16,9 @@
  */
 package org.apache.camel.component.netty4.http.springboot;
 
-import org.apache.camel.Exchange;
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.spring.boot.CamelAutoConfiguration;
-import org.junit.Assert;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -53,9 +50,8 @@
         "camel.ssl.config.trust-managers.key-store.password=changeit",
         "camel.ssl.config.trust-managers.key-store.type=jks",
         "camel.component.netty4-http.use-global-ssl-context-parameters=true",
-        "camel.component.http.use-global-ssl-context-parameters=true"
+        "camel.component.http4.use-global-ssl-context-parameters=true"
 })
-@Ignore("Bug in https4 spring-boot configuration")
 public class Netty4HttpSSLTest {
 
     @Autowired
diff --git 
a/platforms/spring-boot/components-starter/camel-snakeyaml-starter/src/main/java/org/apache/camel/component/snakeyaml/springboot/SnakeYAMLDataFormatConfiguration.java
 
b/platforms/spring-boot/components-starter/camel-snakeyaml-starter/src/main/java/org/apache/camel/component/snakeyaml/springboot/SnakeYAMLDataFormatConfiguration.java
index 0bd61abbdf2..368e1e4f5cf 100644
--- 
a/platforms/spring-boot/components-starter/camel-snakeyaml-starter/src/main/java/org/apache/camel/component/snakeyaml/springboot/SnakeYAMLDataFormatConfiguration.java
+++ 
b/platforms/spring-boot/components-starter/camel-snakeyaml-starter/src/main/java/org/apache/camel/component/snakeyaml/springboot/SnakeYAMLDataFormatConfiguration.java
@@ -31,7 +31,7 @@
 public class SnakeYAMLDataFormatConfiguration {
 
     /**
-     * Which yaml library to use such. Is by default SnakeYAML
+     * Which yaml library to use. By default it is SnakeYAML
      */
     private YAMLLibrary library = YAMLLibrary.SnakeYAML;
     /**
diff --git 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
index d7eac27e6c6..002f4127a19 100644
--- 
a/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
+++ 
b/tooling/maven/camel-package-maven-plugin/src/main/java/org/apache/camel/maven/packaging/SpringBootAutoConfigurationMojo.java
@@ -41,9 +41,11 @@
 import java.util.TreeSet;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
+
 import org.apache.camel.maven.packaging.model.ComponentModel;
 import org.apache.camel.maven.packaging.model.ComponentOptionModel;
 import org.apache.camel.maven.packaging.model.DataFormatModel;
@@ -528,7 +530,7 @@ private void executeComponent() throws 
MojoExecutionException, MojoFailureExcept
             for (String componentClass : grModels.keySet()) {
                 List<ComponentModel> compModels = grModels.get(componentClass);
                 ComponentModel model = compModels.get(0); // They should be 
equivalent
-                List<String> aliases = 
compModels.stream().map(ComponentModel::getScheme).sorted().collect(Collectors.toList());
+                List<String> aliases = compModels.stream().flatMap(mod -> 
this.getComponentModelSchemes(mod, 
allModels)).distinct().sorted().collect(Collectors.toList());
 
                 // resolvePropertyPlaceholders is an option which only make 
sense to use if the component has other options
                 boolean hasOptions = 
model.getComponentOptions().stream().anyMatch(o -> 
!o.getName().equals("resolvePropertyPlaceholders"));
@@ -1404,6 +1406,21 @@ private void createLanguageSpringFactorySource(String 
packageName, LanguageModel
         writeComponentSpringFactorySource(packageName, name);
     }
 
+    private Stream<String> getComponentModelSchemes(ComponentModel model, 
List<ComponentModel> allModels) {
+        Set<String> mainSchemes = 
allModels.stream().map(ComponentModel::getScheme).collect(Collectors.toSet());
+        Set<String> schemes = new TreeSet<>();
+        schemes.add(model.getScheme());
+        if (model.getAlternativeSchemes() != null) {
+            String[] alternativeSchemes = 
model.getAlternativeSchemes().split(",");
+            for (String s : alternativeSchemes) {
+                if (!StringHelper.isEmpty(s) && !mainSchemes.contains(s)) {
+                    schemes.add(s);
+                }
+            }
+        }
+        return schemes.stream();
+    }
+
     private static String createComponentBody(String shortJavaType, boolean 
hasOptions) {
         StringBuilder sb = new StringBuilder();
         sb.append(shortJavaType).append(" component = new 
").append(shortJavaType).append("();").append("\n");
@@ -1611,6 +1628,7 @@ private static ComponentModel 
generateComponentModel(String componentName, Strin
 
         ComponentModel component = new ComponentModel(true);
         component.setScheme(getSafeValue("scheme", rows));
+        component.setAlternativeSchemes(getSafeValue("alternativeSchemes", 
rows));
         component.setSyntax(getSafeValue("syntax", rows));
         component.setAlternativeSyntax(getSafeValue("alternativeSyntax", 
rows));
         component.setTitle(getSafeValue("title", rows));


 

----------------------------------------------------------------
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: Bug
>          Components: camel-aws
>    Affects Versions: 2.21.1
>            Reporter: Saravanakumar Selvaraj
>            Priority: Minor
>
> 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)

Reply via email to