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.

I tried in several ways like
fromF("file:target/upload?fileName=%s?moveFailed=../error",file_name)
                                      
fromF("file:target/upload/?%s?moveFailed=../error",file_name)
but it doesnt works. can you please provide some input , where am I doing it
wrong?

Regards,
Biplab Sarkar.
biplab.sarka...@gmail.com



--
View this message in context: 
http://camel.465427.n5.nabble.com/Apache-camel-FTP-issue-tp5744530.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to