You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by nguyen <qu...@gmail.com> on 2013/10/01 00:23:30 UTC

Camel route - how to move the file in the failed directory if there's an error

Hi all, i'm new in camel, so thanks in advance for any help.I have the
following route defined in my context file.      This route is using in the
context of a spring batch job.	I would like to do the following:If the my
batch job fails, because there's an error in my input file, for example if
the number of lines in the files are not correctly defined in the footer, i
would like that file to be moved to the "failed" directory after the file is
processed. The current behavior, is the file moved to the "done" directory.
Is it possible to do that? If yes, can you please help, thanks !!!



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-route-how-to-move-the-file-in-the-failed-directory-if-there-s-an-error-tp5740611.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Camel route - how to move the file in the failed directory if there's an error

Posted by Claus Ibsen <cl...@gmail.com>.
camel-spring-batch would have to fail with an exception for the file
consumer to move the file to the failed directory.

Not sure how spring batch triggers this. I suggest to dive into the
source code / unit tests to take a look.

On Tue, Oct 1, 2013 at 12:31 AM, nguyen <qu...@gmail.com> wrote:
> Oups the route didn't show.. Inserted now the route definition.
>
> <camelContext id="transactionBatchRoutes"
> xmlns="http://camel.apache.org/schema/spring">
> <route id="transactionFileRoute">
>         <description>
>                 Route to poll a directory for transaction alert file and launch the job
>         </description>
>         <from
>
> uri="file:{{batch.process.watch.directory}}?include={{transaction.file.name.pattern}}&amp;delay={{transaction.file.poll.delay}}&amp;doneFileName=${file:name}.sig&amp;move={{batch.process.done.directory}}&amp;moveFailed={{batch.process.failed.directory}}"
> />
>             <setHeader headerName="fileName">
>                 <simple>${headers.CamelFileNameOnly}</simple>
>            </setHeader>
>
> <to uri="spring-batch:transactionFileJob?jobLauncherRef=jobLauncher" />
>                 </route>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-route-how-to-move-the-file-in-the-failed-directory-if-there-s-an-error-tp5740611p5740613.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Camel route - how to move the file in the failed directory if there's an error

Posted by nguyen <qu...@gmail.com>.
Oups the route didn't show.. Inserted now the route definition. 

<camelContext id="transactionBatchRoutes"
xmlns="http://camel.apache.org/schema/spring">
<route id="transactionFileRoute">
	<description>
		Route to poll a directory for transaction alert file and launch the job
	</description>
	<from
	 
uri="file:{{batch.process.watch.directory}}?include={{transaction.file.name.pattern}}&amp;delay={{transaction.file.poll.delay}}&amp;doneFileName=${file:name}.sig&amp;move={{batch.process.done.directory}}&amp;moveFailed={{batch.process.failed.directory}}"
/>
	    <setHeader headerName="fileName">
		<simple>${headers.CamelFileNameOnly}</simple>
	   </setHeader>

<to uri="spring-batch:transactionFileJob?jobLauncherRef=jobLauncher" />
		</route>
	



--
View this message in context: http://camel.465427.n5.nabble.com/Camel-route-how-to-move-the-file-in-the-failed-directory-if-there-s-an-error-tp5740611p5740613.html
Sent from the Camel - Users mailing list archive at Nabble.com.