public abstract class GenericFileConsumer<T>
extends org.apache.camel.support.ScheduledBatchPollingConsumer
Modifier and Type | Field and Description |
---|---|
protected org.apache.camel.Processor |
customProcessor |
protected boolean |
eagerLimitMaxMessagesPerPoll |
protected GenericFileEndpoint<T> |
endpoint |
protected GenericFileOperations<T> |
operations |
protected int |
pendingExchanges |
protected boolean |
prepareOnStartup |
protected GenericFileProcessStrategy<T> |
processStrategy |
protected org.apache.camel.ShutdownRunningTask |
shutdownRunningTask |
Constructor and Description |
---|
GenericFileConsumer(GenericFileEndpoint<T> endpoint,
org.apache.camel.Processor processor,
GenericFileOperations<T> operations,
GenericFileProcessStrategy<T> processStrategy) |
Modifier and Type | Method and Description |
---|---|
void |
afterPoll() |
long |
beforePoll(long timeout) |
boolean |
canPollMoreFiles(List<?> fileList)
Whether or not we can continue polling for more files
|
protected boolean |
customProcessExchange(org.apache.camel.Exchange exchange,
org.apache.camel.Processor processor)
Processes the exchange using a custom processor.
|
protected void |
doInit() |
protected void |
doStart() |
protected void |
doStop() |
protected String |
evaluateFileExpression(org.apache.camel.Exchange exchange) |
org.apache.camel.Processor |
getCustomProcessor() |
protected boolean |
ignoreCannotRetrieveFile(String name,
org.apache.camel.Exchange exchange,
Exception cause)
Whether to ignore if the file cannot be retrieved.
|
boolean |
isEagerLimitMaxMessagesPerPoll() |
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 |
isRetrieveFile()
Override if required.
|
protected boolean |
isValidFile(GenericFile<T> file,
boolean isDirectory,
List<T> files)
Strategy for validating if the given remote file should be included or not
|
void |
onInit() |
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(int polledMessages)
Override if required.
|
protected boolean |
prePollCheck()
Override if required.
|
int |
processBatch(Queue<Object> exchanges) |
protected boolean |
processExchange(org.apache.camel.Exchange exchange)
Processes the exchange
|
protected void |
removeExcessiveInProgressFiles(Deque<org.apache.camel.Exchange> exchanges,
int limit)
Drain any in progress files as we are done with this batch
|
protected void |
removeExcessiveInProgressFiles(List<GenericFile<T>> files)
Drain any in progress files as we are done with the files
|
void |
setCustomProcessor(org.apache.camel.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.
|
protected abstract void |
updateFileHeaders(GenericFile<T> file,
org.apache.camel.Message message)
Updates the information on
Message after we have acquired read-lock and can begin process the file. |
deferShutdown, getMaxMessagesPerPoll, getPendingExchangesSize, isBatchAllowed, prepareShutdown, processEmptyMessage, setMaxMessagesPerPoll
doShutdown, doSuspend, getBackoffCounter, getBackoffErrorThreshold, getBackoffIdleThreshold, getBackoffMultiplier, getDelay, getInitialDelay, getPollStrategy, getRepeatCount, getRunLoggingLevel, getScheduledExecutorService, getScheduler, getSchedulerProperties, getTimeUnit, isGreedy, isPollAllowed, isPolling, isSchedulerStarted, isSendEmptyMessageWhenIdle, isStartScheduler, isUseFixedDelay, run, setBackoffErrorThreshold, setBackoffIdleThreshold, setBackoffMultiplier, setDelay, setGreedy, setInitialDelay, setPollStrategy, setRepeatCount, setRunLoggingLevel, setScheduledExecutorService, setScheduler, setSchedulerProperties, setSendEmptyMessageWhenIdle, setStartScheduler, setTimeUnit, setUseFixedDelay, startScheduler
createUoW, doneUoW, getAsyncProcessor, getEndpoint, getExceptionHandler, getProcessor, getRoute, getRouteId, handleException, handleException, setExceptionHandler, setRoute, setRouteId, toString
build, doBuild, doFail, doLifecycleChange, doResume, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
protected GenericFileEndpoint<T> endpoint
protected GenericFileOperations<T> operations
protected GenericFileProcessStrategy<T> processStrategy
protected volatile org.apache.camel.ShutdownRunningTask shutdownRunningTask
protected volatile int pendingExchanges
protected org.apache.camel.Processor customProcessor
protected boolean eagerLimitMaxMessagesPerPoll
protected volatile boolean prepareOnStartup
public GenericFileConsumer(GenericFileEndpoint<T> endpoint, org.apache.camel.Processor processor, GenericFileOperations<T> operations, GenericFileProcessStrategy<T> processStrategy)
public org.apache.camel.Processor getCustomProcessor()
public void setCustomProcessor(org.apache.camel.Processor processor)
processor
- a custom processorpublic boolean isEagerLimitMaxMessagesPerPoll()
public void setEagerLimitMaxMessagesPerPoll(boolean eagerLimitMaxMessagesPerPoll)
public int poll() throws Exception
poll
in class org.apache.camel.support.ScheduledPollConsumer
Exception
protected void removeExcessiveInProgressFiles(Deque<org.apache.camel.Exchange> exchanges, int limit)
exchanges
- the exchangeslimit
- the limitprotected void removeExcessiveInProgressFiles(List<GenericFile<T>> files)
files
- the filespublic boolean canPollMoreFiles(List<?> fileList)
fileList
- the current list of gathered filesprotected boolean prePollCheck() throws Exception
Exception
protected void postPollCheck(int polledMessages)
polledMessages
- number of polled messagesprotected 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 boolean ignoreCannotRetrieveFile(String name, org.apache.camel.Exchange exchange, Exception cause)
GenericFileOperationFailedException
is thrown if the file cannot be retrieved.
This method allows to suppress this and just ignore that.name
- the file nameexchange
- the exchangecause
- optional exception occurred during retrieving fileprotected boolean processExchange(org.apache.camel.Exchange exchange)
exchange
- the exchangeprotected abstract void updateFileHeaders(GenericFile<T> file, org.apache.camel.Message message)
Message
after we have acquired read-lock and can begin process the file.file
- the filemessage
- the Camel message to update its headersprotected boolean isRetrieveFile()
protected boolean customProcessExchange(org.apache.camel.Exchange exchange, org.apache.camel.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 directoryprotected 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 directoryprotected 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 directoryprotected String evaluateFileExpression(org.apache.camel.Exchange exchange)
protected void doInit() throws Exception
doInit
in class org.apache.camel.support.ScheduledPollConsumer
Exception
protected void doStart() throws Exception
doStart
in class org.apache.camel.support.ScheduledPollConsumer
Exception
protected void doStop() throws Exception
doStop
in class org.apache.camel.support.ScheduledPollConsumer
Exception
public void onInit() throws Exception
onInit
in interface org.apache.camel.PollingConsumerPollingStrategy
onInit
in class org.apache.camel.support.ScheduledPollConsumer
Exception
public long beforePoll(long timeout) throws Exception
beforePoll
in interface org.apache.camel.PollingConsumerPollingStrategy
beforePoll
in class org.apache.camel.support.ScheduledPollConsumer
Exception
Apache Camel