public abstract class FileSystemListener<F,FS extends IBasicFileSystem<F>> extends Object implements IPullingListener<F>, HasPhysicalDestination, IProvidesMessageBrowsers<F>
listener
that looks in a FileSystem
for files.
When a file is found, it is moved to an process-folder, so that it isn't found more then once.
The name of the moved file is passed to the pipeline.Modifier and Type | Field and Description |
---|---|
static String |
FILENAME_KEY |
static String |
FILEPATH_KEY |
protected org.apache.logging.log4j.Logger |
log |
static String |
ORIGINAL_FILENAME_KEY |
Constructor and Description |
---|
FileSystemListener() |
Modifier and Type | Method and Description |
---|---|
void |
afterMessageProcessed(PipeLineResult processResult,
RawMessageWrapper<F> rawMessage,
PipeLineSession pipeLineSession)
Called to perform actions (like committing or sending a reply) after a message has been processed by the
Pipeline.
|
RawMessageWrapper<F> |
changeProcessState(RawMessageWrapper<F> message,
ProcessState toState,
String reason)
Change the processState of the message to the specified state, if that state
is supported.
|
protected boolean |
checkForExistenceOfFolder(String attributeName,
String folderName) |
void |
close()
Close all resources used for listening.
|
void |
closeThread(Map<String,Object> threadContext)
Finalizes a message receiving thread.
|
void |
configure()
configure() is called once at startup of the framework in the configure() method
of the owner of this listener. |
protected abstract FS |
createFileSystem() |
Message |
extractMessage(RawMessageWrapper<F> rawMessage,
Map<String,Object> context)
Returns the filename, or the contents
|
Map<String,Object> |
extractMessageProperties(F rawMessage,
String originalFilename) |
String |
getDomain() |
IMessageBrowser<F> |
getMessageBrowser(ProcessState state)
returns a
browser of messages that are in ProcessState 'state', and are stored in a
storage managed by the listener itself (as opposed to a storage configured as a messageLog or errorStorage in the configuration). |
String |
getPhysicalDestinationName() |
RawMessageWrapper<F> |
getRawMessage(Map<String,Object> threadContext)
Retrieves messages from queue or other channel, but does no processing on it.
|
String |
getStateFolder(ProcessState state) |
Set<ProcessState> |
knownProcessStates()
Provides the set of ProcessStates used by this listener.
|
void |
open()
Prepares the listener for receiving messages.
|
Map<String,Object> |
openThread()
Prepares a thread for receiving messages.
|
void |
setCharset(String charset)
Charset to be used for extracting the contents
|
void |
setCreateFolders(boolean createFolders)
If set to
true , the folders to look for files and to move files to when being processed and after being processed are created if they are specified and do not exist |
void |
setCreateInputDirectory(boolean createInputDirectory)
Deprecated.
|
void |
setDelete(boolean b)
If set
true , the file processed will be deleted after being processed, and not stored |
void |
setDisableMessageBrowsers(boolean disableMessageBrowsers)
If set
true , no browsers for process folders are generated |
void |
setErrorFolder(String errorFolder)
Folder where files are stored after being processed, in case the exit-state was not equal to
success |
void |
setExcludeWildcard(String excludeWildcard)
Filter of files to be excluded when looking in inputFolder.
|
void |
setExcludeWildCard(String excludeWildcard)
Deprecated.
|
void |
setFileTimeSensitive(boolean b)
If
true , the file modification time is used in addition to the filename to determine if a file has been seen before |
void |
setHoldFolder(String holdFolder)
Folder where messages from the error folder can be put on Hold, temporarily
|
void |
setInProcessFolder(String inProcessFolder)
Folder where files are stored while being processed
|
void |
setInputDirectory(String inputDirectory)
Deprecated.
|
void |
setInputFolder(String inputFolder)
Folder that is scanned for files.
|
void |
setLogFolder(String logFolder)
Folder where a copy of every file that is received is stored
|
void |
setMessageIdPropertyKey(String messageIdPropertyKey)
Key of Property to use as messageId.
|
void |
setMessageType(String messageType)
Determines the contents of the message that is sent to the pipeline.
|
void |
setMinStableTime(long minStableTime)
Minimal age of file in milliseconds, to avoid receiving a file while it is still being written
|
void |
setName(String name)
The functional name of the object.
|
void |
setNumberOfBackups(int i)
Number of copies held of a file with the same name.
|
void |
setOutputDirectory(String outputDirectory)
Deprecated.
|
void |
setOutputFormat(DocumentFormat outputFormat)
OutputFormat of message for messageType=info
|
void |
setOverwrite(boolean overwrite)
If set
true , the destination file will be deleted if it already exists |
void |
setProcessedDirectory(String processedDirectory)
Deprecated.
|
void |
setProcessedFolder(String processedFolder)
Folder where files are stored after being processed
|
void |
setStoreMetadataInSessionKey(String storeMetadataInSessionKey)
If set, an XML with all message properties is provided under this key
|
void |
setWildcard(String wildcard)
Filter of files to look for in inputFolder e.g.
|
void |
setWildCard(String wildcard)
Deprecated.
|
Map<ProcessState,Set<ProcessState>> |
targetProcessStates()
Provides the set of ProcessStates that a message in the specified state can be moved to, e.g.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getName
getApplicationContext, getName
getConfigurationClassLoader
protected org.apache.logging.log4j.Logger log
public static final String ORIGINAL_FILENAME_KEY
public static final String FILENAME_KEY
public static final String FILEPATH_KEY
protected abstract FS createFileSystem()
public void configure() throws ConfigurationException
IListener
configure()
is called once at startup of the framework in the configure()
method
of the owner of this listener.
Purpose of this method is to reduce creating connections to databases etc. in the IPullingListener.getRawMessage(Map)
method.
As much as possible class-instantiating should take place in the
configure()
or open()
method, to improve performance.configure
in interface IConfigurable
configure
in interface IListener<F>
ConfigurationException
public Set<ProcessState> knownProcessStates()
IHasProcessState
knownProcessStates
in interface IHasProcessState<F>
public Map<ProcessState,Set<ProcessState>> targetProcessStates()
IHasProcessState
targetProcessStates
in interface IHasProcessState<F>
public void open() throws ListenerException
IListener
open()
is called once each time the listener is started.open
in interface IListener<F>
ListenerException
protected boolean checkForExistenceOfFolder(String attributeName, String folderName) throws ListenerException
ListenerException
public void close() throws ListenerException
IListener
close
in interface IListener<F>
ListenerException
@Nonnull public Map<String,Object> openThread() throws ListenerException
IPullingListener
openThread
in interface IPullingListener<F>
null
, must be a mutable map type.ListenerException
public void closeThread(@Nonnull Map<String,Object> threadContext) throws ListenerException
IPullingListener
IListener.close()
is called.closeThread
in interface IPullingListener<F>
ListenerException
public String getPhysicalDestinationName()
getPhysicalDestinationName
in interface HasPhysicalDestination
public String getDomain()
getDomain
in interface HasPhysicalDestination
public RawMessageWrapper<F> getRawMessage(@Nonnull Map<String,Object> threadContext) throws ListenerException
IPullingListener
synchronized
.
Any thread-specific properties should be stored in and retrieved from the threadContext.
getRawMessage
in interface IPullingListener<F>
ListenerException
public void afterMessageProcessed(PipeLineResult processResult, RawMessageWrapper<F> rawMessage, PipeLineSession pipeLineSession) throws ListenerException
IListener
afterMessageProcessed
in interface IListener<F>
ListenerException
public Message extractMessage(@Nonnull RawMessageWrapper<F> rawMessage, @Nonnull Map<String,Object> context) throws ListenerException
extractMessage
in interface IListener<F>
rawMessage
- The RawMessageWrapper
from which to extract the Message
.context
- Context to populate. Either a PipeLineSession
or a Map
threadContext depending on caller.Message
for adapter.ListenerException
@Nonnull public Map<String,Object> extractMessageProperties(@Nonnull F rawMessage, @Nullable String originalFilename) throws ListenerException
ListenerException
public RawMessageWrapper<F> changeProcessState(RawMessageWrapper<F> message, ProcessState toState, String reason) throws ListenerException
IHasProcessState
false
is returned.changeProcessState
in interface IHasProcessState<F>
ListenerException
public String getStateFolder(ProcessState state)
public IMessageBrowser<F> getMessageBrowser(ProcessState state)
IProvidesMessageBrowsers
browser
of messages that are in ProcessState 'state', and are stored in a
storage managed by the listener itself (as opposed to a storage configured as a messageLog or errorStorage in the configuration).getMessageBrowser
in interface IProvidesMessageBrowsers<F>
public void setName(String name)
INamedObject
setName
in interface INamedObject
@Deprecated @ConfigurationWarning(value="attribute \'inputDirectory\' has been replaced by \'inputFolder\'") public void setInputDirectory(String inputDirectory)
public void setInputFolder(String inputFolder)
@Deprecated @ConfigurationWarning(value="attribute \'outputDirectory\' has been replaced by \'inProcessFolder\'") public void setOutputDirectory(String outputDirectory)
public void setInProcessFolder(String inProcessFolder)
@Deprecated @ConfigurationWarning(value="attribute \'processedDirectory\' has been replaced by \'processedFolder\'") public void setProcessedDirectory(String processedDirectory)
public void setProcessedFolder(String processedFolder)
public void setErrorFolder(String errorFolder)
success
public void setHoldFolder(String holdFolder)
public void setLogFolder(String logFolder)
public void setCreateFolders(boolean createFolders)
true
, the folders to look for files and to move files to when being processed and after being processed are created if they are specified and do not exist@Deprecated @ConfigurationWarning(value="attribute \'createInputDirectory\' has been replaced by \'createFolders\'") public void setCreateInputDirectory(boolean createInputDirectory)
public void setDelete(boolean b)
true
, the file processed will be deleted after being processed, and not storedpublic void setNumberOfBackups(int i)
public void setOverwrite(boolean overwrite)
true
, the destination file will be deleted if it already existspublic void setMessageType(String messageType)
public void setFileTimeSensitive(boolean b)
true
, the file modification time is used in addition to the filename to determine if a file has been seen beforepublic void setMinStableTime(long minStableTime)
public void setMessageIdPropertyKey(String messageIdPropertyKey)
public void setDisableMessageBrowsers(boolean disableMessageBrowsers)
true
, no browsers for process folders are generated@Deprecated @ConfigurationWarning(value="attribute \'wildCard\' has been renamed to \'wildcard\'") public void setWildCard(String wildcard)
public void setWildcard(String wildcard)
@Deprecated @ConfigurationWarning(value="attribute \'excludeWildCard\' has been renamed to \'excludeWildcard\'") public void setExcludeWildCard(String excludeWildcard)
public void setExcludeWildcard(String excludeWildcard)
public void setStoreMetadataInSessionKey(String storeMetadataInSessionKey)
public void setCharset(String charset)
public void setOutputFormat(DocumentFormat outputFormat)
Copyright © 2023 Frank!Framework. All rights reserved.