On Fri, May 25, 2012 at 7:52 PM, Nestor Urquiza
<nestor.urqu...@gmail.com> wrote:
> Thanks Clous. Your answers brought me back to earth.
>
> I think I missed the point about what the ftp components and any other Camel
> component is about (Producer/Consumer). I was trying to activate a route
> from a seda component and then only at that point try to test for the
> existence of a file in the remote SFTP. If that is what I need I should use
> just a bean and not really the component. If the need is to constantly check
> for the file existence then we just use the Polling Consumer pattern.
>
> My needs (send an email when there is a new file) could be covered (tested
> and it works) with a filter like below:
> <code>
>        public class FileAttributesFilter<T> implements GenericFileFilter<T> {
>
>        public boolean accept(GenericFile<T> file) {
>            return file.getLastModified() + RECONNECT_DELAY_MSEC >
> System.currentTimeMillis();
>        }
>    }
> </code>
>
> However the next question is how to make sure two JVMs running the same
> Camel routes do not compete with each other. If I use a persisted quartz
> route and a bean I can be sure that only one one JVM will run the quartz
> StatefulJob which can produce the message for a unique end point in that VM.
> How can I achieve the same with the Camel FTP Consumer?
>

You can for example use a route policy and figure out the locking
strategy yourself.
http://camel.apache.org/routepolicy

Maybe tie that into quartz clustering support somehow.


The Fuse Fabric has a Camel master component that does a master/slave
for Camel routes in a cluster.
https://github.com/fusesource/fuse/blob/master/fabric/fabric-camel/src/main/java/org/fusesource/fabric/camel/MasterComponent.java

Does not updated yet
http://fuse.fusesource.org/fabric/docs/user-guide.html#Camel_Fabric

That requires to use Fabric though, in eg Apache Karaf / ServiceMix or
the Fuse products/


> Also it looks like Camel FTP pulls the files even when using
> fastExistsCheck=true, is that expected? I know it does pull the file because
> if I chain an smtp component I get the content of the file by email.
>

Yeah it always download the file. We could possible add option
download=true|false, to the ftp component.
Then ppl can use download=false, to be notified of the existence of new files.
Fell free to create a JIRA for that idea.



> On my initial tests (for the record) there were several miss understanding
> generating all errors I posted:
> 1. As it implements the Polling Consumer Pattern Camel FTP will continue to
> poll, you can control the delay and other parameters but that won't mean it
> will stop retrying even if the problem is related to bad credentials.
> 2. After providing a username any path after the domain is relative to the
> home directory so should you need absolute paths you need to add a slash so
> "sftp://sample.com//home/admin?username=admin"; is really equivalent to just
> "sftp://sample.com?username=admin"; (most of the time)
> 3. FTP2 inherits all fields from File2 between which there is an option to
> pull just one file. Implementing a GenericFileFilter is an alternative that
> goes beyond that as you can literally check for any file attributes before
> accepting the file as a valid message for the route.
>
> Best,
>
> -Nestor
>
> --
> View this message in context: 
> http://camel.465427.n5.nabble.com/Camel-FTP-SFTP-check-instead-of-download-tp5713363p5713567.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cib...@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to