camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [camel] 01/03: CAMEL-13041 - Camel-AWS MQ: Create Broker operation is not working
Date Tue, 08 Jan 2019 13:54:34 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 016b725e50b15b426e8619ce4aa8704e2d42d049
Author: Andrea Cosentino <ancosen@gmail.com>
AuthorDate: Tue Jan 8 14:20:21 2019 +0100

    CAMEL-13041 - Camel-AWS MQ: Create Broker operation is not working
    
    Conflicts:
    	components/camel-aws/src/main/java/org/apache/camel/component/aws/mq/MQProducer.java
    	components/camel-aws/src/test/java/org/apache/camel/component/aws/mq/MQProducerSpringTest.java
    	components/camel-aws/src/test/java/org/apache/camel/component/aws/mq/MQProducerTest.java
---
 .../apache/camel/component/aws/mq/MQConstants.java |  4 +++
 .../apache/camel/component/aws/mq/MQProducer.java  | 35 +++++++++++++++++++++-
 .../component/aws/mq/MQProducerSpringTest.java     | 16 +++++++++-
 .../camel/component/aws/mq/MQProducerTest.java     | 16 +++++++++-
 4 files changed, 68 insertions(+), 3 deletions(-)

diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/mq/MQConstants.java
b/components/camel-aws/src/main/java/org/apache/camel/component/aws/mq/MQConstants.java
index 19f4c65..31ef98f 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/mq/MQConstants.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/mq/MQConstants.java
@@ -24,7 +24,11 @@ public interface MQConstants {
     String OPERATION                = "CamelAwsMQOperation";
     String MAX_RESULTS              = "CamelAwsMQMaxResults";
     String BROKER_NAME              = "CamelAwsMQBrokerName";
+    String BROKER_ENGINE            = "CamelAwsMQBrokerEngine";
+    String BROKER_ENGINE_VERSION    = "CamelAwsMQBrokerEngineVersion";
     String BROKER_ID                = "CamelAwsMQBrokerID";
     String CONFIGURATION_ID         = "CamelAwsMQConfigurationID";
     String BROKER_DEPLOYMENT_MODE   = "CamelAwsMQBrokerDeploymentMode";
+    String BROKER_INSTANCE_TYPE     = "CamelAwsMQBrokerInstanceType";
+    String BROKER_USERS             = "CamelAwsMQBrokerUsers";
 }
diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/mq/MQProducer.java
b/components/camel-aws/src/main/java/org/apache/camel/component/aws/mq/MQProducer.java
index 0151770..176a8e8 100644
--- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/mq/MQProducer.java
+++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/mq/MQProducer.java
@@ -23,12 +23,15 @@ import com.amazonaws.services.mq.model.CreateBrokerRequest;
 import com.amazonaws.services.mq.model.CreateBrokerResult;
 import com.amazonaws.services.mq.model.DeleteBrokerRequest;
 import com.amazonaws.services.mq.model.DeleteBrokerResult;
+import com.amazonaws.services.mq.model.DeploymentMode;
+import com.amazonaws.services.mq.model.EngineType;
 import com.amazonaws.services.mq.model.ListBrokersRequest;
 import com.amazonaws.services.mq.model.ListBrokersResult;
 import com.amazonaws.services.mq.model.RebootBrokerRequest;
 import com.amazonaws.services.mq.model.RebootBrokerResult;
 import com.amazonaws.services.mq.model.UpdateBrokerRequest;
 import com.amazonaws.services.mq.model.UpdateBrokerResult;
+import com.amazonaws.services.mq.model.User;
 
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
@@ -41,6 +44,8 @@ import org.slf4j.LoggerFactory;
 
 import static org.apache.camel.component.aws.common.AwsExchangeUtil.getMessageForResponse;
 
