Class NonDeletingFsConsumer
- java.lang.Object
-
- com.adaptris.core.AdaptrisMessageWorkerImp
-
- com.adaptris.core.AdaptrisMessageConsumerImp
-
- com.adaptris.core.AdaptrisPollingConsumer
-
- com.adaptris.core.fs.FsConsumerImpl
-
- com.adaptris.core.fs.NonDeletingFsConsumer
-
- All Implemented Interfaces:
AdaptrisComponent
,AdaptrisMessageConsumer
,AdaptrisMessageWorker
,ComponentLifecycle
,ComponentLifecycleExtension
,MessageEventGenerator
,StateManagedComponent
- Direct Known Subclasses:
MovingNonDeletingFsConsumer
@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 thecom.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- 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.
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.
-
-
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 NonDeletingFsConsumer()
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the component.ProcessedItemCache
getProcessedItemCache()
protected boolean
hasChanged(ProcessedItem entry)
void
init()
Initialises the component.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-
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, setBaseDirectoryUrl, setCreateDirs, setFileFilterImp, setFileSorter, setFilterExpression, setLogAllExceptions, setQuietInterval, shouldCreateDirs, verifyDirectory, withBaseDirectoryUrl, withFilterExpression
-
Methods inherited from class com.adaptris.core.AdaptrisPollingConsumer
continueProcessingMessages, getMaxMessagesPerPoll, getPoller, getReacquireLockBetweenMessages, prepare, releaseLock, setMaxMessagesPerPoll, setPoller, setReacquireLockBetweenMessages
-
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
-
processMessages
protected int processMessages()
Description copied from class: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.
- Overrides:
processMessages
in classFsConsumerImpl
- See Also:
AdaptrisPollingConsumer.processMessages()
-
processFile
protected int processFile(java.io.File fileToProcess) throws CoreException
Description copied from class:FsConsumerImpl
Attempt to process this file which might be a directory.- Specified by:
processFile
in classFsConsumerImpl
- Parameters:
fileToProcess
- the File- Returns:
- the number of files processed.
- Throws:
CoreException
- wrapping any other Exception.
-
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()
-
start
public void start() throws CoreException
Description copied from interface:ComponentLifecycle
Starts the component.Once a component is started it should be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling start will begin message delivery.- Specified by:
start
in interfaceComponentLifecycle
- Overrides:
start
in classAdaptrisPollingConsumer
- Throws:
CoreException
- wrapping any underlyingException
s- See Also:
ComponentLifecycle.start()
-
close
public void close()
Description copied from interface:ComponentLifecycle
Closes the component.A closed component should release any connections it uses, etc. and clean up completely. Throwing a
RuntimeException
may cause unintended consequences- Specified by:
close
in interfaceComponentLifecycle
- Overrides:
close
in classAdaptrisPollingConsumer
- See Also:
ComponentLifecycle.close()
-
stop
public void stop()
Description copied from interface:ComponentLifecycle
Stop the componentA stopped component is not expected to be ready to process messages. In the case of
AdaptrisMessageConsumer
, calling stop will pause message delivery. Throwing aRuntimeException
may cause unintended consequences- Specified by:
stop
in interfaceComponentLifecycle
- Overrides:
stop
in classAdaptrisPollingConsumer
- See Also:
ComponentLifecycle.stop()
-
getProcessedItemCache
public ProcessedItemCache getProcessedItemCache()
-
setProcessedItemCache
public void setProcessedItemCache(ProcessedItemCache cache)
-
hasChanged
protected boolean hasChanged(ProcessedItem entry) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-