org.apache.camel.component.file.strategy
Class FileRenameExclusiveReadLockStrategy
java.lang.Object
org.apache.camel.component.file.strategy.GenericFileRenameExclusiveReadLockStrategy<File>
org.apache.camel.component.file.strategy.FileRenameExclusiveReadLockStrategy
- All Implemented Interfaces:
- GenericFileExclusiveReadLockStrategy<File>
public class FileRenameExclusiveReadLockStrategy
- extends GenericFileRenameExclusiveReadLockStrategy<File>
Acquires exclusive read lock to the given file. Will wait until the lock is granted.
After granting the read lock it is released, we just want to make sure that when we start
consuming the file its not currently in progress of being written by third party.
This implementation is only supported by the File component, that leverages the MarkerFileExclusiveReadLockStrategy
as well, to ensure only acquiring locks on files, which is not already in progress by another process,
that have marked this using the marker file.
Setting the option setMarkerFiler(boolean) to false allows to turn off using marker files.
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FileRenameExclusiveReadLockStrategy
public FileRenameExclusiveReadLockStrategy()
acquireExclusiveReadLock
public boolean acquireExclusiveReadLock(GenericFileOperations<File> operations,
GenericFile<File> file,
Exchange exchange)
throws Exception
- Description copied from interface:
GenericFileExclusiveReadLockStrategy
- Acquires exclusive read lock to the file.
- Specified by:
acquireExclusiveReadLock in interface GenericFileExclusiveReadLockStrategy<File>- Overrides:
acquireExclusiveReadLock in class GenericFileRenameExclusiveReadLockStrategy<File>
- Parameters:
operations - generic file operationsfile - the fileexchange - the exchange
- Returns:
- true if read lock was acquired. If false Camel
will skip the file and try it on the next poll
- Throws:
Exception - can be thrown in case of errors
releaseExclusiveReadLock
public void releaseExclusiveReadLock(GenericFileOperations<File> operations,
GenericFile<File> file,
Exchange exchange)
throws Exception
- Description copied from interface:
GenericFileExclusiveReadLockStrategy
- Releases the exclusive read lock granted by the acquireExclusiveReadLock method.
- Specified by:
releaseExclusiveReadLock in interface GenericFileExclusiveReadLockStrategy<File>- Overrides:
releaseExclusiveReadLock in class GenericFileRenameExclusiveReadLockStrategy<File>
- Parameters:
operations - generic file operationsfile - the fileexchange - the exchange
- Throws:
Exception - can be thrown in case of errors
setMarkerFiler
public void setMarkerFiler(boolean markerFile)
- Description copied from interface:
GenericFileExclusiveReadLockStrategy
- Sets whether marker file should be used or not.
- Specified by:
setMarkerFiler in interface GenericFileExclusiveReadLockStrategy<File>- Overrides:
setMarkerFiler in class GenericFileRenameExclusiveReadLockStrategy<File>
- Parameters:
markerFile - true to use marker files.
Apache Camel