camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From OrackBahama <>
Subject Global onCompletion
Date Mon, 12 Sep 2011 14:45:43 GMT

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 
  public void configure() throws Exception
      // 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:
Sent from the Camel - Users mailing list archive at

View raw message