Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolving Dependency Automatically -- aws-s3 #419

Closed
kameshsampath opened this issue Feb 11, 2019 · 2 comments
Closed

Resolving Dependency Automatically -- aws-s3 #419

kameshsampath opened this issue Feb 11, 2019 · 2 comments
Labels
status/waiting-for-feedback Needs some feedback

Comments

@kameshsampath
Copy link
Contributor

When creating a route using aws-s3(http://camel.apache.org/aws-s3.html) , the deployment fails with error

file-organizer-5849bb5579-lm596 file-organizer Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: aws-s3://data?accessKey=demoacesskey&amazonS3Endpoint=http%3A%2F%2Fminio.cookbook%3A9000&secretKey=demosecretkey due to: No component found with scheme: aws-s3
file-organizer-5849bb5579-lm596 file-organizer 	at org.apache.camel.impl.DefaultCamelContext.getEndpoint(DefaultCamelContext.java:759)
file-organizer-5849bb5579-lm596 file-organizer 	at org.apache.camel.util.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:80)
file-organizer-5849bb5579-lm596 file-organizer 	at org.apache.camel.model.RouteDefinition.resolveEndpoint(RouteDefinition.java:227)
file-organizer-5849bb5579-lm596 file-organizer 	at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:116)
file-organizer-5849bb5579-lm596 file-organizer 	at org.apache.camel.impl.DefaultRouteContext.resolveEndpoint(DefaultRouteContext.java:122)
file-organizer-5849bb5579-lm596 file-organizer 	at org.apache.camel.model.FromDefinition.resolveEndpoint(FromDefinition.java:75)
file-organizer-5849bb5579-lm596 file-organizer 	at org.apache.camel.impl.DefaultRouteContext.getEndpoint(DefaultRouteContext.java:98)
file-organizer-5849bb5579-lm596 file-organizer 	at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:1332)
file-organizer-5849bb5579-lm596 file-organizer 	at org.apache.camel.model.RouteDefinition.addRoutes(RouteDefinition.java:212)
file-organizer-5849bb5579-lm596 file-organizer 	... 13 more

Route

import org.apache.camel.builder.RouteBuilder;

/**
 * FileOrganizer
 */
public class FileOrganizer extends RouteBuilder {

    @Override
    public void configure() throws Exception {

        from("aws-s3://data?amazonS3Endpoint={{s3EndpointUrl}}" + "&accessKey={{minioAccessKey}}"
                + "&secretKey={{minioSecretKey}}").to("log:message");
    }

}
@kameshsampath kameshsampath changed the title Resolving Dependency Automatically Resolving Dependency Automatically -- aws-s3 Feb 11, 2019
lburgazzoli added a commit to lburgazzoli/apache-camel-k that referenced this issue Feb 11, 2019
@kameshsampath
Copy link
Contributor Author

it.yaml

apiVersion: camel.apache.org/v1alpha1
kind: Integration
metadata:
  creationTimestamp: 2019-02-11T16:50:39Z
  generation: 1
  name: file-organizer
  namespace: cookbook
  resourceVersion: "40155"
  selfLink: /apis/camel.apache.org/v1alpha1/namespaces/cookbook/integrations/file-organizer
  uid: 29658d87-2e1d-11e9-97f5-42010aa00009
spec:
  configuration:
  - type: secret
    value: s3config
  dependencies:
  - camel:aws
  sources:
  - content: |
      import com.amazonaws.auth.AWSCredentials;
      import com.amazonaws.auth.AWSCredentialsProvider;
      import com.amazonaws.auth.AWSStaticCredentialsProvider;
      import com.amazonaws.auth.BasicAWSCredentials;
      import com.amazonaws.client.builder.AwsClientBuilder.EndpointConfiguration;
      import com.amazonaws.services.s3.AmazonS3;
      import com.amazonaws.services.s3.AmazonS3ClientBuilder;
      import org.apache.camel.builder.RouteBuilder;
      import org.apache.camel.component.aws.s3.S3Component;

      /**
       * FileOrganizer
       */
      public class FileOrganizer extends RouteBuilder {

          @Override
          public void configure() throws Exception {

              S3Component s3Component = getContext().getComponent("aws-s3", S3Component.class);
              s3Component.getConfiguration().setAmazonS3Client(amazonS3Client());
              from("aws-s3://data").to("log:message");
          }

          AmazonS3 amazonS3Client() throws Exception {
              final String s3EndpointUrl = getContext().resolvePropertyPlaceholders("{{s3EndpointUrl}}");
              final String minioAccessKey =
                      getContext().resolvePropertyPlaceholders("{{minioAccessKey}}");
              final String minioSecretKey =
                      getContext().resolvePropertyPlaceholders("{{minioSecretKey}}");

              EndpointConfiguration endpointConfiguration =
                      new EndpointConfiguration(s3EndpointUrl, null);
              AWSCredentials credentials = new BasicAWSCredentials(minioAccessKey, minioSecretKey);
              AWSCredentialsProvider credentialsProvider = new AWSStaticCredentialsProvider(credentials);
              AmazonS3ClientBuilder clientBuilder =
                      AmazonS3ClientBuilder.standard().withCredentials(credentialsProvider)
                              .withEndpointConfiguration(endpointConfiguration);
              return clientBuilder.build();
          }

      }
    name: FileOrganizer.java
