Package org.apache.camel.component.file
Class FileConsumer
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.support.DefaultConsumer
-
- org.apache.camel.support.ScheduledPollConsumer
-
- org.apache.camel.support.ScheduledBatchPollingConsumer
-
- org.apache.camel.component.file.GenericFileConsumer<File>
-
- org.apache.camel.component.file.FileConsumer
-
- All Implemented Interfaces:
AutoCloseable
,Runnable
,org.apache.camel.BatchConsumer
,org.apache.camel.Consumer
,org.apache.camel.EndpointAware
,org.apache.camel.health.HealthCheckAware
,org.apache.camel.PollingConsumerPollingStrategy
,org.apache.camel.RouteAware
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.RouteIdAware
,org.apache.camel.spi.ShutdownAware
,org.apache.camel.spi.ShutdownPrepared
,org.apache.camel.StatefulService
,org.apache.camel.Suspendable
,org.apache.camel.SuspendableService
public class FileConsumer extends GenericFileConsumer<File>
File consumer.
-
-
Field Summary
-
Fields inherited from class org.apache.camel.component.file.GenericFileConsumer
customProcessor, eagerLimitMaxMessagesPerPoll, endpoint, operations, pendingExchanges, prepareOnStartup, processStrategy, shutdownRunningTask
-
-
Constructor Summary
Constructors Constructor Description FileConsumer(FileEndpoint endpoint, org.apache.camel.Processor processor, GenericFileOperations<File> operations, GenericFileProcessStrategy<File> processStrategy)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static GenericFile<File>
asGenericFile(String endpointPath, File file, String charset, boolean probeContentType)
Creates a new GenericFilebased on the given file. protected org.apache.camel.Exchange
createExchange(GenericFile<File> file)
Creates the exchange from the polled fileFileEndpoint
getEndpoint()
protected boolean
isMatched(GenericFile<File> file, String doneFileName, File[] files)
Strategy to perform file matching based on endpoint configuration in terms of done file name.protected boolean
pollDirectory(String fileName, List<GenericFile<File>> fileList, int depth)
Polls the given directory for files to processprotected void
updateFileHeaders(GenericFile<File> file, org.apache.camel.Message message)
Updates the information onMessage
after we have acquired read-lock and can begin process the file.-
Methods inherited from class org.apache.camel.component.file.GenericFileConsumer
afterPoll, beforePoll, canPollMoreFiles, customProcessExchange, doInit, doStart, doStop, evaluateFileExpression, getCustomProcessor, ignoreCannotRetrieveFile, isEagerLimitMaxMessagesPerPoll, isMatched, isRetrieveFile, isValidFile, onInit, poll, postPollCheck, prePollCheck, processBatch, processExchange, removeExcessiveInProgressFiles, removeExcessiveInProgressFiles, setCustomProcessor, setEagerLimitMaxMessagesPerPoll, setOperations
-
Methods inherited from class org.apache.camel.support.ScheduledBatchPollingConsumer
deferShutdown, getMaxMessagesPerPoll, getPendingExchangesSize, isBatchAllowed, prepareShutdown, processEmptyMessage, setMaxMessagesPerPoll
-
Methods inherited from class org.apache.camel.support.ScheduledPollConsumer
addLastErrorDetail, afterConfigureScheduler, doBuild, doShutdown, doSuspend, getBackoffCounter, getBackoffErrorThreshold, getBackoffIdleThreshold, getBackoffMultiplier, getCounter, getDelay, getErrorCounter, getInitialDelay, getLastError, getLastErrorDetails, getPollStrategy, getRepeatCount, getRunLoggingLevel, getScheduledExecutorService, getScheduler, getSchedulerProperties, getSuccessCounter, getTimeUnit, isFirstPollDone, 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
-
Methods inherited from class org.apache.camel.support.DefaultConsumer
createExchange, createUoW, defaultConsumerCallback, doneUoW, getAsyncProcessor, getExceptionHandler, getHealthCheck, getProcessor, getRoute, getRouteId, handleException, handleException, releaseExchange, setExceptionHandler, setHealthCheck, setRoute, setRouteId, toString
-
Methods inherited from class org.apache.camel.support.service.BaseService
build, 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
-
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
createExchange, defaultConsumerCallback, getProcessor, releaseExchange
-
Methods inherited from interface org.apache.camel.health.HealthCheckAware
getHealthCheck, setHealthCheck
-
-
-
-
Constructor Detail
-
FileConsumer
public FileConsumer(FileEndpoint endpoint, org.apache.camel.Processor processor, GenericFileOperations<File> operations, GenericFileProcessStrategy<File> processStrategy)
-
-
Method Detail
-
createExchange
protected org.apache.camel.Exchange createExchange(GenericFile<File> file)
Description copied from class:GenericFileConsumer
Creates the exchange from the polled file- Specified by:
createExchange
in classGenericFileConsumer<File>
-
pollDirectory
protected boolean pollDirectory(String fileName, List<GenericFile<File>> fileList, int depth)
Description copied from class:GenericFileConsumer
Polls the given directory for files to process- Specified by:
pollDirectory
in classGenericFileConsumer<File>
- Parameters:
fileName
- current directory or filefileList
- current list of files gathereddepth
- the current depth of the directory (will start from 0)- Returns:
- whether or not to continue polling, false means the maxMessagesPerPoll limit has been hit
-
isMatched
protected boolean isMatched(GenericFile<File> file, String doneFileName, File[] files)
Description copied from class:GenericFileConsumer
Strategy to perform file matching based on endpoint configuration in terms of done file name.- Specified by:
isMatched
in classGenericFileConsumer<File>
- Parameters:
file
- the filedoneFileName
- the done file name (without any paths)files
- files in the directory- Returns:
- true if the file is matched, false if not
-
asGenericFile
public static GenericFile<File> asGenericFile(String endpointPath, File file, String charset, boolean probeContentType)
Creates a new GenericFilebased on the given file. - Parameters:
endpointPath
- the starting directory the endpoint was configured withfile
- the source fileprobeContentType
- whether to probe the content type of the file or not- Returns:
- wrapped as a GenericFile
-
updateFileHeaders
protected void updateFileHeaders(GenericFile<File> file, org.apache.camel.Message message)
Description copied from class:GenericFileConsumer
Updates the information onMessage
after we have acquired read-lock and can begin process the file.- Specified by:
updateFileHeaders
in classGenericFileConsumer<File>
- Parameters:
file
- the filemessage
- the Camel message to update its headers
-
getEndpoint
public FileEndpoint getEndpoint()
- Specified by:
getEndpoint
in interfaceorg.apache.camel.EndpointAware
- Overrides:
getEndpoint
in classorg.apache.camel.support.DefaultConsumer
-
-