Class FsConsumer
- java.lang.Object
-
- All Implemented Interfaces:
AdaptrisComponent
,AdaptrisMessageConsumer
,AdaptrisMessageWorker
,ComponentLifecycle
,ComponentLifecycleExtension
,MessageEventGenerator
,StateManagedComponent
- Direct Known Subclasses:
LargeFsConsumer
,TraversingFsConsumer
@ComponentProfile(summary="Pickup messages from the filesystem", tag="consumer,fs,filesystem", metadata={"originalname","fsFileSize","lastmodified","fsConsumeDir","_interlokMessageConsumedFrom","fsParentDir"}, recommended=NullConnection.class) public class FsConsumer extends FsConsumerImpl
File system implementation of
AdaptrisMessageConsumer
based on thecom.adaptris.fs
package.The configured
Destination
may return a string in one of two formats- If a
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 qualified - If just a path is returned, then it is considered to be relative to the current working directory. e.g. if /opt/fred is used, and the adapter is installed to /opt/adapter, then the fully qualified name is /opt/adapter/opt/fred.
On windows based platforms, you should always use a file based url.
Once A file has been consumed from the file-system a standard set of metadata is added to the resulting message;
Metadata Key Description originalname Metadata key for storing the original name (generally file name) of a message. lastmodified Metadata key for storing the last modified date of the consumed file. fsFileSize Metadata key for storing the size of the message. fsConsumeDir Metadata key for storing the directory where a file was consumed from. fsParentDir Metadata key for storing the name of the immediate parent directory that a file was consumed from. In the adapter configuration file this class is aliased as fs-consumer which is the preferred alternative to the fully qualified classname when building your configuration.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.adaptris.core.AdaptrisPollingConsumer
AdaptrisPollingConsumer.LockOperator
-
-
Field Summary
-
Fields inherited from class com.adaptris.core.fs.FsConsumerImpl
fileFilter, fsWorker
-
Fields inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
log
-
-
Constructor Summary
Constructors Constructor Description FsConsumer()
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Boolean
getResetWipFiles()
java.lang.String
getWipSuffix()
Returns the work-in-progress suffix being used.void
init()
Initialises the component.protected int
processFile(java.io.File originalFile)
Attempt to process this file which might be a directory.protected java.io.File
renameFile(java.io.File file)
protected boolean
resetWipFiles()
void
setResetWipFiles(java.lang.Boolean b)
Specify whether to rename files that are deemed to be in progress back to their original extension upon initialisation.void
setWipSuffix(java.lang.String s)
Sets the work-in-progress suffix to use.-
Methods inherited from class com.adaptris.core.fs.FsConsumerImpl
addStandardMetadata, baseDirUrl, checkModified, consumeLocationKey, createAdaptrisMessage, filterExpression, getBaseDirectoryUrl, getCreateDirs, getFileFilterImp, getFileSorter, getFilterExpression, getLogAllExceptions, getQuietInterval, isFileAccessible, logAllExceptions, prepareConsumer, processMessages, setBaseDirectoryUrl, setCreateDirs, setFileFilterImp, setFileSorter, setFilterExpression, setLogAllExceptions, setQuietInterval, shouldCreateDirs, verifyDirectory, withBaseDirectoryUrl, withFilterExpression
-
Methods inherited from class com.adaptris.core.AdaptrisPollingConsumer
close, continueProcessingMessages, getMaxMessagesPerPoll, getPoller, getReacquireLockBetweenMessages, prepare, releaseLock, setMaxMessagesPerPoll, setPoller, setReacquireLockBetweenMessages, start, stop
-
Methods inherited from class com.adaptris.core.AdaptrisMessageConsumerImp
changeState, newThreadName, registerAdaptrisMessageListener, renameThread, requestClose, requestInit, requestStart, requestStop, retrieveAdaptrisMessageListener, retrieveComponentState
-
Methods inherited from class com.adaptris.core.AdaptrisMessageWorkerImp
createName, createQualifier, decode, encode, getEncoder, getIsTrackingEndpoint, getMessageFactory, getUniqueId, handleConnectionException, isTrackingEndpoint, registerConnection, registerEncoderMessageFactory, retrieveConnection, setEncoder, setIsTrackingEndpoint, setMessageFactory, setUniqueId, withMessageFactory, withUniqueID
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.adaptris.core.AdaptrisComponent
getUniqueId
-
Methods inherited from interface com.adaptris.core.AdaptrisMessageWorker
decode, encode, getEncoder, getMessageFactory, handleConnectionException, registerConnection, retrieveConnection, setEncoder, setMessageFactory
-
Methods inherited from interface com.adaptris.core.MessageEventGenerator
createName, createQualifier, isTrackingEndpoint
-
-
-
-
Method Detail
-
processFile
protected int processFile(java.io.File originalFile) throws CoreException
Description copied from class:FsConsumerImpl
Attempt to process this file which might be a directory.- Specified by:
processFile
in classFsConsumerImpl
- Parameters:
originalFile
- the File- Returns:
- the number of files processed.
- Throws:
CoreException
- wrapping any other Exception.
-
renameFile
protected java.io.File renameFile(java.io.File file) throws FsException
- Throws:
FsException
-
init
public void init() throws CoreException
Description copied from interface:ComponentLifecycle
Initialises the component.Component initialisation includes config verification, creation of connections etc.
- Specified by:
init
in interfaceComponentLifecycle
- Overrides:
init
in classFsConsumerImpl
- Throws:
CoreException
- wrapping any underlyingException
s- See Also:
ComponentLifecycle.init()
-
setWipSuffix
public void setWipSuffix(java.lang.String s)
Sets the work-in-progress suffix to use. May not be null or empty. This suffix is added to the original file name while the file is being processed.
- Parameters:
s
- the work-in-progress suffix to use
-
getWipSuffix
public java.lang.String getWipSuffix()
Returns the work-in-progress suffix being used.
- Returns:
- the work-in-progress suffix being used
-
getResetWipFiles
public java.lang.Boolean getResetWipFiles()
- Returns:
- the ResetWipFiles
-
setResetWipFiles
public void setResetWipFiles(java.lang.Boolean b)
Specify whether to rename files that are deemed to be in progress back to their original extension upon initialisation.Note that if the workfile has been created with the current time in ms (due to file-conflicts upon a previous execution), then setting this to true will result in the current time in ms still being present and may not result in the re-processing of the files.
- Parameters:
b
- the renameWorkFilesUponInitialisation to set
-
resetWipFiles
protected boolean resetWipFiles()
-
-