Hey,

You might want to look at the Splitter's stopOnException and
shareUnitOfWork options [1].

[1] https://camel.apache.org/splitter.html

Regards,

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Wed, Sep 2, 2015 at 11:28 PM, furchess123 <con...@hotmail.com> wrote:

> Hi,
> I am using Splitter to read and process files line by line. The Splitter
> definition is actually a small nested route within the parent main route.
> The Splitter tokenizes by line breaks and groups lines into N lines before
> handing them to the processor bean. If a system/application exception
> occurs
> processing any particular group of lines from the file, I want the route to
> stop processing the file and jump to the end of the parent route.
>
> Right now, I have my exception handling configured in the following way (to
> handle all uncaught application errors):
>
>
>
> *onException(Exception.class).process(errorHandler).handled(true).to("direct:writeToErrorFileEndpoint");*
>
> where "/direct:writeToErrorFileEndpoint/" is the starting endpoint of
> another tiny route that writes out the error report accumulated in the
> exchange.
>
> The way it works now: any system error that occurs during the given file
> fragment (group of lines) processing is handled by my /errorHandler/ bean,
> the error report is appended to the errors file, and the next group of
> lines
> is picked up by the Splitter, and so on... So, the file is always read to
> the very end.
>
> What I want is to STOP processing the file after the first system error is
> caught and handled. I think it may have worked as I wanted before I
> extracted then splitter part into its own route - for code clarity, but, in
> any case, I am looking for the best strategy to instantly - and gracefully
> -
> complete the Main route if any system exception occurs (an exception that
> indicates a programming or system error and does not have a specific
> handler) without processing the rest of the file, or stopping the route.
>
> Thanks for any advice.
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Stopping-file-reading-via-splitter-on-exception-tp5771181.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Reply via email to