How did you trigger the uploading thread ?
You can let the main thread wait for your uploading thread, if you start
the uploading thread from the main thread.
Willem
Hebert Hu wrote:
Thanks for your swift reply.
I think I found the problem just due to the uploading and downloading at the
sametime.
One more question, it seems that the uploading process is runing on a
separate thread. Sometimes the main program finishes before the uploading
thread returns, that stops the uploading. How I can prevent
such situation?
Hebert Hu wrote:
Hi,
I've encountered a strange problem when using Camel Sftp component for
uploading.
Here's my code
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
public void configure() throws Exception {
from("file:c:\\uploadfiles?noop=true").to(getFtpUrl());
from(getFtpUrl()).to("mock:result");
}
};
}
private String getFtpUrl(){
return
"sftp://usern...@sftpserver/ftpload?password=password&binary=true&knownHostsFile=c://.ssh//known_hosts";
}
The problem is: When I start my upload procedure, for the files in the
c:\uploadfiles (multiples files), some of them will create a .camellock
file while others not. As in the remote server, some of the files that
have a .camellock copy will be uploaded while others not. Noted that not
all the files that has .camellock copies will be uploaded. And an
exception is thrown
SEVERE: Cannot retrieve file: ftpload/a.txt
org.apache.camel.component.file.GenericFileOperationFailedException:
Cannot retrieve file: ftpload/a.txt
at
org.apache.camel.component.file.remote.SftpOperations.retrieveFileToStreamInBody(SftpOperations.java:326)
at
org.apache.camel.component.file.remote.SftpOperations.retrieveFile(SftpOperations.java:312)
at
org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:183)
at
org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:120)
at
org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:93)
at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:99)
at
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:432)
at
java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:295)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:80)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:157)
at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:181)
at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:665)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:690)
at java.lang.Thread.run(Thread.java:799)
When I run the upload procedure again, more .camellock files appeared,
more files been uploaded, and the exception is still thrown.
For example. 10 files in c:\uploadfiles, run the upload for the first
time, 5 .camellock appeared, 1 file with .camellock uploaded, and an
exception. Run for the second time, 2 more .camellock appeared, 1 more
file uploaded, and an exception again.
I'm using Camel-core 2.0.0, camel-ftp 2.0.0
Can any one shed some light on me?