org.apache.camel.component.file
Interface GenericFileExclusiveReadLockStrategy<T>

All Known Implementing Classes:
FileLockExclusiveReadLockStrategy, GenericFileRenameExclusiveReadLockStrategy, MarkerFileExclusiveReadLockStrategy

public interface GenericFileExclusiveReadLockStrategy<T>

Strategy for acquiring exclusive read locks for files to be consumed. After granting the read lock it is realeased, we just want to make sure that when we start consuming the file its not currently in progress of being written by third party.

Camel supports out of the box the following strategies:


Method Summary
 boolean acquireExclusiveReadLock(GenericFileOperations<T> operations, GenericFile<T> file, Exchange exchange)
          Acquires exclusive read lock to the file.
 void releaseExclusiveReadLock(GenericFileOperations<T> operations, GenericFile<T> file, Exchange exchange)
          Releases the exclusive read lock granted by the acquireExclusiveReadLock method.
 void setTimeout(long timeout)
          Sets an optional timeout period.
 

Method Detail

acquireExclusiveReadLock

boolean acquireExclusiveReadLock(GenericFileOperations<T> operations,
                                 GenericFile<T> file,
                                 Exchange exchange)
                                 throws Exception
Acquires exclusive read lock to the file.

Parameters:
operations - generic file operations
file - the file
exchange - 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

void releaseExclusiveReadLock(GenericFileOperations<T> operations,
                              GenericFile<T> file,
                              Exchange exchange)
                              throws Exception
Releases the exclusive read lock granted by the acquireExclusiveReadLock method.

Parameters:
operations - generic file operations
file - the file
exchange - the exchange
Throws:
Exception - can be thrown in case of errors

setTimeout

void setTimeout(long timeout)
Sets an optional timeout period.

If the readlock could not be granted within the timeperiod then the wait is stopped and the acquireExclusiveReadLock method returns false.

Parameters:
timeout - period in millis


Apache CAMEL