Package org.apache.camel.component.file
Interface GenericFileProcessStrategy<T>
- All Known Implementing Classes:
GenericFileDeleteProcessStrategy
,GenericFileNoOpProcessStrategy
,GenericFileProcessStrategySupport
,GenericFileRenameProcessStrategy
public interface GenericFileProcessStrategy<T>
Represents a pluggable strategy when processing files.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
abort
(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, org.apache.camel.Exchange exchange, GenericFile<T> file) Called when a begin is aborted, for example to release any resources which may have been acquired during thebegin(GenericFileOperations, GenericFileEndpoint, org.apache.camel.Exchange, GenericFile)
operation.boolean
begin
(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, org.apache.camel.Exchange exchange, GenericFile<T> file) Called when work is about to begin on this file.void
commit
(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, org.apache.camel.Exchange exchange, GenericFile<T> file) Releases any file locks and possibly deletes or moves the file after successful processingvoid
prepareOnStartup
(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint) Allows custom logic to be run on first poll preparing the strategy, such as removing old lock files etc.void
rollback
(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, org.apache.camel.Exchange exchange, GenericFile<T> file) Releases any file locks and possibly deletes or moves the file after unsuccessful processing
-
Method Details
-
prepareOnStartup
void prepareOnStartup(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint) throws Exception Allows custom logic to be run on first poll preparing the strategy, such as removing old lock files etc.- Parameters:
operations
- file operationsendpoint
- the endpoint- Throws:
Exception
- can be thrown in case of errors which causes poll to fail
-
begin
boolean begin(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, org.apache.camel.Exchange exchange, GenericFile<T> file) throws Exception Called when work is about to begin on this file. This method may attempt to acquire some file lock before returning true; returning false if the file lock could not be obtained so that the file should be ignored.- Parameters:
operations
- file operationsendpoint
- the endpointexchange
- the exchangefile
- the file- Returns:
- true if the file can be processed (such as if a file lock could be obtained)
- Throws:
Exception
- can be thrown in case of errors
-
abort
void abort(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, org.apache.camel.Exchange exchange, GenericFile<T> file) throws Exception Called when a begin is aborted, for example to release any resources which may have been acquired during thebegin(GenericFileOperations, GenericFileEndpoint, org.apache.camel.Exchange, GenericFile)
operation.- Parameters:
operations
- file operationsendpoint
- the endpointexchange
- the exchangefile
- the file- Throws:
Exception
- can be thrown in case of errors
-
commit
void commit(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, org.apache.camel.Exchange exchange, GenericFile<T> file) throws Exception Releases any file locks and possibly deletes or moves the file after successful processing- Parameters:
operations
- file operationsendpoint
- the endpointexchange
- the exchangefile
- the file- Throws:
Exception
- can be thrown in case of errors
-
rollback
void rollback(GenericFileOperations<T> operations, GenericFileEndpoint<T> endpoint, org.apache.camel.Exchange exchange, GenericFile<T> file) throws Exception Releases any file locks and possibly deletes or moves the file after unsuccessful processing- Parameters:
operations
- file operationsendpoint
- the endpointexchange
- the exchangefile
- the file- Throws:
Exception
- can be thrown in case of errors
-