gus-maurizio opened a new issue #1431:
URL: https://github.com/apache/camel-quarkus/issues/1431


   This is a question, any help appreciated. Migrating from Spring boot, I have 
some specific needs to define for AWS-S3 a client configuration. In XML DSL is 
like this:
   `<?xml version="1.0" encoding="UTF-8"?>
   <beans xmlns="http://www.springframework.org/schema/beans"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
          xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd";>
   
     <bean id="awsDefaultCredentialsProviderChain" 
class="com.amazonaws.auth.DefaultAWSCredentialsProviderChain" />
     <bean id="awsClientConfigEndpoint" 
class="com.amazonaws.ClientConfiguration">
     </bean>
     <bean id="s3"                     
class="org.apache.camel.component.aws.s3.S3Component" />
     <bean id="vpcs3Client-us-east-1"  
class="com.amazonaws.services.s3.AmazonS3Client">
       <constructor-arg index="0"    ref="awsClientConfigEndpoint" />
       <property name="endpoint"     value="${client.s3.us-east-1}" />
     </bean>
   
   </beans>
   
   `
   I have been trying to migrate this to Java DSL to no avail, this is as far 
as I could get, but cannot make it work:
   `mport org.apache.camel.builder.RouteBuilder;
   
   import javax.inject.Inject;
   import java.io.File;
   import java.util.List;
   
   // import software.amazon.awssdk.services.s3.S3Client;
   import com.amazonaws.ClientConfiguration;
   import com.amazonaws.Protocol;
   import com.amazonaws.auth.AWSCredentials;
   import com.amazonaws.auth.AWSCredentialsProvider;
   import com.amazonaws.auth.BasicAWSCredentials;
   import com.amazonaws.auth.InstanceProfileCredentialsProvider;
   import com.amazonaws.http.IdleConnectionReaper;
   import com.amazonaws.internal.StaticCredentialsProvider;
   import com.amazonaws.services.s3.AmazonS3;
   import com.amazonaws.services.s3.AmazonS3Client;
   import com.amazonaws.services.s3.AmazonS3ClientBuilder;
   import com.amazonaws.services.s3.S3ClientOptions;
   import com.amazonaws.regions.Regions;
   
   
   import org.apache.camel.CamelContext;
   import org.apache.camel.spi.Registry;
   import org.apache.camel.impl.SimpleRegistry;
   import org.apache.camel.impl.CompositeRegistry;
   
   public class CamelRouteS3 extends RouteBuilder {
   
        // @Inject
        // S3Client s3Client;
   
       // @Inject
       // CamelContext camelContext;
   
       // AWSCredentials awsCredentials = new 
BasicAWSCredentials("myAccessKey", "mySecretKey");
   
       // ClientConfiguration clientConfiguration = new ClientConfiguration();
       // clientConfiguration.setProxyHost("http://myProxyHost";);
       // clientConfiguration.setProxyPort(8080);
   
       AmazonS3 s3client = 
AmazonS3ClientBuilder.standard().withRegion(Regions.US_EAST_1).build();
   
       SimpleRegistry registry = new SimpleRegistry();
       registry.put("s3client", (AmazonS3)s3client);
       CamelContext ctx = new DefaultCamelContext(registry);
   
       // SimpleRegistry registry = new SimpleRegistry();
       // ((SimpleRegistry)registry).put("bean-name", new SomeBean());
       // registry.put("s3client", s3client);
       // CamelContext camelContext = getContext();
       // 
camelContext.getRegistry(CompositeRegistry.class).addRegistry(registry);
   
       // CamelContext camelContext = getContext();
       // SimpleRegistry registry = new org.apache.camel.impl.SimpleRegistry();
       // CompositeRegistry compositeRegistry = new CompositeRegistry();
       // compositeRegistry.addRegistry(camelContext.getRegistry());
       // compositeRegistry.addRegistry(registry);
       // registry.bind("s3Client", s3client);
       // camelContext.getRegistry().bind("s3Client", s3client);
       // registry.bind("s3client", s3client);    
   
       public void configure() {
        
        // 
from("aws-s3://helloBucket?prefix=hello.txt&useIAMCredentials=true&region={{camel.aws.region}}&proxyHost={{camel.proxy.host}}&proxyPort={{camel.proxy.port}}&proxyProtocol={{camel.proxy.protocol}}")
        // 
from("aws-s3://{{camel.bucket}}?prefix={{camel.object}}&useIAMCredentials=true&region={{camel.aws.region}}")
           
from("aws-s3://{{camel.bucket}}?prefix={{camel.object}}&amazonS3Client=#s3Client&useIAMCredentials=true")
           .routeId("s3read")
           .streamCaching()
           .to("log:s3?level=INFO&showAll=true");
   
   
       }
   }`
   
   I understand the beans.xml cannot be used as such. Any hints or pointers 
will be appreciated.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to