Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 49460 invoked from network); 7 Oct 2010 15:34:29 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 7 Oct 2010 15:34:29 -0000 Received: (qmail 98596 invoked by uid 500); 7 Oct 2010 15:34:28 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 98560 invoked by uid 500); 7 Oct 2010 15:34:28 -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 98552 invoked by uid 99); 7 Oct 2010 15:34:28 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Oct 2010 15:34:28 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of claus.ibsen@gmail.com designates 209.85.216.180 as permitted sender) Received: from [209.85.216.180] (HELO mail-qy0-f180.google.com) (209.85.216.180) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 07 Oct 2010 15:34:22 +0000 Received: by qyk1 with SMTP id 1so899983qyk.11 for ; Thu, 07 Oct 2010 08:34:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type :content-transfer-encoding; bh=TjgZEzk9TvoRvfiApLLOQaTw0Xi4lX1eE4zB3AMp+y0=; b=do1w8BcH+t8fMf9fMDJJ6OwianDs+PH5TPYsq9AmjR+txvjC8oVfL+PBKQBormvguN bZfgY3PXcP8S79dXhAXBdz4rNcSlHf7kr1+zzSuNaH/eRReTJeaw/nW6aPiYMfAgeDnE vOyOHMYiDP2rw90QWdwiMLcXnSEYKJ7mCHQyI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=p1HXTEXwXop3a0XJh2WKf61LQe9hXlEVyneE/fda/06bRJGh2sWzLSxQQAGBL87W39 By20MEygop31/u4IrCeXRFvOlF89ODfbH+/z6PXl0PrYUD79Tue2EVfI+2oT1VNuDOGN YGDL862IhZC/0Ub/0D/1Tslg0kqNt+M9Pj1ik= Received: by 10.224.202.194 with SMTP id ff2mr415536qab.151.1286465641448; Thu, 07 Oct 2010 08:34:01 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.11.22 with HTTP; Thu, 7 Oct 2010 08:33:41 -0700 (PDT) In-Reply-To: <2E5E061E-86D3-4CE0-AF59-B94F7CA95AE1@tataryn.net> References: <2E5E061E-86D3-4CE0-AF59-B94F7CA95AE1@tataryn.net> From: Claus Ibsen Date: Thu, 7 Oct 2010 17:33:41 +0200 Message-ID: Subject: Re: File Component readLock strategy To: users@camel.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Hi Its actually a bit tricky to detect if a file is locked by another process or not. Although we have the java.nio API it seems to not work consistent across OS's. And I actually think its stated in the docs somewhere, that this can be the case. Also note that NIO locks is JVM wide, which means from an unit test you cannot lock a file by one thread, and from the same JVM see the file lock. And if you forget to unlock the NIO lock, that file is locked until you restart the JVM. Can be a caveat for big app servers, if you have a rouge app holding a lock. Then you can try to obtain the lock on the file by trying to rename it before reading, if you can rename then you assume the other party is not currently writing to it. But I think some OS and apps may allow the OS to rename a file which currently is being written by that app. That leaves you with checking the file modification and timestamp and wait until its "steady". But NIO 2 should have a file watcher API. I assume it may be better at providing notifications when a file has been finished writing. So we can wait for Java 7 :) On Thu, Oct 7, 2010 at 1:07 AM, Craig Tataryn wrote: > Has anyone had any luck using a readLock strategy other than "changed"? = =A0I've tried them all, and "changed" seems to be the only one that works c= onsistently when I'm copying a large file into a directory the File Compone= nt is monitoring. > > All other's allow the File Component to execute before the file is comple= tely copied into the directory. > > $mvn -X --version > Apache Maven 3.0-beta-3 (r990787; 2010-08-30 07:44:03-0500) > Java version: 1.6.0_20 > Java home: /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Hom= e > Default locale: en_US, platform encoding: MacRoman > OS name: "mac os x" version: "10.6.4" arch: "x86_64" Family: "mac" > > Craig. > > -- > Craig Tataryn > site: http://www.basementcoders.com/ > podcast: http://www.basementcoders.com/?feed=3Dpodcast > itunes: http://itunes.apple.com/podcast/the-basement-coders > irc: ThaDon on freenode #basementcoders, ##wicket, #papernapkin > twitter: craiger > > --=20 Claus Ibsen Apache Camel Committer 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