You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2019/07/02 12:10:49 UTC

[camel] branch camel-2.x updated: CAMEL-13680: File component with readLock=fileLock is not supported on Windows

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch camel-2.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-2.x by this push:
     new 5fb4ed3  CAMEL-13680: File component with readLock=fileLock is not supported on Windows
5fb4ed3 is described below

commit 5fb4ed364453acd8c7210ead0b3d0535d3272b34
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Jul 2 14:10:38 2019 +0200

    CAMEL-13680: File component with readLock=fileLock is not supported on Windows
---
 camel-core/src/main/docs/file-component.adoc                          | 2 +-
 .../src/main/java/org/apache/camel/component/file/FileEndpoint.java   | 4 ++++
 .../java/org/apache/camel/component/file/GenericFileEndpoint.java     | 2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/camel-core/src/main/docs/file-component.adoc b/camel-core/src/main/docs/file-component.adoc
index 25a5c49..bcd4903 100644
--- a/camel-core/src/main/docs/file-component.adoc
+++ b/camel-core/src/main/docs/file-component.adoc
@@ -135,7 +135,7 @@ with the following path and query parameters:
 | *minDepth* (filter) | The minimum depth to start processing when recursively processing a directory. Using minDepth=1 means the base directory. Using minDepth=2 means the first sub directory. |  | int
 | *move* (filter) | Expression (such as Simple Language) used to dynamically set the filename when moving it after processing. To move files into a .done subdirectory just enter .done. |  | String
 | *exclusiveReadLockStrategy* (lock) | Pluggable read-lock as a org.apache.camel.component.file.GenericFileExclusiveReadLockStrategy implementation. |  | GenericFileExclusive ReadLockStrategy
-| *readLock* (lock) | Used by consumer, to only poll the files if it has exclusive read-lock on the file (i.e. the file is not in-progress or being written). Camel will wait until the file lock is granted. This option provides the build in strategies: none - No read lock is in use markerFile - Camel creates a marker file (fileName.camelLock) and then holds a lock on it. This option is not available for the FTP component changed - Changed is using file length/modification timestamp to det [...]
+| *readLock* (lock) | Used by consumer, to only poll the files if it has exclusive read-lock on the file (i.e. the file is not in-progress or being written). Camel will wait until the file lock is granted. This option provides the build in strategies: none - No read lock is in use markerFile - Camel creates a marker file (fileName.camelLock) and then holds a lock on it. This option is not available for the FTP component changed - Changed is using file length/modification timestamp to det [...]
 | *readLockCheckInterval* (lock) | Interval in millis for the read-lock, if supported by the read lock. This interval is used for sleeping between attempts to acquire the read lock. For example when using the changed read lock, you can set a higher interval period to cater for slow writes. The default of 1 sec. may be too fast if the producer is very slow writing the file. Notice: For FTP the default readLockCheckInterval is 5000. The readLockTimeout value must be higher than readLockChe [...]
 | *readLockDeleteOrphanLock Files* (lock) | Whether or not read lock with marker files should upon startup delete any orphan read lock files, which may have been left on the file system, if Camel was not properly shutdown (such as a JVM crash). If turning this option to false then any orphaned lock file will cause Camel to not attempt to pickup that file, this could also be due another node is concurrently reading files from the same shared directory. | true | boolean
 | *readLockIdempotentRelease Async* (lock) | Whether the delayed release task should be synchronous or asynchronous. See more details at the readLockIdempotentReleaseDelay option. | false | boolean
diff --git a/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
index b866cba..2b35b5d 100644
--- a/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/component/file/FileEndpoint.java
@@ -120,6 +120,10 @@ public class FileEndpoint extends GenericFileEndpoint<File> {
             }
         }
 
+        if ("fileLock".equals(readLock) && FileUtil.isWindows()) {
+            throw new IllegalArgumentException("The readLock=fileLock option is not supported on Windows");
+        }
+
         // set max messages per poll
         result.setMaxMessagesPerPoll(getMaxMessagesPerPoll());
         result.setEagerLimitMaxMessagesPerPoll(isEagerMaxMessagesPerPoll());
diff --git a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
index bf0394a..6ca6aea 100644
--- a/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
+++ b/camel-core/src/main/java/org/apache/camel/component/file/GenericFileEndpoint.java
@@ -843,7 +843,7 @@ public abstract class GenericFileEndpoint<T> extends ScheduledPollEndpoint imple
      *     <li>changed - Changed is using file length/modification timestamp to detect whether the file is currently being copied or not. Will at least use 1 sec
      *     to determine this, so this option cannot consume files as fast as the others, but can be more reliable as the JDK IO API cannot
      *     always determine whether a file is currently being used by another process. The option readLockCheckInterval can be used to set the check frequency.</li>
-     *     <li>fileLock - is for using java.nio.channels.FileLock. This option is not avail for the FTP component. This approach should be avoided when accessing
+     *     <li>fileLock - is for using java.nio.channels.FileLock. This option is not avail on Windows or the FTP component. This approach should be avoided when accessing
      *     a remote file system via a mount/share unless that file system supports distributed file locks.</li>
      *     <li>rename - rename is for using a try to rename the file as a test if we can get exclusive read-lock.</li>
      *     <li>idempotent - (only for file component) idempotent is for using a idempotentRepository as the read-lock.