Biplab Sarkar created CAMEL-7047:
------------------------------------

             Summary: FTP
                 Key: CAMEL-7047
                 URL: https://issues.apache.org/jira/browse/CAMEL-7047
             Project: Camel
          Issue Type: Improvement
          Components: bean-integration
            Reporter: Biplab Sarkar
            Priority: Minor


Hi,

I am trying to ftp a particular file from a directory to a ftp location, so I 
followed the examples provided in camel 2.12.1, which polls for any file in the 
target directory specified, and whenever it finds the file it uploads in the 
ftp location mentioned in the properties file.

How ever my requirement is i am writing a method which accepts the file name as 
an argument and sends that file name in the route builder, so that it uploads 
the only specified file name from the polling target directory.
this is not working!

public  void toftp(String node_name,final String file_name) throws Exception {
                
                PropertiesComponent pc = 
getContext().getComponent("properties", PropertiesComponent.class);
                
System.out.println("properties:"+getContext().getComponent("properties", 
PropertiesComponent.class));
            pc.setLocation("classpath:ftp.properties");
            System.out.println("properties location:"+pc.getLocations());
            context_sdp=new DefaultCamelContext();
            context_sdp.addComponent("properties", pc);
                
                
                if (node_name.equals("NODE_SDP")) {
                    
                        context_sdp.addRoutes(new RouteBuilder() {
                                
                                        @Override
                                        public void configure() throws 
Exception{
                                                try{
                                        System.out.println("File name received 
is :"+file_name);
                                        
fromF("file:target/upload?fileName=%s?moveFailed=../error",file_name)
                                        .log("Uploading file ${file:name}")
                                        .to("{{ftp.client.sdp}}")
                                        .log("Uploaded file ${file:name} 
complete.");
                                        
                                }  catch (Exception e 
){System.out.println("error:"+e);}
                                        } 
                        });
                        context_sdp.start();
                        Thread.sleep(50000);
                        context_sdp.stop();
                }       

This however  works fine if i give 
fromF("file:target/upload?moveFailed=../error")
this polls for any file in the target directory and tries to ftp when ever any 
file is put in the target directory.




--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to