You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2020/02/28 15:31:34 UTC

[camel] 01/03: CAMEL-14568 - Fixed AWS MQ

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

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

commit 5f4971245e031ef051e4ac1d8d0a85612c4c24fe
Author: Andrea Cosentino <an...@gmail.com>
AuthorDate: Fri Feb 28 16:14:13 2020 +0100

    CAMEL-14568 - Fixed AWS MQ
---
 .../component/aws/mq/MQComponentConfigurer.java    |  7 ++--
 .../org/apache/camel/component/aws/mq/aws-mq.json  |  8 ++--
 .../src/main/docs/aws-mq-component.adoc            |  2 +-
 .../apache/camel/component/aws/mq/MQComponent.java | 48 ++--------------------
 .../aws/mq/MQComponentConfigurationTest.java       | 16 ++++----
 .../dsl/AwsMqComponentBuilderFactory.java          | 32 +++++++--------
 6 files changed, 35 insertions(+), 78 deletions(-)

diff --git a/components/camel-aws-mq/src/generated/java/org/apache/camel/component/aws/mq/MQComponentConfigurer.java b/components/camel-aws-mq/src/generated/java/org/apache/camel/component/aws/mq/MQComponentConfigurer.java
index 9b329c4..583584f 100644
--- a/components/camel-aws-mq/src/generated/java/org/apache/camel/component/aws/mq/MQComponentConfigurer.java
+++ b/components/camel-aws-mq/src/generated/java/org/apache/camel/component/aws/mq/MQComponentConfigurer.java
@@ -23,9 +23,10 @@ public class MQComponentConfigurer extends PropertyConfigurerSupport implements
         MQComponent target = (MQComponent) obj;
         switch (ignoreCase ? name.toLowerCase() : name) {
         case "accesskey":
-        case "accessKey": target.setAccessKey(property(camelContext, java.lang.String.class, value)); return true;
+        case "accessKey": getOrCreateConfiguration(target).setAccessKey(property(camelContext, java.lang.String.class, value)); return true;
         case "amazonmqclient":
         case "amazonMqClient": getOrCreateConfiguration(target).setAmazonMqClient(property(camelContext, com.amazonaws.services.mq.AmazonMQ.class, value)); return true;
+        case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.aws.mq.MQConfiguration.class, value)); return true;
         case "lazystartproducer":
         case "lazyStartProducer": target.setLazyStartProducer(property(camelContext, boolean.class, value)); return true;
         case "operation": getOrCreateConfiguration(target).setOperation(property(camelContext, org.apache.camel.component.aws.mq.MQOperations.class, value)); return true;
@@ -35,13 +36,11 @@ public class MQComponentConfigurer extends PropertyConfigurerSupport implements
         case "proxyPort": getOrCreateConfiguration(target).setProxyPort(property(camelContext, java.lang.Integer.class, value)); return true;
         case "proxyprotocol":
         case "proxyProtocol": getOrCreateConfiguration(target).setProxyProtocol(property(camelContext, com.amazonaws.Protocol.class, value)); return true;
-        case "region": target.setRegion(property(camelContext, java.lang.String.class, value)); return true;
         case "region": getOrCreateConfiguration(target).setRegion(property(camelContext, java.lang.String.class, value)); return true;
         case "secretkey":
-        case "secretKey": target.setSecretKey(property(camelContext, java.lang.String.class, value)); return true;
+        case "secretKey": getOrCreateConfiguration(target).setSecretKey(property(camelContext, java.lang.String.class, value)); return true;
         case "basicpropertybinding":
         case "basicPropertyBinding": target.setBasicPropertyBinding(property(camelContext, boolean.class, value)); return true;
-        case "configuration": target.setConfiguration(property(camelContext, org.apache.camel.component.aws.mq.MQConfiguration.class, value)); return true;
         default: return false;
         }
     }
