You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by shekher awasthi <sh...@gmail.com> on 2011/08/09 12:10:38 UTC
Question regarding File Component
Hi,
After going through what all was available about File component ,i still
have one query regarding the working of this component
i have configured route something like this
from("file:data/csv?fileName=input-customer3.csv").to("file:data/csvoutput")
since i have specified specific file name in side the csv directory and as
per my assumptions Camel file component should try to look for this exact
file
but what i observe is that it not showing any error/exception about the file
name (i have intentionaly give wrong file name which does not exist) when
the file with specified name is not there,it keep polling the location till
i am not closing the context
Is it a intentioanly defined way of working?
is there any way camel can notify back that such file does not exist in the
specified location?
Thanks in advance
Re: Question regarding File Component
Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Aug 9, 2011 at 12:10 PM, shekher awasthi
<sh...@gmail.com> wrote:
> Hi,
>
> After going through what all was available about File component ,i still
> have one query regarding the working of this component
>
> i have configured route something like this
>
> from("file:data/csv?fileName=input-customer3.csv").to("file:data/csvoutput")
>
> since i have specified specific file name in side the csv directory and as
> per my assumptions Camel file component should try to look for this exact
> file
>
> but what i observe is that it not showing any error/exception about the file
> name (i have intentionaly give wrong file name which does not exist) when
> the file with specified name is not there,it keep polling the location till
> i am not closing the context
>
>
>
> Is it a intentioanly defined way of working?
Yes that is how it works. Its a filter. So it only pickup files
matching any filter criteria you setup.
>
> is there any way camel can notify back that such file does not exist in the
> specified location?
>
You can configure a custom
org.apache.camel.spi.PollingConsumerPollStrategy on the file endpoint,
which has callbacks.
For example it will invoke the commit method with polledMessages=0 in
case there was 0 files polled.
http://camel.apache.org/polling-consumer.html
from("file:data/csv?fileName=input-customer3.csv&pollStrategy=#myPollStrategy").to("file:data/csvoutput")
And then you need to register your custom PollingConsumerPollStrategy
in the Registry with the bean id "myPollStrategy".
If you use a Spring XML file then its simply just
<bean id="myPollStrategy" class="com.mycompany...."/>
>
>
> Thanks in advance
>
--
Claus Ibsen
-----------------
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/