|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.camel.support.ServiceSupport org.apache.camel.impl.DefaultConsumer org.apache.camel.impl.ScheduledPollConsumer org.apache.camel.impl.ScheduledBatchPollingConsumer org.apache.camel.component.file.GenericFileConsumer<T>
public abstract class GenericFileConsumer<T>
Base class for file consumers.
Field Summary | |
---|---|
protected Processor |
customProcessor
|
protected boolean |
eagerLimitMaxMessagesPerPoll
|
protected GenericFileEndpoint<T> |
endpoint
|
protected String |
fileExpressionResult
|
protected org.slf4j.Logger |
log
|
protected boolean |
loggedIn
|
protected GenericFileOperations<T> |
operations
|
protected int |
pendingExchanges
|
protected ShutdownRunningTask |
shutdownRunningTask
|
Fields inherited from class org.apache.camel.impl.ScheduledBatchPollingConsumer |
---|
maxMessagesPerPoll |
Fields inherited from class org.apache.camel.support.ServiceSupport |
---|
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending |
Constructor Summary | |
---|---|
GenericFileConsumer(GenericFileEndpoint<T> endpoint,
Processor processor,
GenericFileOperations<T> operations)
|
Method Summary | |
---|---|
boolean |
canPollMoreFiles(List<?> fileList)
Whether or not we can continue polling for more files |
protected void |
customProcessExchange(Exchange exchange,
Processor processor)
Processes the exchange using a custom processor. |
protected void |
doStart()
Implementations override this method to support customized start/stop. |
Processor |
getCustomProcessor()
|
boolean |
isEagerLimitMaxMessagesPerPoll()
|
protected boolean |
isInProgress(GenericFile<T> file)
Is the given file already in progress. |
protected boolean |
isMatched(GenericFile<T> file,
boolean isDirectory,
List<T> files)
Strategy to perform file matching based on endpoint configuration. |
protected abstract boolean |
isMatched(GenericFile<T> file,
String doneFileName,
List<T> files)
Strategy to perform file matching based on endpoint configuration in terms of done file name. |
protected boolean |
isValidFile(GenericFile<T> file,
boolean isDirectory,
List<T> files)
Strategy for validating if the given remote file should be included or not |
protected int |
poll()
Poll for files |
protected abstract boolean |
pollDirectory(String fileName,
List<GenericFile<T>> fileList,
int depth)
Polls the given directory for files to process |
protected void |
postPollCheck()
Override if required. |
protected boolean |
prePollCheck()
Override if required. |
int |
processBatch(Queue<Object> exchanges)
Processes the list of Exchange objects in a batch. |
protected void |
processExchange(Exchange exchange)
Processes the exchange |
protected void |
removeExcessiveInProgressFiles(Deque<Exchange> exchanges,
int limit)
|
void |
setCustomProcessor(Processor processor)
Use a custom processor to process the exchange. |
void |
setEagerLimitMaxMessagesPerPoll(boolean eagerLimitMaxMessagesPerPoll)
|
void |
setOperations(GenericFileOperations<T> operations)
Sets the operations to be used. |
Methods inherited from class org.apache.camel.impl.ScheduledBatchPollingConsumer |
---|
deferShutdown, getMaxMessagesPerPoll, getPendingExchangesSize, isBatchAllowed, prepareShutdown, processEmptyMessage, setMaxMessagesPerPoll |
Methods inherited from class org.apache.camel.impl.DefaultConsumer |
---|
getAsyncProcessor, getEndpoint, getExceptionHandler, getProcessor, handleException, handleException, setExceptionHandler, toString |
Methods inherited from class org.apache.camel.support.ServiceSupport |
---|
doResume, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspended, isSuspending, resume, shutdown, start, stop, suspend |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.camel.Consumer |
---|
getEndpoint |
Methods inherited from interface org.apache.camel.Service |
---|
start, stop |
Methods inherited from interface org.apache.camel.SuspendableService |
---|
isSuspended, resume, suspend |
Field Detail |
---|
protected final transient org.slf4j.Logger log
protected GenericFileEndpoint<T> endpoint
protected GenericFileOperations<T> operations
protected boolean loggedIn
protected String fileExpressionResult
protected volatile ShutdownRunningTask shutdownRunningTask
protected volatile int pendingExchanges
protected Processor customProcessor
protected boolean eagerLimitMaxMessagesPerPoll
Constructor Detail |
---|
public GenericFileConsumer(GenericFileEndpoint<T> endpoint, Processor processor, GenericFileOperations<T> operations)
Method Detail |
---|
public Processor getCustomProcessor()
public void setCustomProcessor(Processor processor)
processor
- a custom processorpublic boolean isEagerLimitMaxMessagesPerPoll()
public void setEagerLimitMaxMessagesPerPoll(boolean eagerLimitMaxMessagesPerPoll)
protected int poll() throws Exception
poll
in class ScheduledPollConsumer
Exception
- can be thrown if an exception occurred during pollingpublic int processBatch(Queue<Object> exchanges)
BatchConsumer
Exchange
objects in a batch.
Each message exchange will be processed individually but the batch
consumer will add properties with the current index and total in the batch.
The items in the Queue may actually be Holder objects that store other
data alongside the Exchange.
exchanges
- list of items in this batch
protected void removeExcessiveInProgressFiles(Deque<Exchange> exchanges, int limit)
public boolean canPollMoreFiles(List<?> fileList)
fileList
- the current list of gathered files
protected boolean prePollCheck() throws Exception
Exception
protected void postPollCheck()
protected abstract boolean pollDirectory(String fileName, List<GenericFile<T>> fileList, int depth)
fileName
- current directory or filefileList
- current list of files gathereddepth
- the current depth of the directory (will start from 0)
public void setOperations(GenericFileOperations<T> operations)
operations
- the operationsprotected void processExchange(Exchange exchange)
exchange
- the exchangeprotected void customProcessExchange(Exchange exchange, Processor processor)
exchange
- the exchangeprocessor
- the custom processorprotected boolean isValidFile(GenericFile<T> file, boolean isDirectory, List<T> files)
file
- the fileisDirectory
- whether the file is a directory or a filefiles
- files in the directory
protected boolean isMatched(GenericFile<T> file, boolean isDirectory, List<T> files)
file
- the fileisDirectory
- whether the file is a directory or a filefiles
- files in the directory
protected abstract boolean isMatched(GenericFile<T> file, String doneFileName, List<T> files)
file
- the filedoneFileName
- the done file name (without any paths)files
- files in the directory
protected boolean isInProgress(GenericFile<T> file)
file
- the file
protected void doStart() throws Exception
ServiceSupport
ServiceSupport.doStop()
for more details.
doStart
in class ScheduledPollConsumer
Exception
ServiceSupport.doStop()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |