Reputation: 3018
I am trying to build an auto sync application. The files should just be copied if e.g. the content has changed. Since I am new to camel and I didn't find anything I would like to know if it is possible to somehow compare the target file with the source file (if there is one).
public class App {
public static void main(String[] args) {
final long durationMs = 2000;
final CamelContext camelContext = new DefaultCamelContext();
try {
camelContext.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("file:/home/av/Schreibtisch/src?noop=true&recursive=true&maxDepth=100")
.to("file:/home/av/Schreibtisch/target");
}
});
camelContext.start();
Thread.sleep(durationMs);
camelContext.stop();
} catch (Exception camelException) {
camelException.printStackTrace();
}
}
}
Upvotes: 0
Views: 46
Reputation: 2294
There is a whole section in Apache Camel documentation to see how to avoid consuming a certain file under certain condtions. idempotent
and idempotentKey
are the solution here.
Maybe your discriminatory conditions to tell if the file is already consumed would be :
${file:name}-${file:size}
)${file:name}-${file:modified}
)For example, to use the size of the file. It would be something along the lines of:
from("file:/somedir?noop=true&idempotentKey=${file:name}-${file:size}")
Upvotes: 2