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:40:10 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 70d4133b59d91be1ae3f8ba66550ca32c1efaad8
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
---
 .../apache/camel/component/aws/mq/MQConstants.java |  4 +++
 .../apache/camel/component/aws/mq/MQProducer.java  | 32 ++++++++++++++++++++++
 .../component/aws/mq/MQProducerSpringTest.java     | 14 ++++++++++
 .../camel/component/aws/mq/MQProducerTest.java     | 14 ++++++++++
 4 files changed, 64 insertions(+)

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 6e697e9..cb27a18 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
@@ -26,12 +26,14 @@ import com.amazonaws.services.mq.model.DeleteBrokerResult;
 import com.amazonaws.services.mq.model.DeploymentMode;
 import com.amazonaws.services.mq.model.DescribeBrokerRequest;
 import com.amazonaws.services.mq.model.DescribeBrokerResult;
+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;
@@ -44,6 +46,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>
@@ -127,7 +131,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);
@@ -135,12 +143,36 @@ 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.fromValue(deploymentMode));
         } else {
             throw new IllegalArgumentException("Deployment Mode must be specified");
         }
+        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);
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 ace9f00..2397c66 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
@@ -22,8 +22,13 @@ 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.DescribeBrokerResult;
+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;
@@ -68,6 +73,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);
             }
         });
         
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 b3e4ccb..2da87e6 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
@@ -22,8 +22,13 @@ 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.DescribeBrokerResult;
+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;
@@ -68,6 +73,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);
             }
         });
         


Mime
View raw message