Class FileIdempotentChangedRepositoryReadLockStrategy
java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.component.file.strategy.FileIdempotentChangedRepositoryReadLockStrategy
- All Implemented Interfaces:
 AutoCloseable,org.apache.camel.CamelContextAware,GenericFileExclusiveReadLockStrategy<File>,org.apache.camel.Service,org.apache.camel.ShutdownableService,org.apache.camel.spi.HasCamelContext,org.apache.camel.StatefulService,org.apache.camel.SuspendableService
public class FileIdempotentChangedRepositoryReadLockStrategy
extends org.apache.camel.support.service.ServiceSupport
implements GenericFileExclusiveReadLockStrategy<File>, org.apache.camel.CamelContextAware
A file read lock that uses an 
IdempotentRepository and changed
 as the lock strategy. This allows to plugin and use existing idempotent repositories that for example supports
 clustering. The other read lock strategies that are using marker files or file locks, are not guaranteed to work in
 clustered setup with various platform and file systems.- 
Field Summary
Fields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING - 
Constructor Summary
Constructors - 
Method Summary
Modifier and TypeMethodDescriptionbooleanacquireExclusiveReadLock(GenericFileOperations<File> operations, GenericFile<File> file, org.apache.camel.Exchange exchange) Acquires exclusive read lock to the file.protected StringasKey(org.apache.camel.Exchange exchange, GenericFile<File> file) protected voiddoStart()protected voiddoStop()org.apache.camel.CamelContextorg.apache.camel.spi.IdempotentRepositoryThe idempotent repository to use as the store for the read locks.intbooleanbooleanWhether to remove the file from the idempotent repository when doing a commit.booleanWhether to remove the file from the idempotent repository when doing a rollback.voidprepareOnStartup(GenericFileOperations<File> operations, GenericFileEndpoint<File> endpoint) Allows custom logic to be run on startup preparing the strategy, such as removing old lock files etc.voidreleaseExclusiveReadLockOnAbort(GenericFileOperations<File> operations, GenericFile<File> file, org.apache.camel.Exchange exchange) Releases the exclusive read lock granted by the acquireExclusiveReadLock method due an abort operation (acquireExclusiveReadLock returned false).voidreleaseExclusiveReadLockOnCommit(GenericFileOperations<File> operations, GenericFile<File> file, org.apache.camel.Exchange exchange) Releases the exclusive read lock granted by the acquireExclusiveReadLock method due a commit operation (Exchange processing succeeded)voidreleaseExclusiveReadLockOnRollback(GenericFileOperations<File> operations, GenericFile<File> file, org.apache.camel.Exchange exchange) Releases the exclusive read lock granted by the acquireExclusiveReadLock method due a rollback operation (Exchange processing failed)voidsetCamelContext(org.apache.camel.CamelContext camelContext) voidsetCheckInterval(long checkInterval) Sets the check interval period.voidsetDeleteOrphanLockFiles(boolean deleteOrphanLockFiles) Sets whether orphan marker files should be deleted upon startupvoidsetIdempotentRepository(org.apache.camel.spi.IdempotentRepository idempotentRepository) The idempotent repository to use as the store for the read locks.voidsetMarkerFiler(boolean markerFile) Sets whether marker file should be used or not.voidsetMinAge(long minAge) voidsetMinLength(long minLength) voidsetReadLockIdempotentReleaseAsync(boolean readLockIdempotentReleaseAsync) Whether the delayed release task should be synchronous or asynchronous.voidsetReadLockIdempotentReleaseAsyncPoolSize(int readLockIdempotentReleaseAsyncPoolSize) The number of threads in the scheduled thread pool when using asynchronous release tasks.voidsetReadLockIdempotentReleaseDelay(int readLockIdempotentReleaseDelay) Whether to delay the release task for a period of millis.voidsetReadLockIdempotentReleaseExecutorService(ScheduledExecutorService readLockIdempotentReleaseExecutorService) To use a custom and shared thread pool for asynchronous release tasks.voidsetReadLockLoggingLevel(org.apache.camel.LoggingLevel readLockLoggingLevel) Sets logging level used when a read lock could not be acquired.voidsetRemoveOnCommit(boolean removeOnCommit) Whether to remove the file from the idempotent repository when doing a commit.voidsetRemoveOnRollback(boolean removeOnRollback) Whether to remove the file from the idempotent repository when doing a rollback.voidsetTimeout(long timeout) Sets an optional timeout period.Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getInternalLock, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend 
- 
Constructor Details
- 
FileIdempotentChangedRepositoryReadLockStrategy
public FileIdempotentChangedRepositoryReadLockStrategy() 
 - 
 - 
