camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Larry Meadors <>
Subject File consumer - waiting for it to start
Date Fri, 03 Feb 2012 21:15:46 GMT
I have what I think is a simple route:

public void configure() throws Exception {
  .setHeader(S3Constants.KEY, simple("${header.CamelFileNameOnly}"))
  .setHeader(S3Constants.CONTENT_LENGTH, simple("${header.CamelFileLength}"))

It's just taking files from a directory and copying them to an s3 bucket.

What I'm seeing is that when I start it up, it stops immediately, so I
end up doing this:

// create the route - the parameters are the source, then the destination
DirectCopyRoute directCopyRoute = new DirectCopyRoute(arg[0], arg[1]);

// create the camel context and start it
CamelContext camelContext = new DefaultCamelContext();

// give it time to realize it has work to do

If I remove the Thread.sleep call, it just starts and stops.

Adding that seems to make it work, but I'm wondering why?

I'm guessing the "why" is that it takes a bit of time to create the
list of files to process, and since there is nothing pending to
process, camel figures it's done what it was supposed to, and shuts
down - adding the delay gives the file consumer time to create the
list of files to process, and once it's started, it goes until it's

It that's the case, it leads to a second question: Will 1 second be
long enough to work if the source directory contains a LOT of files?

Normally, the directory will only have a few hundred files, but it may
have a few thousand, and it may be accessing a shared directory over a
network, so the time required to get a directory listing may vary.

Is there a smarter way to do this?


View raw message