[ 
https://issues.apache.org/jira/browse/CAMEL-14992?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17120292#comment-17120292
 ] 

Jon Chase commented on CAMEL-14992:
-----------------------------------

If things go according to plan, I should have a PR up this weekend.

Here's what I wound up with in terms of the URI feel:
{code:java}
@Override
protected RouteBuilder createRouteBuilder() {
  return new RouteBuilder() {
    @Override
    public void configure() {
      // String awsCreds = "&accessKey=xxx&secretKey=yyy&region=eu-west-1";
      String awsCreds = "amazonAthenaClient=#athenaClient";

      from("direct:athenaGetQueryExecutionTest")
          .setBody(constant("SELECT 1"))
          
.to("aws2-athena://label?operation=startQueryExecution&outputLocation=" + 
s3Bucket + "&" + awsCreds)
          .to("aws2-athena://label?operation=getQueryExecution&" + awsCreds);

      from("direct:athenaGetQueryResultsAsStreamListTest")
          .setBody(constant(
              "SELECT * FROM ("
                  + "    VALUES"
                  + "        (1, 'a'),"
                  + "        (2, 'b')"
                  + ") AS t (id, name)"))
          
.to("aws2-athena://label?operation=startQueryExecution&waitTimeout=60000&outputLocation="
 + s3Bucket + "&" + awsCreds)
          
.to("aws2-athena://label?operation=getQueryResults&outputType=StreamList&" + 
awsCreds);

      from("direct:athenaGetQueryResultsAsSelectListTest")
          .setBody(constant(
              "SELECT * FROM ("
                  + "    VALUES"
                  + "        (1, 'a'),"
                  + "        (2, 'b')"
                  + ") AS t (id, name)"))
          
.to("aws2-athena://label?operation=startQueryExecution&waitTimeout=60000&outputLocation="
 + s3Bucket + "&" + awsCreds)
          
.to("aws2-athena://label?operation=getQueryResults&outputType=SelectList&" + 
awsCreds);

      from("direct:athenaGetQueryResultsAsS3PointerTest")
          .setBody(constant("SELECT 1"))
          
.to("aws2-athena://label?operation=startQueryExecution&waitTimeout=60000&outputLocation="
 + s3Bucket + "&" + awsCreds)
          
.to("aws2-athena://label?operation=getQueryResults&outputType=S3Pointer&" + 
awsCreds);

      from("direct:athenaListQueryExecutionsTest")
          .setBody(constant("SELECT 1"))
          
.to("aws2-athena://label?operation=startQueryExecution&outputLocation=" + 
s3Bucket + "&" + awsCreds)
          .to("aws2-athena://label?operation=listQueryExecutions&" + awsCreds);

      from("direct:athenaListQueryExecutionsSetsNextTokenTest")
          .loop(2)
            .setBody(constant("SELECT 1"))
            
.to("aws2-athena://label?operation=startQueryExecution&outputLocation=" + 
s3Bucket + "&" + awsCreds)
          .end()
          .to("aws2-athena://label?operation=listQueryExecutions&maxResults=1&" 
+ awsCreds);

      from("direct:athenaStartQueryExecutionIncludesTraceInQuery")
          .setBody(constant("SELECT 1"))
          
.to("aws2-athena://label?operation=startQueryExecution&includeTrace=true&outputLocation="
 + s3Bucket + "&" + awsCreds)
          .to("aws2-athena://label?operation=getQueryExecution&" + awsCreds);

      from("direct:athenaStartQueryExecutionWaitForQueryCompletionTest")
          .setBody(constant("SELECT 1"))
          
.to("aws2-athena://label?operation=startQueryExecution&waitTimeout=60000&outputLocation="
 + s3Bucket + "&" + awsCreds);

      
from("direct:athenaStartQueryExecutionByDefaultDoesNotWaitForCompletionTest")
          .setBody(constant("SELECT 1"))
          
.to("aws2-athena://label?operation=startQueryExecution&outputLocation=" + 
s3Bucket + "&" + awsCreds);

      from("direct:athenaStartQueryExecutionHandlesInvalidSqlTest")
          .setBody(constant("SELECT INVALID SQL")) // parses, but query fails 
to complete
          
.to("aws2-athena://label?operation=startQueryExecution&waitTimeout=60000&maxAttempts=3&retry=always&outputLocation="
 + s3Bucket + "&" + awsCreds);

      from("direct:athenaStartQueryExecutionHandlesMalformedSqlTest")
          .setBody(constant("MALFORMED SQL")) // unparseable by athena
          
.to("aws2-athena://label?operation=startQueryExecution&waitTimeout=60000&maxAttempts=3&outputLocation="
 + s3Bucket + "&" + awsCreds);

      from("direct:athenaStartQueryExecutionTest")
          .setBody(constant("SELECT 1"))
          
.to("aws2-athena://label?operation=startQueryExecution&outputLocation=" + 
s3Bucket + "&" + awsCreds);

      from("direct:athenaStartQueryExecutionAndGetQueryExecutionUsingHeaders")
          .setBody(constant("SELECT 1"))
          
.to("aws2-athena://label?operation=startQueryExecution&outputLocation=" + 
s3Bucket + "&" + awsCreds)
          .to("aws2-athena://label?operation=getQueryExecution&" + awsCreds);

      
from("direct:athenaStartQueryExecutionAndGetQueryResultsByWaitingWithALoop")
          .setBody(constant("SELECT 1"))
          
.to("aws2-athena://label?operation=startQueryExecution&outputLocation=" + 
s3Bucket + "&" + awsCreds)
          .loopDoWhile(simple("${header." + 
Athena2Constants.QUERY_EXECUTION_STATE + "} != 'SUCCEEDED'"))
            .delay(1_000)
            .to("aws2-athena://label?operation=getQueryExecution&" + awsCreds)
          .end()
          
.to("aws2-athena://label?operation=getQueryResults&outputType=S3Pointer&" + 
awsCreds);
    }
  };
}
 {code}
 

> Create a Camel AWS2 Athena component
> ------------------------------------
>
>                 Key: CAMEL-14992
>                 URL: https://issues.apache.org/jira/browse/CAMEL-14992
>             Project: Camel
>          Issue Type: New Feature
>          Components: camel-aws2
>            Reporter: Andrea Cosentino
>            Assignee: Andrea Cosentino
>            Priority: Major
>             Fix For: 3.x
>
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to