Method Details
- 
prepareOnStartup
public void prepareOnStartup(GenericFileOperations<File> operations, GenericFileEndpoint<File> endpoint) throws Exception Description copied from interface:GenericFileExclusiveReadLockStrategyAllows custom logic to be run on startup preparing the strategy, such as removing old lock files etc.- Specified by:
 prepareOnStartupin interfaceGenericFileExclusiveReadLockStrategy<File>- Parameters:
 operations- generic file operationsendpoint- the endpoint- Throws:
 Exception- can be thrown in case of errors
 - 
acquireExclusiveReadLock
public boolean acquireExclusiveReadLock(GenericFileOperations<File> operations, GenericFile<File> file, org.apache.camel.Exchange exchange) throws Exception Description copied from interface:GenericFileExclusiveReadLockStrategyAcquires exclusive read lock to the file.- Specified by:
 acquireExclusiveReadLockin interfaceGenericFileExclusiveReadLockStrategy<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
 - 
releaseExclusiveReadLockOnAbort
public void releaseExclusiveReadLockOnAbort(GenericFileOperations<File> operations, GenericFile<File> file, org.apache.camel.Exchange exchange) throws Exception Description copied from interface:GenericFileExclusiveReadLockStrategyReleases the exclusive read lock granted by the acquireExclusiveReadLock method due an abort operation (acquireExclusiveReadLock returned false).- Specified by:
 releaseExclusiveReadLockOnAbortin interfaceGenericFileExclusiveReadLockStrategy<File>- Parameters:
 operations- generic file operationsfile- the fileexchange- the exchange- Throws:
 Exception- can be thrown in case of errors
 - 
releaseExclusiveReadLockOnRollback
public void releaseExclusiveReadLockOnRollback(GenericFileOperations<File> operations, GenericFile<File> file, org.apache.camel.Exchange exchange) throws Exception Description copied from interface:GenericFileExclusiveReadLockStrategyReleases the exclusive read lock granted by the acquireExclusiveReadLock method due a rollback operation (Exchange processing failed)- Specified by:
 releaseExclusiveReadLockOnRollbackin interfaceGenericFileExclusiveReadLockStrategy<File>- Parameters:
 operations- generic file operationsfile- the fileexchange- the exchange- Throws:
 Exception- can be thrown in case of errors
 - 
releaseExclusiveReadLockOnCommit
public void releaseExclusiveReadLockOnCommit(GenericFileOperations<File> operations, GenericFile<File> file, org.apache.camel.Exchange exchange) throws Exception Description copied from interface:GenericFileExclusiveReadLockStrategyReleases the exclusive read lock granted by the acquireExclusiveReadLock method due a commit operation (Exchange processing succeeded)- Specified by:
 releaseExclusiveReadLockOnCommitin interfaceGenericFileExclusiveReadLockStrategy<File>- Parameters:
 operations- generic file operationsfile- the fileexchange- the exchange- Throws:
 Exception- can be thrown in case of errors
 - 
setTimeout
public void setTimeout(long timeout) Description copied from interface:GenericFileExclusiveReadLockStrategySets an optional timeout period. If the readlock could not be granted within the time period then the wait is stopped and the acquireExclusiveReadLock method returns false.- Specified by:
 setTimeoutin interfaceGenericFileExclusiveReadLockStrategy<File>- Parameters:
 timeout- period in millis
 - 
setCheckInterval
public void setCheckInterval(long checkInterval) Description copied from interface:GenericFileExclusiveReadLockStrategySets the check interval period. The check interval is used for sleeping between attempts to acquire read lock. Setting a high value allows to cater for slow writes in case the producer of the file is slow. The default period is 1000 millis.- Specified by:
 setCheckIntervalin interfaceGenericFileExclusiveReadLockStrategy<File>- Parameters:
 checkInterval- interval in millis
 - 
