1
votes
import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;

public class ReadFileExample {
public static void main(String [] args) throws Exception{
    System.out.println("trying to copy file");
    CamelContext ctx = new DefaultCamelContext();
    RouteBuilder route = new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("file://Users/aranja2/Documents/in/?fileName=sample.txt&charset=utf-8")
             .to("file://Users/aranja2/Documents/out/?fileName=sample.txt&charset=utf-8");
        }
    };
    ctx.addRoutes(route);
    ctx.start();
    // Maybe sleep a little here
    // Thread.sleep(4000);
    ctx.stop();
 }
}

I am using camel to copy files but it is not happening.I am using mac. The messages thrown are

[main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.16.2 (CamelContext: camel-1) is starting [main] INFO org.apache.camel.management.ManagedManagementStrategy - JMX is enabled [main] INFO org.apache.camel.impl.converter.DefaultTypeConverter - Loaded 183 type converters [main] INFO org.apache.camel.impl.DefaultRuntimeEndpointRegistry - Runtime endpoint registry is in extended mode gathering usage statistics of all incoming and outgoing endpoints (cache limit: 1000) [main] INFO org.apache.camel.impl.DefaultCamelContext - AllowUseOriginalMessage is enabled. If access to the original message is not needed, then its recommended to turn this option off as it may improve performance. [main] INFO org.apache.camel.impl.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 [main] INFO org.apache.camel.component.file.FileEndpoint - Endpoint is configured with noop=true so forcing endpoint to be idempotent as well [main] INFO org.apache.camel.component.file.FileEndpoint - Using default memory based idempotent repository with cache max size: 1000 [main] INFO org.apache.camel.impl.DefaultCamelContext - Route: route1 started and consuming from: Endpoint[file://Users/aranja2/Documents/in/?noop=true] [main] INFO org.apache.camel.impl.DefaultCamelContext - Total 1 routes, of which 1 is started. [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.16.2 (CamelContext: camel-1) started in 0.344 seconds [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.16.2 (CamelContext: camel-1) is shutting down [main] INFO org.apache.camel.impl.DefaultShutdownStrategy - Starting to graceful shutdown 1 routes (timeout 300 seconds) [Camel (camel-1) thread #1 - ShutdownTask] INFO org.apache.camel.impl.DefaultShutdownStrategy - Route: route1 shutdown complete, was consuming from: Endpoint[file://Users/aranja2/Documents/in/?noop=true] [main] INFO org.apache.camel.impl.DefaultShutdownStrategy - Graceful shutdown of 1 routes completed in 0 seconds [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.16.2 (CamelContext: camel-1) uptime 0.359 seconds [main] INFO org.apache.camel.impl.DefaultCamelContext - Apache Camel 2.16.2 (CamelContext: camel-1) is shutdown in 0.007 seconds

1

1 Answers

0
votes

are you sure you are reaching that directory on //Users/aranja2/Documents/in/?fileName=sample.txt? You rout seems ok. I've attached a sample project with a route copying from one directory to another. This ruse use the same parameter fileName as yours. You can run it just it mvn camel:run

https://drive.google.com/file/d/0B9AooXd3hwFyWjZ4aEFRc0Znam8/view?usp=sharing

Cheers!