camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: File consumer - waiting for it to start
Date Tue, 07 Feb 2012 07:19:12 GMT
On Tue, Feb 7, 2012 at 4:41 AM, Larry Meadors <> wrote:
> Just had a thought - couldn't I use the file component as a batch consumer,
> then know when it had consumed all of the files and trigger my cleanup code
> based on that, then have that trigger the shutdown?

Yes the file consumer is a batch consumer, so it enrich the message
with details.

You can just add add a onWhen predicate to your onCompletion, to only
trigger when the batch is complete.
Exchange.BATCH_COMPLETE == true

Something alike


> Not at my computer at the moment, I'll have to try it in the morning.
> Larry
> On Feb 6, 2012 4:22 PM, "Larry Meadors" <> wrote:
>> Wow, this thread is growing and what I thought was a simple task is
>> turning into a bit of a mess. :-/
>> Here's what I'm trying to accomplish:
>>  - I have a directory with files in it
>>  - I want to process every file in that directory
>>  - Once I have processed *all* of the files, I want my app to execute
>> some cleanup code and then shut down
>> The original issue was that when I started up the app, it shut down
>> immediately and didn't process any I changed my code to use
>> the Main class to keep it running until it was done.
>> That worked, but then it wouldn't *stop* and I couldn't run my cleanup
>> code.
>> It processed all the files, but stayed I added the
>> shutdown thing in an onCompletion block, thinking (erroneously) that
>> the onCompletion code would run at the end after ALL files were
>> processed.
>> Now I see that the code in onCompletion() is running after every file
>> is it gets one or two files, then shuts down. Which
>> looks like the expected behavior, now that I'm re-reading that section
>> in the CIA book.
>> Can someone point me to an example that shows how to do what I'm
>> trying to do here?
>> The issue seems to be knowing when I'm done (all the files have been
>> consumed). Is there a way to do that? Is it documented anywhere?
>> Does sendEmptyMessageWhenIdle=true mean that it'll send a null message
>> after processing all of the files or only if there are no files when
>> it starts?
>> Larry

Claus Ibsen
Twitter: davsclaus, fusenews
Author of Camel in Action:

View raw message