setReadLockLoggingLevel
public void setReadLockLoggingLevel(org.apache.camel.LoggingLevel readLockLoggingLevel) Description copied from interface:GenericFileExclusiveReadLockStrategySets logging level used when a read lock could not be acquired. Logging level used when a read lock could not be acquired. The default logging level is WARN- Specified by:
 setReadLockLoggingLevelin interfaceGenericFileExclusiveReadLockStrategy<File>- Parameters:
 readLockLoggingLevel- LoggingLevel
 - 
setMarkerFiler
public void setMarkerFiler(boolean markerFile) Description copied from interface:GenericFileExclusiveReadLockStrategySets whether marker file should be used or not.- Specified by:
 setMarkerFilerin interfaceGenericFileExclusiveReadLockStrategy<File>- Parameters:
 markerFile- true to use marker files.
 - 
setDeleteOrphanLockFiles
public void setDeleteOrphanLockFiles(boolean deleteOrphanLockFiles) Description copied from interface:GenericFileExclusiveReadLockStrategySets whether orphan marker files should be deleted upon startup- Specified by:
 setDeleteOrphanLockFilesin interfaceGenericFileExclusiveReadLockStrategy<File>- Parameters:
 deleteOrphanLockFiles- true to delete files, false to skip this check
 - 
setMinLength
public void setMinLength(long minLength)  - 
setMinAge
public void setMinAge(long minAge)  - 
getCamelContext
public org.apache.camel.CamelContext getCamelContext()- Specified by:
 getCamelContextin interfaceorg.apache.camel.spi.HasCamelContext
 - 
setCamelContext
public void setCamelContext(org.apache.camel.CamelContext camelContext) - Specified by:
 setCamelContextin interfaceorg.apache.camel.CamelContextAware
 - 
getIdempotentRepository
public org.apache.camel.spi.IdempotentRepository getIdempotentRepository()The idempotent repository to use as the store for the read locks. - 
setIdempotentRepository
public void setIdempotentRepository(org.apache.camel.spi.IdempotentRepository idempotentRepository) The idempotent repository to use as the store for the read locks. - 
isRemoveOnRollback
public boolean isRemoveOnRollback()Whether to remove the file from the idempotent repository when doing a rollback. By default this is true. - 
setRemoveOnRollback
public void setRemoveOnRollback(boolean removeOnRollback) Whether to remove the file from the idempotent repository when doing a rollback. By default this is true. - 
isRemoveOnCommit
public boolean isRemoveOnCommit()Whether to remove the file from the idempotent repository when doing a commit. By default this is false. - 
setRemoveOnCommit
public void setRemoveOnCommit(boolean removeOnCommit) Whether to remove the file from the idempotent repository when doing a commit. By default this is false. - 
setReadLockIdempotentReleaseDelay
public void setReadLockIdempotentReleaseDelay(int readLockIdempotentReleaseDelay) Whether to delay the release task for a period of millis. - 
isReadLockIdempotentReleaseAsync
public boolean isReadLockIdempotentReleaseAsync() - 
setReadLockIdempotentReleaseAsync
public void setReadLockIdempotentReleaseAsync(boolean readLockIdempotentReleaseAsync) Whether the delayed release task should be synchronous or asynchronous. - 
getReadLockIdempotentReleaseAsyncPoolSize
public int getReadLockIdempotentReleaseAsyncPoolSize() - 
setReadLockIdempotentReleaseAsyncPoolSize
public void setReadLockIdempotentReleaseAsyncPoolSize(int readLockIdempotentReleaseAsyncPoolSize) The number of threads in the scheduled thread pool when using asynchronous release tasks. - 
getReadLockIdempotentReleaseExecutorService
 - 
setReadLockIdempotentReleaseExecutorService
public void setReadLockIdempotentReleaseExecutorService(ScheduledExecutorService readLockIdempotentReleaseExecutorService) To use a custom and shared thread pool for asynchronous release tasks. - 
asKey
 - 
doStart
- Overrides:
 doStartin classorg.apache.camel.support.service.BaseService- Throws:
 Exception
 - 
doStop
- Overrides:
 doStopin classorg.apache.camel.support.service.BaseService- Throws:
 Exception
 
 -