Author: tjsnell
Date: Fri Jan 11 02:20:42 2013
New Revision: 1431813
URL: http://svn.apache.org/viewvc?rev=1431813&view=rev
Log:
CAMEL-5944 - Setting extendMessageVisibility on an SQS consumer
Modified:
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsComponent.java
camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java
Modified:
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsComponent.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsComponent.java?rev=1431813&r1=1431812&r2=1431813&view=diff
==============================================================================
---
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsComponent.java
(original)
+++
camel/trunk/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsComponent.java
Fri Jan 11 02:20:42 2013
@@ -48,7 +48,12 @@ public class SqsComponent extends Defaul
if (configuration.getAmazonSQSClient() == null &&
(configuration.getAccessKey() == null || configuration.getSecretKey() == null))
{
throw new IllegalArgumentException("AmazonSQSClient or accessKey
and secretKey must be specified.");
}
-
+
+ // Verify that visibilityTimeout is set if extendMessageVisibility is
set to true.
+ if (configuration.isExtendMessageVisibility() &&
(configuration.getVisibilityTimeout() == null)) {
+ throw new IllegalArgumentException("Extending message visibilty
(extendMessageVisibility) requires visibilityTimeout to be set on the
Endpoint.");
+ }
+
SqsEndpoint sqsEndpoint = new SqsEndpoint(uri, this, configuration);
sqsEndpoint.setConsumerProperties(parameters);
return sqsEndpoint;
Modified:
camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java?rev=1431813&r1=1431812&r2=1431813&view=diff
==============================================================================
---
camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java
(original)
+++
camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java
Fri Jan 11 02:20:42 2013
@@ -121,4 +121,23 @@ public class SqsComponentConfigurationTe
SqsComponent component = new SqsComponent(context);
component.createEndpoint("aws-sqs://MyQueue?accessKey=xxx");
}
+
+ // Setting extendMessageVisibility on an SQS consumer should make
visibilityTimeout compulsory
+ @Test(expected = IllegalArgumentException.class)
+ public void
createEndpointWithExtendMessageVisibilityAndNoVisibilityTimeoutThrowsException()
throws Exception {
+ SqsComponent component = new SqsComponent(context);
+
component.createEndpoint("aws-sqs://MyQueue?accessKey=xxx&secretKey=yyy&extendMessageVisibility=true");
+ }
+
+ @Test
+ public void
createEndpointWithExtendMessageVisibilityTrueAndVisibilityTimeoutSet() throws
Exception {
+ SqsComponent component = new SqsComponent(context);
+
assertNotNull(component.createEndpoint("aws-sqs://MyQueue?accessKey=xxx&secretKey=yyy&visibilityTimeout=30&extendMessageVisibility=true"));
+ }
+
+ @Test
+ public void
createEndpointWithExtendMessageVisibilityFalseAndVisibilityTimeoutSet() throws
Exception {
+ SqsComponent component = new SqsComponent(context);
+
assertNotNull(component.createEndpoint("aws-sqs://MyQueue?accessKey=xxx&secretKey=yyy&visibilityTimeout=30&extendMessageVisibility=false"));
+ }
}
\ No newline at end of file