You're the man, Claus. ;-) I added a "direct:stop" route to my builder with the cleanup and shutdown code in it.
I changed my route to send a message to it using "onCompletion().onWhen(header(Exchange.BATCH_COMPLETE).isEqualTo(true))", and blammo! It all works exactly how I wanted it to. Amazing what one line will do. :) Thanks! Off to the test environment to get it verified by the client. :D Larry On Tue, Feb 7, 2012 at 12:19 AM, Claus Ibsen <claus.ib...@gmail.com> wrote: > On Tue, Feb 7, 2012 at 4:41 AM, Larry Meadors <larry.mead...@gmail.com> 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 > > onCompletion().onWhen(header(Exchange.BATCH_COMPLETE).isEqualTo(true)) > .xxxx > .end(); > > > > >> 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" <larry.mead...@gmail.com> 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 files...so 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 running...so 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 processed...so 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 > ----------------- > FuseSource > Email: cib...@fusesource.com > Web: http://fusesource.com > Twitter: davsclaus, fusenews > Blog: http://davsclaus.blogspot.com/ > Author of Camel in Action: http://www.manning.com/ibsen/