+import java.util.List;
+
 /**
  * A Producer which sends messages to the Amazon MQ Service
  * <a href="http://aws.amazon.com/mq/">AWS MQ</a>
@@ -121,7 +126,11 @@ public class MQProducer extends DefaultProducer {
 
     private void createBroker(AmazonMQ mqClient, Exchange exchange) {
         String brokerName;
+        String brokerEngine;
+        String brokerEngineVersion;
         String deploymentMode;
+        String instanceType;
+        List<User> users;
         CreateBrokerRequest request = new CreateBrokerRequest();
         if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQConstants.BROKER_NAME)))
{
             brokerName = exchange.getIn().getHeader(MQConstants.BROKER_NAME, String.class);
@@ -129,10 +138,34 @@ public class MQProducer extends DefaultProducer {
         } else {
             throw new IllegalArgumentException("Broker Name must be specified");
         }
+        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQConstants.BROKER_ENGINE)))
{
+            brokerEngine = exchange.getIn().getHeader(MQConstants.BROKER_ENGINE, String.class);
+            request.withEngineType(EngineType.fromValue(brokerEngine));
+        } else {
+            request.withEngineType(EngineType.ACTIVEMQ.name());
+        }
+        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQConstants.BROKER_ENGINE_VERSION)))
{
+            brokerEngineVersion = exchange.getIn().getHeader(MQConstants.BROKER_ENGINE_VERSION,
String.class);
+            request.withEngineVersion(brokerEngineVersion);
+        } else {
+            throw new IllegalArgumentException("Broker Engine Version must be specified");
+        }
         if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQConstants.BROKER_DEPLOYMENT_MODE)))
{
             deploymentMode = exchange.getIn().getHeader(MQConstants.BROKER_DEPLOYMENT_MODE,
String.class);
             request.withDeploymentMode(deploymentMode);
         }
+        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQConstants.BROKER_INSTANCE_TYPE)))
{
+            instanceType = exchange.getIn().getHeader(MQConstants.BROKER_INSTANCE_TYPE, String.class);
+            request.withHostInstanceType(instanceType);
+        } else {
+            throw new IllegalArgumentException("Instance Type must be specified");
+        }
+        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(MQConstants.BROKER_USERS)))
{
+            users = exchange.getIn().getHeader(MQConstants.BROKER_USERS, List.class);
+            request.withUsers(users);
+        } else {
+            throw new IllegalArgumentException("A Users list must be specified");
+        }
         CreateBrokerResult result;
         try {
             result = mqClient.createBroker(request);
@@ -210,4 +243,4 @@ public class MQProducer extends DefaultProducer {
         Message message = getMessageForResponse(exchange);
         message.setBody(result);
     }
-}
\ No newline at end of file
+}
diff --git a/components/camel-aws/src/test/java/org/apache/camel/component/aws/mq/MQProducerSpringTest.java
b/components/camel-aws/src/test/java/org/apache/camel/component/aws/mq/MQProducerSpringTest.java
index f14e39d..1c77fb2 100644
--- a/components/camel-aws/src/test/java/org/apache/camel/component/aws/mq/MQProducerSpringTest.java
+++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/mq/MQProducerSpringTest.java
@@ -21,8 +21,13 @@ import com.amazonaws.services.mq.model.ConfigurationId;
 import com.amazonaws.services.mq.model.CreateBrokerResult;
 import com.amazonaws.services.mq.model.DeleteBrokerResult;
 import com.amazonaws.services.mq.model.DeploymentMode;
+import com.amazonaws.services.mq.model.EngineType;
 import com.amazonaws.services.mq.model.ListBrokersResult;
 import com.amazonaws.services.mq.model.UpdateBrokerResult;
+import com.amazonaws.services.mq.model.User;
+
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.camel.EndpointInject;
 import org.apache.camel.Exchange;
@@ -67,6 +72,15 @@ public class MQProducerSpringTest extends CamelSpringTestSupport {
                 exchange.getIn().setHeader(MQConstants.OPERATION, MQOperations.createBroker);
                 exchange.getIn().setHeader(MQConstants.BROKER_NAME, "test");
                 exchange.getIn().setHeader(MQConstants.BROKER_DEPLOYMENT_MODE, DeploymentMode.SINGLE_INSTANCE);
+                exchange.getIn().setHeader(MQConstants.BROKER_INSTANCE_TYPE, "mq.t2.micro");
+                exchange.getIn().setHeader(MQConstants.BROKER_ENGINE, EngineType.ACTIVEMQ.name());
+                exchange.getIn().setHeader(MQConstants.BROKER_ENGINE_VERSION, "5.15.6");
+                List<User> users = new ArrayList<>();
+                User user = new User();
+                user.setUsername("camel");
+                user.setPassword("camelcamel12");
+                users.add(user);
+                exchange.getIn().setHeader(MQConstants.BROKER_USERS, users);
             }
         });
         
@@ -146,4 +160,4 @@ public class MQProducerSpringTest extends CamelSpringTestSupport {
     protected ClassPathXmlApplicationContext createApplicationContext() {
         return new ClassPathXmlApplicationContext("org/apache/camel/component/aws/mq/MQComponentSpringTest-context.xml");
     }
-}
\ No newline at end of file
+}
diff --git a/components/camel-aws/src/test/java/org/apache/camel/component/aws/mq/MQProducerTest.java
b/components/camel-aws/src/test/java/org/apache/camel/component/aws/mq/MQProducerTest.java
index 1bd449d..d028c05 100644
--- a/components/camel-aws/src/test/java/org/apache/camel/component/aws/mq/MQProducerTest.java
+++ b/components/camel-aws/src/test/java/org/apache/camel/component/aws/mq/MQProducerTest.java
@@ -21,8 +21,13 @@ import com.amazonaws.services.mq.model.ConfigurationId;
 import com.amazonaws.services.mq.model.CreateBrokerResult;
 import com.amazonaws.services.mq.model.DeleteBrokerResult;
 import com.amazonaws.services.mq.model.DeploymentMode;
+import com.amazonaws.services.mq.model.EngineType;
 import com.amazonaws.services.mq.model.ListBrokersResult;
 import com.amazonaws.services.mq.model.UpdateBrokerResult;
+import com.amazonaws.services.mq.model.User;
+
+import java.util.ArrayList;
+import java.util.List;
 
 import org.apache.camel.EndpointInject;
 import org.apache.camel.Exchange;
@@ -67,6 +72,15 @@ public class MQProducerTest extends CamelTestSupport {
                 exchange.getIn().setHeader(MQConstants.OPERATION, MQOperations.createBroker);
                 exchange.getIn().setHeader(MQConstants.BROKER_NAME, "test");
                 exchange.getIn().setHeader(MQConstants.BROKER_DEPLOYMENT_MODE, DeploymentMode.SINGLE_INSTANCE);
+                exchange.getIn().setHeader(MQConstants.BROKER_INSTANCE_TYPE, "mq.t2.micro");
+                exchange.getIn().setHeader(MQConstants.BROKER_ENGINE, EngineType.ACTIVEMQ.name());
+                exchange.getIn().setHeader(MQConstants.BROKER_ENGINE_VERSION, "5.15.6");
+                List<User> users = new ArrayList<>();
+                User user = new User();
+                user.setUsername("camel");
+                user.setPassword("camelcamel12");
+                users.add(user);
+                exchange.getIn().setHeader(MQConstants.BROKER_USERS, users);
             }
         });
         
@@ -165,4 +179,4 @@ public class MQProducerTest extends CamelTestSupport {
             }
         };
     }
-}
\ No newline at end of file
+}


Mime
View raw message