status:
  context: ctx-bhgpqgg938dlliepild0
  dependencies:
  - camel:aws
  - camel:core
  - runtime:jvm
  digest: vZpVeIJMmQaAvwhJH-QeVMRYwR4m2atgps6Zm7VychIw
  image: docker-registry.default.svc:5000/cookbook/camel-k-ctx-bhgpqgg938dlliepild0:34798
  phase: Running

@lburgazzoli
Copy link
Contributor

lburgazzoli commented Feb 11, 2019

I did try with camel-k from master and I'm unable to reproduce the issue:

[1] 2019-02-11 18:12:44.976 INFO  [main] RoutesConfigurer - Loading routes from: file:/etc/camel/sources/FileOrganizer.java?language=java
[1] 2019-02-11 18:12:46.843 INFO  [main] DefaultCamelContext - Apache Camel 2.23.1 (CamelContext: camel-k) is starting
[1] 2019-02-11 18:12:46.846 INFO  [main] ManagedManagementStrategy - JMX is enabled
[1] 2019-02-11 18:12:47.022 INFO  [main] DefaultTypeConverter - Type converters loaded (core: 195, classpath: 2)
[1] 2019-02-11 18:12:47.132 INFO  [main] DefaultCamelContext - StreamCaching is not in use. If using streams then its recommended to enable stream caching. See more details at http://camel.apache.org/stream-caching.html
[1] 2019-02-11 18:12:47.548 INFO  [main] DefaultCamelContext - Apache Camel 2.23.1 (CamelContext: camel-k) is shutting down
[1] 2019-02-11 18:12:47.558 INFO  [main] MainLifecycleStrategy - CamelContext: camel-k has been shutdown, triggering shutdown of the JVM.
[1] 2019-02-11 18:12:47.571 INFO  [main] DefaultCamelContext - Apache Camel 2.23.1 (CamelContext: camel-k) uptime 0.727 seconds
[1] 2019-02-11 18:12:47.572 INFO  [main] DefaultCamelContext - Apache Camel 2.23.1 (CamelContext: camel-k) is shutdown in 0.024 seconds
[1] Exception in thread "main" org.apache.camel.FailedToCreateRouteException: Failed to create route route1: Route(route1)[[From[aws-s3://data]] -> [To[log:message]]] because of Unable to execute HTTP request: data.s3EndpointUrl
[1] 	at org.apache.camel.impl.RouteService.warmUp(RouteService.java:147)
[1] 	at org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:3953)
[1] 	at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3860)
[1] 	at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:3646)
[1] 	at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3489)
[1] 	at org.apache.camel.impl.DefaultCamelContext$4.call(DefaultCamelContext.java:3248)
[1] 	at org.apache.camel.impl.DefaultCamelContext$4.call(DefaultCamelContext.java:3244)
[1] 	at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:3267)
[1] 	at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:3244)
[1] 	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:72)
[1] 	at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:3160)
[1] 	at org.apache.camel.k.jvm.ApplicationRuntime$Main.doStart(ApplicationRuntime.java:108)
[1] 	at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:72)
[1] 	at org.apache.camel.main.MainSupport.run(MainSupport.java:170)
[1] 	at org.apache.camel.k.jvm.ApplicationRuntime.run(ApplicationRuntime.java:66)
[1] 	at org.apache.camel.k.jvm.Application.main(Application.java:56)

The failure here is expected as I have not configured any property but component is properly resolved

@lburgazzoli lburgazzoli added the status/waiting-for-feedback Needs some feedback label Mar 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/waiting-for-feedback Needs some feedback
Projects
None yet
Development

No branches or pull requests

2 participants