diff --git a/components/camel-aws-mq/src/generated/resources/org/apache/camel/component/aws/mq/aws-mq.json b/components/camel-aws-mq/src/generated/resources/org/apache/camel/component/aws/mq/aws-mq.json
index d85082a..d946834 100644
--- a/components/camel-aws-mq/src/generated/resources/org/apache/camel/component/aws/mq/aws-mq.json
+++ b/components/camel-aws-mq/src/generated/resources/org/apache/camel/component/aws/mq/aws-mq.json
@@ -19,17 +19,17 @@
     "version": "3.2.0-SNAPSHOT"
   },
   "componentProperties": {
-    "accessKey": { "kind": "property", "displayName": "Access Key", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "description": "Amazon AWS Access Key" },
+    "accessKey": { "kind": "property", "displayName": "Access Key", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": true, "configurationClass": "org.apache.camel.component.aws.mq.MQConfiguration", "configurationField": "configuration", "description": "Amazon AWS Access Key" },
     "amazonMqClient": { "kind": "property", "displayName": "Amazon Mq Client", "group": "producer", "label": "producer", "required": false, "type": "object", "javaType": "com.amazonaws.services.mq.AmazonMQ", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws.mq.MQConfiguration", "configurationField": "configuration", "description": "To use a existing configured AmazonMQClient as client" },
+    "configuration": { "kind": "property", "displayName": "Configuration", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "org.apache.camel.component.aws.mq.MQConfiguration", "deprecated": false, "secret": false, "description": "The Component configuration" },
     "lazyStartProducer": { "kind": "property", "displayName": "Lazy Start Producer", "group": "producer", "label": "producer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the r [...]
     "operation": { "kind": "property", "displayName": "Operation", "group": "producer", "label": "producer", "required": true, "type": "object", "javaType": "org.apache.camel.component.aws.mq.MQOperations", "enum": [ "listBrokers", "createBroker", "deleteBroker", "rebootBroker", "updateBroker", "describeBroker" ], "deprecated": false, "deprecationNote": "", "secret": false, "configurationClass": "org.apache.camel.component.aws.mq.MQConfiguration", "configurationField": "configuration", " [...]
     "proxyHost": { "kind": "property", "displayName": "Proxy Host", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws.mq.MQConfiguration", "configurationField": "configuration", "description": "To define a proxy host when instantiating the MQ client" },
     "proxyPort": { "kind": "property", "displayName": "Proxy Port", "group": "producer", "label": "producer", "required": false, "type": "integer", "javaType": "java.lang.Integer", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws.mq.MQConfiguration", "configurationField": "configuration", "description": "To define a proxy port when instantiating the MQ client" },
     "proxyProtocol": { "kind": "property", "displayName": "Proxy Protocol", "group": "producer", "label": "", "required": false, "type": "object", "javaType": "com.amazonaws.Protocol", "enum": [ "HTTP", "HTTPS" ], "deprecated": false, "secret": false, "defaultValue": "HTTPS", "configurationClass": "org.apache.camel.component.aws.mq.MQConfiguration", "configurationField": "configuration", "description": "To define a proxy protocol when instantiating the MQ client" },
     "region": { "kind": "property", "displayName": "Region", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "configurationClass": "org.apache.camel.component.aws.mq.MQConfiguration", "configurationField": "configuration", "description": "The region in which MQ client needs to work. When using this parameter, the configuration will expect the capitalized name of the region (for example AP_EAST_1) [...]
-    "secretKey": { "kind": "property", "displayName": "Secret Key", "group": "producer", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": false, "description": "Amazon AWS Secret Key" },
-    "basicPropertyBinding": { "kind": "property", "displayName": "Basic Property Binding", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities" },
-    "configuration": { "kind": "property", "displayName": "Configuration", "group": "advanced", "label": "advanced", "required": false, "type": "object", "javaType": "org.apache.camel.component.aws.mq.MQConfiguration", "deprecated": false, "secret": false, "description": "The AWS MQ default configuration" }
+    "secretKey": { "kind": "property", "displayName": "Secret Key", "group": "producer", "label": "producer", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "secret": true, "configurationClass": "org.apache.camel.component.aws.mq.MQConfiguration", "configurationField": "configuration", "description": "Amazon AWS Secret Key" },
+    "basicPropertyBinding": { "kind": "property", "displayName": "Basic Property Binding", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "secret": false, "defaultValue": false, "description": "Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities" }
   },
   "properties": {
     "label": { "kind": "path", "displayName": "Label", "group": "producer", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "secret": false, "configurationClass": "org.apache.camel.component.aws.mq.MQConfiguration", "configurationField": "configuration", "description": "Logical name" },
diff --git a/components/camel-aws-mq/src/main/docs/aws-mq-component.adoc b/components/camel-aws-mq/src/main/docs/aws-mq-component.adoc
index 54583f1..9f3acdb 100644
--- a/components/camel-aws-mq/src/main/docs/aws-mq-component.adoc
+++ b/components/camel-aws-mq/src/main/docs/aws-mq-component.adoc
@@ -39,6 +39,7 @@ The AWS MQ component supports 11 options, which are listed below.
 | Name | Description | Default | Type
 | *accessKey* (producer) | Amazon AWS Access Key |  | String
 | *amazonMqClient* (producer) | To use a existing configured AmazonMQClient as client |  | AmazonMQ
+| *configuration* (producer) | The Component configuration |  | MQConfiguration
 | *lazyStartProducer* (producer) | Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel's routing error handlers. Beware that when the first message is processed then creating and [...]
 | *operation* (producer) | *Required* The operation to perform. It can be listBrokers,createBroker,deleteBroker. The value can be one of: listBrokers, createBroker, deleteBroker, rebootBroker, updateBroker, describeBroker |  | MQOperations
 | *proxyHost* (producer) | To define a proxy host when instantiating the MQ client |  | String
@@ -47,7 +48,6 @@ The AWS MQ component supports 11 options, which are listed below.
 | *region* (producer) | The region in which MQ client needs to work. When using this parameter, the configuration will expect the capitalized name of the region (for example AP_EAST_1) You'll need to use the name Regions.EU_WEST_1.name() |  | String
 | *secretKey* (producer) | Amazon AWS Secret Key |  | String
 | *basicPropertyBinding* (advanced) | Whether the component should use basic property binding (Camel 2.x) or the newer property binding with additional capabilities | false | boolean
-| *configuration* (advanced) | The AWS MQ default configuration |  | MQConfiguration
 |===
 // component options: END
 
diff --git a/components/camel-aws-mq/src/main/java/org/apache/camel/component/aws/mq/MQComponent.java b/components/camel-aws-mq/src/main/java/org/apache/camel/component/aws/mq/MQComponent.java
index a6b07d8..e538445 100644
--- a/components/camel-aws-mq/src/main/java/org/apache/camel/component/aws/mq/MQComponent.java
+++ b/components/camel-aws-mq/src/main/java/org/apache/camel/component/aws/mq/MQComponent.java
@@ -32,14 +32,8 @@ import org.apache.camel.support.DefaultComponent;
 @Component("aws-mq")
 public class MQComponent extends DefaultComponent {
 
-    @Metadata
-    private String accessKey;
-    @Metadata
-    private String secretKey;
-    @Metadata
-    private String region;
-    @Metadata(label = "advanced")    
-    private MQConfiguration configuration;
+    @Metadata  
+    private MQConfiguration configuration = new MQConfiguration();
     
     public MQComponent() {
         this(null);
@@ -55,9 +49,6 @@ public class MQComponent extends DefaultComponent {
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
         MQConfiguration configuration = this.configuration != null ? this.configuration.copy() : new MQConfiguration();
         MQEndpoint endpoint = new MQEndpoint(uri, this, configuration);
-        endpoint.getConfiguration().setAccessKey(accessKey);
-        endpoint.getConfiguration().setSecretKey(secretKey);
-        endpoint.getConfiguration().setRegion(region);
         setProperties(endpoint, parameters);
         checkAndSetRegistryClient(configuration);
         if (configuration.getAmazonMqClient() == null && (configuration.getAccessKey() == null || configuration.getSecretKey() == null)) {
@@ -72,45 +63,12 @@ public class MQComponent extends DefaultComponent {
     }
 
     /**
-     * The AWS MQ default configuration
+     * The Component configuration
      */
     public void setConfiguration(MQConfiguration configuration) {
         this.configuration = configuration;
     }
 
-    public String getAccessKey() {
-        return accessKey;
-    }
-
-    /**
-     * Amazon AWS Access Key
-     */
-    public void setAccessKey(String accessKey) {
-        this.accessKey = accessKey;
-    }
-
-    public String getSecretKey() {
-        return secretKey;
-    }
-
-    /**
-     * Amazon AWS Secret Key
-     */
-    public void setSecretKey(String secretKey) {
-        this.secretKey = secretKey;
-    }
-    
-    public String getRegion() {
-        return region;
-    }
-
-    /**
-     * The region in which MQ client needs to work
-     */
-    public void setRegion(String region) {
-        this.region = region;
-    }
-
     private void checkAndSetRegistryClient(MQConfiguration configuration) {
         Set<AmazonMQ> clients = getCamelContext().getRegistry().findByType(AmazonMQ.class);
         if (clients.size() == 1) {
diff --git a/components/camel-aws-mq/src/test/java/org/apache/camel/component/aws/mq/MQComponentConfigurationTest.java b/components/camel-aws-mq/src/test/java/org/apache/camel/component/aws/mq/MQComponentConfigurationTest.java
index 5f4560f..490dfea 100644
--- a/components/camel-aws-mq/src/test/java/org/apache/camel/component/aws/mq/MQComponentConfigurationTest.java
+++ b/components/camel-aws-mq/src/test/java/org/apache/camel/component/aws/mq/MQComponentConfigurationTest.java
@@ -27,8 +27,8 @@ public class MQComponentConfigurationTest extends CamelTestSupport {
     @Test
     public void createEndpointWithComponentElements() throws Exception {
         MQComponent component = context.getComponent("aws-mq", MQComponent.class);
-        component.setAccessKey("XXX");
-        component.setSecretKey("YYY");
+        component.getConfiguration().setAccessKey("XXX");
+        component.getConfiguration().setSecretKey("YYY");
         MQEndpoint endpoint = (MQEndpoint)component.createEndpoint("aws-mq://MyQueue");
         
         assertEquals("XXX", endpoint.getConfiguration().getAccessKey());
@@ -38,9 +38,9 @@ public class MQComponentConfigurationTest extends CamelTestSupport {
     @Test
     public void createEndpointWithComponentAndEndpointElements() throws Exception {
         MQComponent component = context.getComponent("aws-mq", MQComponent.class);
-        component.setAccessKey("XXX");
-        component.setSecretKey("YYY");
-        component.setRegion(Regions.US_WEST_1.toString());
+        component.getConfiguration().setAccessKey("XXX");
+        component.getConfiguration().setSecretKey("YYY");
+        component.getConfiguration().setRegion(Regions.US_WEST_1.toString());
         MQEndpoint endpoint = (MQEndpoint)component.createEndpoint("aws-mq://MyQueue?accessKey=xxxxxx&secretKey=yyyyy&region=US_EAST_1");
         
         assertEquals("xxxxxx", endpoint.getConfiguration().getAccessKey());
@@ -51,9 +51,9 @@ public class MQComponentConfigurationTest extends CamelTestSupport {
     @Test
     public void createEndpointWithComponentEndpointElementsAndProxy() throws Exception {
         MQComponent component = context.getComponent("aws-mq", MQComponent.class);
-        component.setAccessKey("XXX");
-        component.setSecretKey("YYY");
-        component.setRegion(Regions.US_WEST_1.toString());
+        component.getConfiguration().setAccessKey("XXX");
+        component.getConfiguration().setSecretKey("YYY");
+        component.getConfiguration().setRegion(Regions.US_WEST_1.toString());
         MQEndpoint endpoint = (MQEndpoint)component.createEndpoint("aws-mq://label?accessKey=xxxxxx&secretKey=yyyyy&region=US_EAST_1&proxyHost=localhost&proxyPort=9000&proxyProtocol=HTTP");
         
         assertEquals("xxxxxx", endpoint.getConfiguration().getAccessKey());
diff --git a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsMqComponentBuilderFactory.java b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsMqComponentBuilderFactory.java
index 00fd3ca..5bb83bb 100644
--- a/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsMqComponentBuilderFactory.java
+++ b/core/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/AwsMqComponentBuilderFactory.java
@@ -71,6 +71,19 @@ public interface AwsMqComponentBuilderFactory {
             return this;
         }
         /**
+         * The Component configuration.
+         * 
+         * The option is a:
+         * <code>org.apache.camel.component.aws.mq.MQConfiguration</code> type.
+         * 
+         * Group: producer
+         */
+        default AwsMqComponentBuilder configuration(
+                org.apache.camel.component.aws.mq.MQConfiguration configuration) {
+            doSetProperty("configuration", configuration);
+            return this;
+        }
+        /**
          * Whether the producer should be started lazy (on the first message).
          * By starting lazy you can use this to allow CamelContext and routes to
          * startup in situations where a producer may otherwise fail during
@@ -179,19 +192,6 @@ public interface AwsMqComponentBuilderFactory {
             doSetProperty("basicPropertyBinding", basicPropertyBinding);
             return this;
         }
-        /**
-         * The AWS MQ default configuration.
-         * 
-         * The option is a:
-         * <code>org.apache.camel.component.aws.mq.MQConfiguration</code> type.
-         * 
-         * Group: advanced
-         */
-        default AwsMqComponentBuilder configuration(
-                org.apache.camel.component.aws.mq.MQConfiguration configuration) {
-            doSetProperty("configuration", configuration);
-            return this;
-        }
     }
 
     class AwsMqComponentBuilderImpl
@@ -216,17 +216,17 @@ public interface AwsMqComponentBuilderFactory {
                 String name,
                 Object value) {
             switch (name) {
-            case "accessKey": ((MQComponent) component).setAccessKey((java.lang.String) value); return true;
+            case "accessKey": getOrCreateConfiguration((MQComponent) component).setAccessKey((java.lang.String) value); return true;
             case "amazonMqClient": getOrCreateConfiguration((MQComponent) component).setAmazonMqClient((com.amazonaws.services.mq.AmazonMQ) value); return true;
+            case "configuration": ((MQComponent) component).setConfiguration((org.apache.camel.component.aws.mq.MQConfiguration) value); return true;
             case "lazyStartProducer": ((MQComponent) component).setLazyStartProducer((boolean) value); return true;
             case "operation": getOrCreateConfiguration((MQComponent) component).setOperation((org.apache.camel.component.aws.mq.MQOperations) value); return true;
             case "proxyHost": getOrCreateConfiguration((MQComponent) component).setProxyHost((java.lang.String) value); return true;
             case "proxyPort": getOrCreateConfiguration((MQComponent) component).setProxyPort((java.lang.Integer) value); return true;
             case "proxyProtocol": getOrCreateConfiguration((MQComponent) component).setProxyProtocol((com.amazonaws.Protocol) value); return true;
             case "region": getOrCreateConfiguration((MQComponent) component).setRegion((java.lang.String) value); return true;
-            case "secretKey": ((MQComponent) component).setSecretKey((java.lang.String) value); return true;
+            case "secretKey": getOrCreateConfiguration((MQComponent) component).setSecretKey((java.lang.String) value); return true;
             case "basicPropertyBinding": ((MQComponent) component).setBasicPropertyBinding((boolean) value); return true;
-            case "configuration": ((MQComponent) component).setConfiguration((org.apache.camel.component.aws.mq.MQConfiguration) value); return true;
             default: return false;
             }
         }