[
https://issues.apache.org/jira/browse/CAMEL-12647?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16542965#comment-16542965
]
ASF GitHub Bot commented on CAMEL-12647:
----------------------------------------
oscerd closed pull request #2424: CAMEL-12647 : Problem in setting region for
camel AWS-SQS endpoint
URL: https://github.com/apache/camel/pull/2424
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponent.java
b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponent.java
index 655f92e5b55..89a0e92ba5b 100644
---
a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponent.java
+++
b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sns/SnsComponent.java
@@ -18,6 +18,7 @@
import java.util.Map;
+import com.amazonaws.regions.Regions;
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
import org.apache.camel.impl.DefaultComponent;
@@ -54,7 +55,12 @@ protected Endpoint createEndpoint(String uri, String
remaining, Map<String, Obje
throw new IllegalArgumentException("Topic name must be
specified.");
}
if (remaining.startsWith("arn:")) {
+ String[] parts = remaining.split(":");
+ if (parts.length != 6 || !parts[2].equals("sns")) {
+ throw new IllegalArgumentException("Topic arn must be in
format arn:aws:sns:region:account:name.");
+ }
configuration.setTopicArn(remaining);
+ configuration.setRegion(Regions.fromName(parts[3]).toString());
} else {
configuration.setTopicName(remaining);
}
diff --git
a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsComponent.java
b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsComponent.java
index e21610b0dc7..e09f76cbad8 100644
---
a/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsComponent.java
+++
b/components/camel-aws/src/main/java/org/apache/camel/component/aws/sqs/SqsComponent.java
@@ -18,6 +18,7 @@
import java.util.Map;
+import com.amazonaws.regions.Regions;
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
import org.apache.camel.impl.DefaultComponent;
@@ -60,7 +61,7 @@ protected Endpoint createEndpoint(String uri, String
remaining, Map<String, Obje
if (parts.length != 6 || !parts[2].equals("sqs")) {
throw new IllegalArgumentException("Queue arn must be in
format arn:aws:sqs:region:account:name.");
}
- configuration.setRegion(parts[3]);
+ configuration.setRegion(Regions.fromName(parts[3]).toString());
configuration.setQueueOwnerAWSAccountId(parts[4]);
configuration.setQueueName(parts[5]);
} else {
diff --git
a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java
b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java
index 329263ff63a..0e564698407 100644
---
a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java
+++
b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sns/SnsComponentConfigurationTest.java
@@ -61,10 +61,10 @@ public void createEndpointWithMinimalArnConfiguration()
throws Exception {
((JndiRegistry) ((PropertyPlaceholderDelegateRegistry)
context.getRegistry()).getRegistry()).bind("amazonSNSClient", mock);
SnsComponent component = new SnsComponent(context);
- SnsEndpoint endpoint = (SnsEndpoint)
component.createEndpoint("aws-sns://arn:aws:sns:region:account:MyTopic?amazonSNSClient=#amazonSNSClient&accessKey=xxx&secretKey=yyy");
+ SnsEndpoint endpoint = (SnsEndpoint)
component.createEndpoint("aws-sns://arn:aws:sns:us-east-1:account:MyTopic?amazonSNSClient=#amazonSNSClient&accessKey=xxx&secretKey=yyy");
assertNull(endpoint.getConfiguration().getTopicName());
- assertEquals("arn:aws:sns:region:account:MyTopic",
endpoint.getConfiguration().getTopicArn());
+ assertEquals("arn:aws:sns:us-east-1:account:MyTopic",
endpoint.getConfiguration().getTopicArn());
}
@Test
diff --git
a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java
b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java
index 240a48b2a31..2699482d716 100644
---
a/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java
+++
b/components/camel-aws/src/test/java/org/apache/camel/component/aws/sqs/SqsComponentConfigurationTest.java
@@ -73,9 +73,9 @@ public void createEndpointWithMinimalArnConfiguration()
throws Exception {
((JndiRegistry) ((PropertyPlaceholderDelegateRegistry)
context.getRegistry()).getRegistry()).bind("amazonSQSClient", mock);
SqsComponent component = new SqsComponent(context);
- SqsEndpoint endpoint = (SqsEndpoint)
component.createEndpoint("aws-sqs://arn:aws:sqs:region:account:MyQueue?amazonSQSClient=#amazonSQSClient&accessKey=xxx&secretKey=yyy");
+ SqsEndpoint endpoint = (SqsEndpoint)
component.createEndpoint("aws-sqs://arn:aws:sqs:us-east-1:account:MyQueue?amazonSQSClient=#amazonSQSClient&accessKey=xxx&secretKey=yyy");
- assertEquals("region", endpoint.getConfiguration().getRegion());
+ assertEquals("US_EAST_1", endpoint.getConfiguration().getRegion());
assertEquals("account",
endpoint.getConfiguration().getQueueOwnerAWSAccountId());
assertEquals("MyQueue", endpoint.getConfiguration().getQueueName());
assertEquals("xxx", endpoint.getConfiguration().getAccessKey());
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Problem in setting region for camel AWS-SQS endpoint
> ----------------------------------------------------
>
> Key: CAMEL-12647
> URL: https://issues.apache.org/jira/browse/CAMEL-12647
> Project: Camel
> Issue Type: Bug
> Components: camel-aws
> Affects Versions: 2.21.1
> Reporter: Saravanakumar Selvaraj
> Assignee: Andrea Cosentino
> Priority: Major
> Fix For: 2.21.2, 2.22.1, 2.23.0
>
>
> It gives FailedToCreateRouteException while creating camel AWS-SQS endpoint
> with ARN.
> For example, below producer or consumer endpoint is not being created.
> {code:java}
> uri="aws-sqs://arn:aws:sqs:us-east-2:account:MyQueue?accessKey=xxx&secretKey=yyy®ion=US_EAST_2"{code}
> And it throws error as follows.
> {code:java}
> Caused by: java.lang.IllegalArgumentException: No enum constant
> com.amazonaws.regions.Regions.us-east-2
> at java.lang.Enum.valueOf(Enum.java:238)
> at com.amazonaws.regions.Regions.valueOf(Regions.java:26)
> at
> org.apache.camel.component.aws.sqs.SqsEndpoint.createClient(SqsEndpoint.java:310)
> {code}
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)