Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 38075 invoked from network); 30 Dec 2009 05:41:14 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 30 Dec 2009 05:41:14 -0000 Received: (qmail 69548 invoked by uid 500); 30 Dec 2009 05:41:13 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 69440 invoked by uid 500); 30 Dec 2009 05:41:13 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 69429 invoked by uid 99); 30 Dec 2009 05:41:13 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Dec 2009 05:41:13 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Dec 2009 05:41:02 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1NPrIX-0004j6-Nx for users@camel.apache.org; Tue, 29 Dec 2009 21:40:41 -0800 Message-ID: <26964320.post@talk.nabble.com> Date: Tue, 29 Dec 2009 21:40:41 -0800 (PST) From: Hebert Hu To: users@camel.apache.org Subject: Re: Issue in upload with Camel In-Reply-To: <5380c69c0912290405o7caa6e83l68951bdda6a4cc73@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Nabble-From: hooper@zju.edu.cn References: <26940685.post@talk.nabble.com> <26951787.post@talk.nabble.com> <4B39B6E6.9010900@gmail.com> <5380c69c0912290405o7caa6e83l68951bdda6a4cc73@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org Since I only need to check whether the upload is finished, I wrote from(fileUrl).onCompletion().to(ftpUrl).end() am I writing the right syntax? Since it didn't work well It seems that the in flight count way is more convenient, but I can't find the function available neither in 2.0 or 2.1.Is it a new feature in 2.2? BTW, the download link for 2.2 is not valid currently Claus Ibsen-2 wrote: >=20 > On Tue, Dec 29, 2009 at 8:59 AM, Willem Jiang > wrote: >> If you are using file endpoint to pull the directory, it is hard to tell >> if >> the uploading processor is over, >> Can you take look at the camel polling consumer API[1] (Timer based >> polling >> consumer example), in this way you can add you logic to check if the fil= e >> pulling is finished, and the sendTemplate will return when the =C2=A0upl= oading >> work is over. >> >> [1]http://camel.apache.org/polling-consumer.html >> >=20 >=20 > You can also use onCompletion or check the inflight registry if there > are any current exchanges. > http://camel.apache.org/oncompletion.html >=20 > CamelContext.getInflightRegistry() >=20 > Which has a counter for the number of exchanges in flight. When it > reaches 0 the file should have been transferred. >=20 >=20 >=20 >> Willem >> >> Hebert Hu wrote: >>> >>> I started the upload like this >>> >>> CamelContext context =3D new DefaultCamelContext(); >>> RouteBuilder route =3D createRouteBuilder(); >>> context.addRoutes(route); >>> context.start(); >>> >>> I'm able to get the route service status by RouteDefinition definition = =3D >>> context.getRouteDefinitions().get(0); >>> context.getRouteStatus(definition) >>> >>> But how can I tell whther the upload is finished? >>> As I always get "Started" even the upload is finished. >>> >>> >>> Hebert Hu wrote: >>>> >>>> Hi, >>>> I've encountered a strange problem when using Camel Sftp component for >>>> uploading. >>>> >>>> Here's my code >>>> >>>> =C2=A0 =C2=A0protected RouteBuilder createRouteBuilder() throws Except= ion { >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0return new RouteBuilder() { >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0public void configure() throw= s Exception { >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0from("file:c:\\= uploadfiles?noop=3Dtrue").to(getFtpUrl()); >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0from(getFtpUrl(= )).to("mock:result"); >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0}; >>>> =C2=A0 =C2=A0} >>>> >>>> private String getFtpUrl(){ >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0return >>>> >>>> "sftp://username@sftpserver/ftpload?password=3Dpassword&binary=3Dtrue&= knownHostsFile=3Dc://.ssh//known_hosts"; >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0} >>>> >>>> The problem is: When I start my upload procedure, for the files in the >>>> c:\uploadfiles (multiples files), some of them will create a .camelloc= k >>>> 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 >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>> >>>> org.apache.camel.component.file.remote.SftpOperations.retrieveFileToSt= reamInBody(SftpOperations.java:326) >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>> >>>> org.apache.camel.component.file.remote.SftpOperations.retrieveFile(Sft= pOperations.java:312) >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>> >>>> org.apache.camel.component.file.GenericFileConsumer.processExchange(Ge= nericFileConsumer.java:183) >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>> >>>> org.apache.camel.component.file.GenericFileConsumer.processBatch(Gener= icFileConsumer.java:120) >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>> >>>> org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileCo= nsumer.java:93) >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>> >>>> org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.= java:99) >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:432= ) >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>> >>>> java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:= 295) >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>> java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150) >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>> >>>> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.a= ccess$101(ScheduledThreadPoolExecutor.java:80) >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>> >>>> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.r= unPeriodic(ScheduledThreadPoolExecutor.java:157) >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>> >>>> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.r= un(ScheduledThreadPoolExecutor.java:181) >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>> >>>> java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecu= tor.java:665) >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at >>>> >>>> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.= java:690) >>>> =C2=A0 =C2=A0 =C2=A0 =C2=A0at 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? >>>> >>> >> >> >=20 >=20 >=20 > --=20 > Claus Ibsen > Apache Camel Committer >=20 > Author of Camel in Action: http://www.manning.com/ibsen/ > Open Source Integration: http://fusesource.com > Blog: http://davsclaus.blogspot.com/ > Twitter: http://twitter.com/davsclaus >=20 >=20 --=20 View this message in context: http://old.nabble.com/Issue-in-upload-with-Ca= mel-tp26940685p26964320.html Sent from the Camel - Users mailing list archive at Nabble.com.