From 9030299add2a60e2938dbd8dafbf8e589ebef519 Mon Sep 17 00:00:00 2001 From: Saurabh Kr Singh Date: Tue, 12 Mar 2013 20:31:07 +0530 Subject: [PATCH 1/2] making change so that we can use camel-aws integration to make use of other implementations of AmazonSQS instead of tightly binding it to AmazonSQSClient. making change so that we can use camel-aws integration to make use of other implementations of AmazonSQS instead of tightly binding it to AmazonSQSClient. For example this also allows us to make use of AmazonSQSBufferedAsyncClient if we want to. --- .gitignore | 4 ++++ .../camel/component/aws/sqs/SqsConfiguration.java | 8 ++++---- .../apache/camel/component/aws/sqs/SqsConsumer.java | 4 ++-- .../apache/camel/component/aws/sqs/SqsEndpoint.java | 11 ++++++----- .../apache/camel/component/aws/sqs/SqsProducer.java | 6 +++--- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 394c1748e8b08..2dffc9e8dde37 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,7 @@ target .checkstyle *.log dependency-reduced-pom.xml + +setEnv.sh + +tests/camel-itest/src/test/lib/camel-validator-test-resources-1.0.0-sources.jar.lastUpdated diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsConfiguration.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsConfiguration.java index e7bd2375ae8a1..c0295e3c2e17b 100644 --- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsConfiguration.java +++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsConfiguration.java @@ -18,7 +18,7 @@ import java.util.Collection; -import com.amazonaws.services.sqs.AmazonSQSClient; +import com.amazonaws.services.sqs.AmazonSQS; /** * The AWS SQS component configuration properties @@ -28,7 +28,7 @@ public class SqsConfiguration { // common properties private String queueName; - private AmazonSQSClient amazonSQSClient; + private AmazonSQS amazonSQSClient; private String accessKey; private String secretKey; private String amazonSQSEndpoint; @@ -90,11 +90,11 @@ public void setDeleteAfterRead(Boolean deleteAfterRead) { this.deleteAfterRead = deleteAfterRead; } - public AmazonSQSClient getAmazonSQSClient() { + public AmazonSQS getAmazonSQSClient() { return amazonSQSClient; } - public void setAmazonSQSClient(AmazonSQSClient amazonSQSClient) { + public void setAmazonSQSClient(AmazonSQS amazonSQSClient) { this.amazonSQSClient = amazonSQSClient; } diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsConsumer.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsConsumer.java index 5d5b01bc4b9af..5ed50487af68f 100644 --- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsConsumer.java +++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsConsumer.java @@ -24,7 +24,7 @@ import java.util.concurrent.TimeUnit; import com.amazonaws.AmazonClientException; -import com.amazonaws.services.sqs.AmazonSQSClient; +import com.amazonaws.services.sqs.AmazonSQS; import com.amazonaws.services.sqs.model.ChangeMessageVisibilityRequest; import com.amazonaws.services.sqs.model.DeleteMessageRequest; import com.amazonaws.services.sqs.model.Message; @@ -208,7 +208,7 @@ protected SqsConfiguration getConfiguration() { return getEndpoint().getConfiguration(); } - protected AmazonSQSClient getClient() { + protected AmazonSQS getClient() { return getEndpoint().getClient(); } diff --git a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsEndpoint.java b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsEndpoint.java index 3e117d22cfbd3..9d34001e2f3a6 100644 --- a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsEndpoint.java +++ b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsEndpoint.java @@ -21,6 +21,7 @@ import com.amazonaws.auth.AWSCredentials; import com.amazonaws.auth.BasicAWSCredentials; import com.amazonaws.services.sqs.AmazonSQSClient; +import com.amazonaws.services.sqs.AmazonSQS; import com.amazonaws.services.sqs.model.CreateQueueRequest; import com.amazonaws.services.sqs.model.CreateQueueResult; import com.amazonaws.services.sqs.model.ListQueuesResult; @@ -47,7 +48,7 @@ public class SqsEndpoint extends ScheduledPollEndpoint { private static final transient Logger LOG = LoggerFactory.getLogger(SqsEndpoint.class); - private AmazonSQSClient client; + private AmazonSQS client; private String queueUrl; private SqsConfiguration configuration; private int maxMessagesPerPoll; @@ -94,7 +95,7 @@ protected void doStart() throws Exception { } } - private void createQueue(AmazonSQSClient client) { + private void createQueue(AmazonSQS client) { LOG.trace("Queue '{}' doesn't exist. Will create it...", configuration.getQueueName()); // creates a new queue, or returns the URL of an existing one @@ -122,7 +123,7 @@ private void createQueue(AmazonSQSClient client) { LOG.trace("Queue created and available at: {}", queueUrl); } - private void updateQueueAttributes(AmazonSQSClient client) { + private void updateQueueAttributes(AmazonSQS client) { SetQueueAttributesRequest request = new SetQueueAttributesRequest(); request.setQueueUrl(queueUrl); if (getConfiguration().getDefaultVisibilityTimeout() != null) { @@ -177,14 +178,14 @@ public void setConfiguration(SqsConfiguration configuration) { this.configuration = configuration; } - public AmazonSQSClient getClient() { + public AmazonSQS getClient() { if (client == null) { client = createClient(); } return client; } - public void setClient(AmazonSQSClient client) { + public void setClient(AmazonSQS client) { this.client = client; } 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 0cfd25b14e104..d67ce29b99b4c 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 @@ -16,7 +16,7 @@ */ package org.apache.camel.component.aws.sqs; -import com.amazonaws.services.sqs.AmazonSQSClient; +import com.amazonaws.services.sqs.AmazonSQS; import com.amazonaws.services.sqs.model.SendMessageRequest; import com.amazonaws.services.sqs.model.SendMessageResult; @@ -59,7 +59,7 @@ public void process(Exchange exchange) throws Exception { private void addDelay(SendMessageRequest request, Exchange exchange) { Integer headerValue = exchange.getIn().getHeader(SqsConstants.DELAY_HEADER, Integer.class); - Integer delayValue = Integer.valueOf(0); + Integer delayValue; if (headerValue == null) { LOG.trace("Using the config delay"); delayValue = getEndpoint().getConfiguration().getDelaySeconds(); @@ -81,7 +81,7 @@ private Message getMessageForResponse(Exchange exchange) { return exchange.getIn(); } - protected AmazonSQSClient getClient() { + protected AmazonSQS getClient() { return getEndpoint().getClient(); } From f7de9320b1fb4994c0dba4b3ad2821358b4e6222 Mon Sep 17 00:00:00 2001 From: Saurabh Kr Singh Date: Tue, 12 Mar 2013 21:10:33 +0530 Subject: [PATCH 2/2] reverting unnecessary change --- .gitignore | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index 2dffc9e8dde37..9dc1974bf9a82 100644 --- a/.gitignore +++ b/.gitignore @@ -9,8 +9,4 @@ target .settings .checkstyle *.log -dependency-reduced-pom.xml - -setEnv.sh - -tests/camel-itest/src/test/lib/camel-validator-test-resources-1.0.0-sources.jar.lastUpdated +dependency-reduced-pom.xml \ No newline at end of file