I believe OnCompletion is called on each exchange. One file should be one exchange, so each file would generate a call to OnCompletion.
If polling is restricted to 20 files at a time, that should still be 20 exchanges, resulting in 20 calls to OnCompletion. Don On Mon, Sep 12, 2011 at 10:45 AM, OrackBahama <jdorfsch...@metadok.de> wrote: > Hi, > > although I've read several posts for this, I'm quite unsure if the > "onCompletion" construct will fit my needs. > As far as I've understood, this is a hook that's called after completion of > the route (when defined in front of the "from" ...). > > I'll explain my problem in the following example. > I want to process the files in a directory and every file should result in > one log entry - successful or not. > Then, after all files have been processed, the logfile should be closed and > transferred back to the customer. > > Assume, we have 100 files -> then the logfile contains 100 lines. > Question: If I restrict the messages per poll (let's say twenty) - will that > result in 5 calls of "onCompletion" (and 5 logfiles with 20 lines) ? Is that > meant with "UnitOfWork" ? > > public class CompletionTestRouteBuilder extends RouteBuilder > { > > /***************************************************************************** > * > * @throws Exception > > ****************************************************************************/ > @Override > public void configure() throws Exception > { > onCompletion() > // close whole logfile and transfer it to customer > // contains one line per processed file > // purpose: one logfile per directory poll/UnitOfWork > ... > ; > > from( "file:C:/tmp/inbox" // + "?maxMessagesPerPoll=20" > ) > > // process file and write log entry per-file in logfile > ... > .to( "file:C:/tmp/outbox" ) > ; > } > } > > > Hopefully someone could explain a bit - thanks in advance ! > > Best regards > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Global-onCompletion-tp4794456p4794456.html > Sent from the Camel - Users mailing list archive at Nabble.com. >