You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Hilde <hi...@yahoo.de> on 2012/05/04 13:53:53 UTC
Component file: move and moveFailed
Dear Listener!
I have a route that starts with a file consumer that has the options 'move'
and 'moveFailed' configured.
After the file component has given away the file to the subsequent process
an exception is thrown that
will be handled via the exception policy (onException with handled=false).
The problem is that the beginning file component does not register the
exception and therefore the csv
file is always moved to the directory /.done/ instead of /.error/.
How can I notify the file component that the process is failed with the
result to move the csv file to
/.error/? My understanding actually was that the file component should
handle this for itself once
the option 'move' and 'moveFailed' are configured!? :-(
I am using Apache Camel version 2.9.0. The /Default Error Handler/ is used.
At next you can find the camel route I am talking about:
<camel:endpoint id="fileInEndpoint"
uri="file://[[configDir]]?filter=#Filter&move=.done/${file:name.noext}-${date:now:yyyy_MM_dd_HH_mm_ss}.${file:ext}
&moveFailed=.error/${file:name.noext}-${date:now:yyyy_MM_dd_HH_mm_ss}.${file:ext}&delay=10000"
/>
<camel:onException>
<camel:exception>java.lang.IllegalArgumentException</camel:exception>
<camel:exception>javax.validation.ValidationException</camel:exception>
<camel:to uri="seda:logger" />
</camel:onException>
<camel:route id="readConfig">
<camel:from ref="fileInEndpoint" />
<camel:onCompletion>
<camel:bean ref="reset" method="resetRepo" />
</camel:onCompletion>
<camel:setHeader headerName="operationName">
<camel:simple>Import</camel:simple>
</camel:setHeader>
<camel:unmarshal ref="bindyDataformat" />
...
</camel:route>
Many thanks in advanced!
Best regards
Hilde
--
View this message in context: http://camel.465427.n5.nabble.com/Component-file-move-and-moveFailed-tp5685631.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Component file: move and moveFailed
Posted by Claus Ibsen <cl...@gmail.com>.
On Fri, May 4, 2012 at 2:25 PM, Hilde <hi...@yahoo.de> wrote:
> I have forgotten to notice that the file component acts as expected as soon
> as I
> remove the exception policy (onException). However we need that for writing
> an protocol.
>
Yeah I can see this is a possible mistake, as your onException don't
handle the exception, which is then propagated
back to the file consumer. But there is a glitch in the logic that
checks for if the exchange failed.
Let me log a JIRA, and get that fixed.
> --
> View this message in context: http://camel.465427.n5.nabble.com/Component-file-move-and-moveFailed-tp5685631p5685713.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: Component file: move and moveFailed
Posted by Hilde <hi...@yahoo.de>.
Generally an issue regarding locking I can exclude because the file is always
moved to the .done directory instead of .error.
--
View this message in context: http://camel.465427.n5.nabble.com/Component-file-move-and-moveFailed-tp5685631p5697111.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Component file: move and moveFailed
Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, May 9, 2012 at 1:04 PM, Hilde <hi...@yahoo.de> wrote:
> The files being processed with camel afterwards are not moved to that
> directory programmatically but also droped in the directory manually. As a
> result there can no open file stream remain.
>
Read about the read-lock strategies you have at
http://camel.apache.org/file2
eg the idea is to avoid reading files while other parties is currently
writing them. And that depends on what file system you use etc, what
you can do.
> --
> View this message in context: http://camel.465427.n5.nabble.com/Component-file-move-and-moveFailed-tp5685631p5697076.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: Component file: move and moveFailed
Posted by Hilde <hi...@yahoo.de>.
The files being processed with camel afterwards are not moved to that
directory programmatically but also droped in the directory manually. As a
result there can no open file stream remain.
--
View this message in context: http://camel.465427.n5.nabble.com/Component-file-move-and-moveFailed-tp5685631p5697076.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Component file: move and moveFailed
Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, May 9, 2012 at 11:06 AM, Hilde <hi...@yahoo.de> wrote:
> Hello Claus!
>
> Can you tell me definitely whether my camel configuration causes the issue
> or it's inside the Apache Camel 2.9.0 version?
>
No I cannot. You have to dig yourself.
When on Windows then make extra care to ensure to close file streams,
as windows locks those file handlers for a very long time.
> Best regards
> Hilde
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Component-file-move-and-moveFailed-tp5685631p5696843.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: Component file: move and moveFailed
Posted by Hilde <hi...@yahoo.de>.
Hello Claus!
Can you tell me definitely whether my camel configuration causes the issue
or it's inside the Apache Camel 2.9.0 version?
Best regards
Hilde
--
View this message in context: http://camel.465427.n5.nabble.com/Component-file-move-and-moveFailed-tp5685631p5696843.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Component file: move and moveFailed
Posted by Hilde <hi...@yahoo.de>.
Hello Claus!
Here comes the full camel route:
<camel:endpoint id="fileInEndpoint"
uri="file://[[configDir]]?filter=#filter&move=.done/${file:name.noext}-${date:now:yyyy_MM_dd_HH_mm_ss}.${file:ext}&moveFailed=.error/${file:name.noext}-${date:now:yyyy_MM_dd_HH_mm_ss}.${file:ext}&delay=10000"
/>
<camel:onException>
<camel:exception>java.lang.IllegalArgumentException</camel:exception>
<camel:exception>javax.validation.ValidationException</camel:exception>
<handled>
<constant>false</constant>
</handled>
<camel:transform>
<camel:simple>Error reported - cannot proceed:
${exception.message}
${exception.stacktrace}
</camel:simple>
</camel:transform>
<camel:to
uri="log:importlog?level=ERROR&showAll=true&multiline=true" />
<camel:setHeader headerName="Subject">
<camel:simple>Failure while reading configuration file</camel:simple>
</camel:setHeader>
<camel:setHeader headerName="From">
<camel:constant>[[fromMail]]</camel:constant>
</camel:setHeader>
<camel:setHeader headerName="to">
<camel:simple>${ref:defaultMail.defaultContact}</camel:simple>
</camel:setHeader>
<camel:bean ref="mailProcess" />
<camel:setBody>
<camel:simple>Failure while reading configuration file:
${exception.message}</camel:simple>
</camel:setBody>
<camel:setHeader headerName="success">
<camel:constant>false</camel:constant>
</camel:setHeader>
<camel:to uri="seda:logger" />
<camel:to ref="failMail" />
</camel:onException>
<camel:route id="readConfig">
<camel:from ref="fileInEndpoint" />
<camel:onCompletion>
<camel:bean ref="reset" method="resetRepo" />
</camel:onCompletion>
<camel:transacted ref="PROPAGATION_REQUIRED" />
<camel:to uri="sql:update name set readyForChange =
1?dataSourceRef=dataSource" />
<camel:setHeader headerName="operationName">
<camel:simple>Import</camel:simple>
</camel:setHeader>
<camel:unmarshal ref="bindyDataformat" />
<camel:split stopOnException="true" strategyRef="importProtokollStrategy">
<camel:simple>${body}</camel:simple>
<camel:idempotentConsumer messageIdRepositoryRef="myRepo"
eager="true" skipDuplicate="false">
<camel:simple>${body.values()[0].brandId}</camel:simple>
<camel:filter>
<camel:property>CamelDuplicateMessage</camel:property>
<camel:throwException ref="validationException" />
<camel:stop />
</camel:filter>
<camel:bean ref="convertToEntities" />
<camel:to uri="jpa://org.cameltest.entity.Name?flushOnSend=false" />
<camel:bean ref="addToRunninDataRelease" />
</camel:idempotentConsumer>
</camel:split>
<camel:setHeader headerName="success">
<camel:constant>true</camel:constant>
</camel:setHeader>
<camel:process ref="inactivateNames" />
<camel:bean ref="commentAggregator" />
<camel:to uri="seda:logger" />
</camel:route>
--
View this message in context: http://camel.465427.n5.nabble.com/Component-file-move-and-moveFailed-tp5685631p5690355.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Component file: move and moveFailed
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Can you post your full route, and the code you do in the onException.
It ought to work out of the box, so I wonder what's the issue you see.
On Fri, May 4, 2012 at 2:25 PM, Hilde <hi...@yahoo.de> wrote:
> I have forgotten to notice that the file component acts as expected as soon
> as I
> remove the exception policy (onException). However we need that for writing
> an protocol.
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Component-file-move-and-moveFailed-tp5685631p5685713.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: Component file: move and moveFailed
Posted by Hilde <hi...@yahoo.de>.
I have forgotten to notice that the file component acts as expected as soon
as I
remove the exception policy (onException). However we need that for writing
an protocol.
--
View this message in context: http://camel.465427.n5.nabble.com/Component-file-move-and-moveFailed-tp5685631p5685713.html
Sent from the Camel - Users mailing list archive at Nabble.com.