|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.camel.impl.ServiceSupport org.apache.camel.impl.DefaultConsumer org.apache.camel.impl.ScheduledPollConsumer org.apache.camel.component.file.GenericFileConsumer<T>
public abstract class GenericFileConsumer<T>
Base class for remote file consumers.
Field Summary | |
---|---|
protected GenericFileEndpoint<T> |
endpoint
|
protected String |
fileExpressionResult
|
protected org.apache.commons.logging.Log |
log
|
protected boolean |
loggedIn
|
protected int |
maxMessagesPerPoll
|
protected GenericFileOperations<T> |
operations
|
protected int |
pendingExchanges
|
protected ShutdownRunningTask |
shutdownRunningTask
|
Constructor Summary | |
---|---|
GenericFileConsumer(GenericFileEndpoint<T> endpoint,
Processor processor,
GenericFileOperations<T> operations)
|
Method Summary | |
---|---|
boolean |
deferShutdown(ShutdownRunningTask shutdownRunningTask)
To defer shutdown during first phase of shutdown. |
protected void |
doStart()
|
int |
getPendingExchangesSize()
Gets the number of pending exchanges. |
boolean |
isBatchAllowed()
Whether processing the batch is still allowed. |
protected boolean |
isInProgress(GenericFile<T> file)
Is the given file already in progress. |
protected boolean |
isMatched(GenericFile<T> file,
boolean isDirectory)
Strategy to perform file matching based on endpoint configuration. |
protected boolean |
isValidFile(GenericFile<T> file,
boolean isDirectory)
Strategy for validating if the given remote file should be included or not |
protected void |
poll()
Poll for files |
protected abstract void |
pollDirectory(String fileName,
List<GenericFile<T>> fileList)
Polls the given directory for files to process |
protected void |
postPollCheck()
Override if required. |
protected boolean |
prePollCheck()
Override if required. |
void |
processBatch(Queue<Object> exchanges)
Processes the list of Exchange in a batch. |
protected void |
processExchange(Exchange exchange)
Processes the exchange |
void |
setMaxMessagesPerPoll(int maxMessagesPerPoll)
Sets a maximum number of messages as a limit to poll at each polling. |
Methods inherited from class org.apache.camel.impl.ScheduledPollConsumer |
---|
doStop, getDelay, getInitialDelay, getPollStrategy, getTimeUnit, isPollAllowed, isSuspended, isUseFixedDelay, resume, run, setDelay, setInitialDelay, setPollStrategy, setTimeUnit, setUseFixedDelay, suspend |
Methods inherited from class org.apache.camel.impl.DefaultConsumer |
---|
getEndpoint, getExceptionHandler, getProcessor, handleException, setExceptionHandler, toString |
Methods inherited from class org.apache.camel.impl.ServiceSupport |
---|
addChildService, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, removeChildService, start, stop |
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 |
Field Detail |
---|
protected final transient org.apache.commons.logging.Log log
protected GenericFileEndpoint<T> endpoint
protected GenericFileOperations<T> operations
protected boolean loggedIn
protected String fileExpressionResult
protected int maxMessagesPerPoll
protected volatile ShutdownRunningTask shutdownRunningTask
protected volatile int pendingExchanges
Constructor Detail |
---|
public GenericFileConsumer(GenericFileEndpoint<T> endpoint, Processor processor, GenericFileOperations<T> operations)
Method Detail |
---|
protected void poll() throws Exception
poll
in class ScheduledPollConsumer
Exception
- can be thrown if an exception occurred during pollingpublic void setMaxMessagesPerPoll(int maxMessagesPerPoll)
BatchConsumer
setMaxMessagesPerPoll
in interface BatchConsumer
maxMessagesPerPoll
- maximum messages to poll.public void processBatch(Queue<Object> exchanges)
BatchConsumer
Exchange
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.
processBatch
in interface BatchConsumer
exchanges
- list of items in this batchpublic boolean deferShutdown(ShutdownRunningTask shutdownRunningTask)
ShutdownAware
SedaConsumer
.
deferShutdown
in interface ShutdownAware
shutdownRunningTask
- the configured option for how to act when shutting down running tasks.
public int getPendingExchangesSize()
ShutdownAware
Exchange
which are pending.
For example the SedaConsumer
.
Return zero to indicate no pending exchanges and therefore ready to shutdown.
getPendingExchangesSize
in interface ShutdownAware
public boolean isBatchAllowed()
BatchConsumer
isBatchAllowed
in interface BatchConsumer
ShutdownRunningTask
protected boolean prePollCheck() throws Exception
Exception
protected void postPollCheck()
protected abstract void pollDirectory(String fileName, List<GenericFile<T>> fileList)
fileName
- current directory or filefileList
- current list of files gatheredprotected void processExchange(Exchange exchange)
exchange
- the exchangeprotected boolean isValidFile(GenericFile<T> file, boolean isDirectory)
file
- the remote fileisDirectory
- whether the file is a directory or a file
protected boolean isMatched(GenericFile<T> file, boolean isDirectory)
file
- the fileisDirectory
- whether the file is a directory or a file
protected boolean isInProgress(GenericFile<T> file)
file
- the file
protected void doStart() throws Exception
doStart
in class ScheduledPollConsumer
Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |