@ComponentProfile(summary="Pickup messages from the filesystem without deleting them afterwards", tag="consumer,fs,filesystem", metadata={"originalname","fsFileSize","lastmodified","fsConsumeDir","_interlokMessageConsumedFrom","fsParentDir"}, recommended=NullConnection.class) public class NonDeletingFsConsumer extends FsConsumerImpl
File system implementation of AdaptrisMessageConsumer
based on the com.adaptris.fs
package.
This differs from the standard implementation of FsConsumer in that it processes the file 'in-situ' and does not delete the file after processing. To avoid constantly re-processing the same file over and over again, you can configure a ProcessedItemCache which stores the last modified timestamp of the file and only re-processes the file if it changes.
The configured Destination
may return a string in one of two formats
file
based url is used. e.g. file:///c:/path/to/my/directory or file:////path/to/my/directory then the
patch is considered to be fully qualifiedOn windows based platforms, you should always use a file based url.
In the adapter configuration file this class is aliased as non-deleting-fs-consumer which is the preferred alternative to the fully qualified classname when building your configuration.
AdaptrisPollingConsumer.LockOperator
fileFilter, fsWorker
log
CONFIRMATION_ID_KEY
Constructor and Description |
---|
NonDeletingFsConsumer()
Creates a new instance.
|
NonDeletingFsConsumer(ConsumeDestination d) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the component.
|
ProcessedItemCache |
getProcessedItemCache() |
protected boolean |
hasChanged(ProcessedItem entry) |
void |
init()
Initialises the component.
|
protected void |
prepareConsumer() |
protected int |
processFile(java.io.File fileToProcess)
Attempt to process this file which might be a directory.
|
protected int |
processMessages()
If reacquire-lock-between-messages is set to true, this.reaquireLock is called after each message has been processed.
|
void |
setProcessedItemCache(ProcessedItemCache cache) |
void |
start()
Starts the component.
|
void |
stop()
Stop the component
|
addStandardMetadata, checkModified, consumeLocationKey, createAdaptrisMessage, getCreateDirs, getFileFilterImp, getFileSorter, getLogAllExceptions, getQuietInterval, isFileAccessible, logAllExceptions, setCreateDirs, setFileFilterImp, setFileSorter, setLogAllExceptions, setQuietInterval, shouldCreateDirs, verifyDirectory
continueProcessingMessages, getMaxMessagesPerPoll, getPoller, getReacquireLockBetweenMessages, prepare, releaseLock, setMaxMessagesPerPoll, setPoller, setReacquireLockBetweenMessages
changeState, getDestination, registerAdaptrisMessageListener, renameThread, requestClose, requestInit, requestStart, requestStop, retrieveAdaptrisMessageListener, retrieveComponentState, setDestination
createName, createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactory
getUniqueId
createName, createQualifier, isTrackingEndpoint
public NonDeletingFsConsumer()
Creates a new instance.
public NonDeletingFsConsumer(ConsumeDestination d)
protected int processMessages()
FsConsumerImpl
If reacquire-lock-between-messages is set to true, this.reaquireLock is called after each message has been processed. This gives other Threads (e.g. something stopping the adapter) the opportunity to obtain the lock without waiting for all messages to be processed.
processMessages
in class FsConsumerImpl
AdaptrisPollingConsumer.processMessages()
protected int processFile(java.io.File fileToProcess) throws CoreException
FsConsumerImpl
processFile
in class FsConsumerImpl
fileToProcess
- the FileCoreException
- wrapping any other Exception.protected void prepareConsumer() throws CoreException
prepareConsumer
in class AdaptrisPollingConsumer
CoreException
public void init() throws CoreException
ComponentLifecycle
Component initialisation includes config verification, creation of connections etc.
init
in interface ComponentLifecycle
init
in class FsConsumerImpl
CoreException
- wrapping any underlying Exception
sComponentLifecycle.init()
public void start() throws CoreException
ComponentLifecycle
Once a component is started it should be ready to process messages. In the case of AdaptrisMessageConsumer
, calling start
will begin message delivery.
start
in interface ComponentLifecycle
start
in class AdaptrisPollingConsumer
CoreException
- wrapping any underlying Exception
sComponentLifecycle.start()
public void close()
ComponentLifecycle
A closed component should release any connections it uses, etc. and clean up completely. Throwing a RuntimeException
may
cause unintended consequences
close
in interface ComponentLifecycle
close
in class AdaptrisPollingConsumer
ComponentLifecycle.close()
public void stop()
ComponentLifecycle
A stopped component is not expected to be ready to process messages. In the case of AdaptrisMessageConsumer
, calling stop
will pause message delivery. Throwing a RuntimeException
may cause unintended consequences
stop
in interface ComponentLifecycle
stop
in class AdaptrisPollingConsumer
ComponentLifecycle.stop()
public ProcessedItemCache getProcessedItemCache()
public void setProcessedItemCache(ProcessedItemCache cache)
protected boolean hasChanged(ProcessedItem entry) throws java.lang.Exception
java.lang.Exception