|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.integration.file.FileReadingMessageSource
public class FileReadingMessageSource
MessageSource
that creates messages from a file system directory. To
prevent messages for certain files, you may supply a FileListFilter
.
By default, an AcceptOnceFileListFilter
is used. It ensures files are
picked up only once from the directory.
AcceptOnceFileListFilter
does not prevent this.
In most cases, this can be prevented if the file-writing process renames each
file as soon as it is ready for reading. A pattern-matching filter that
accepts only files that are ready (e.g. based on a known suffix), composed
with the default AcceptOnceFileListFilter
would allow for this. See
CompositeFileFilter
for a way to do this.
A Comparator
can be used to ensure internal ordering of the Files in
a PriorityBlockingQueue
. This does not provide the same guarantees as
a Resequencer
, but in cases where writing files and failure
downstream are rare it might be sufficient.
FileReadingMessageSource is fully thread-safe under concurrent
receive()
invocations and message delivery callbacks.
Constructor Summary | |
---|---|
FileReadingMessageSource()
Creates a FileReadingMessageSource with a naturally ordered queue. |
|
FileReadingMessageSource(java.util.Comparator<java.io.File> receptionOrderComparator)
Creates a FileReadingMessageSource with a PriorityBlockingQueue
ordered with the passed in Comparator
No guarantees about file delivery order can be made under concurrent
access. |
Method Summary | |
---|---|
void |
afterPropertiesSet()
|
void |
onFailure(Message<java.io.File> failedMessage,
java.lang.Throwable t)
Adds the failed message back to the 'toBeReceived' queue. |
void |
onSend(Message<java.io.File> sentMessage)
The message is just logged. |
Message<java.io.File> |
receive()
Retrieve the next available message from this source. |
void |
setAutoCreateDirectory(boolean autoCreateDirectory)
Specify whether to create the source directory automatically if it does not yet exist upon initialization. |
void |
setFilter(FileListFilter filter)
Sets a FileListFilter . |
void |
setInputDirectory(org.springframework.core.io.Resource inputDirectory)
Specify the input directory. |
void |
setScanEachPoll(boolean scanEachPoll)
Optional. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public FileReadingMessageSource()
public FileReadingMessageSource(java.util.Comparator<java.io.File> receptionOrderComparator)
PriorityBlockingQueue
ordered with the passed in Comparator
No guarantees about file delivery order can be made under concurrent
access.
Method Detail |
---|
public void setInputDirectory(org.springframework.core.io.Resource inputDirectory)
public void setAutoCreateDirectory(boolean autoCreateDirectory)
public void setFilter(FileListFilter filter)
FileListFilter
. By default a
AcceptOnceFileListFilter
with no bounds is used. In most cases a
customized FileListFilter
will be needed to deal with
modification and duplication concerns. If multiple filters are required a
CompositeFileListFilter
can be used to group them together.
The supplied filter must be thread safe..
public void setScanEachPoll(boolean scanEachPoll)
public final void afterPropertiesSet()
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
public Message<java.io.File> receive() throws MessagingException
MessageSource
null
if no message is available.
receive
in interface MessageSource<java.io.File>
MessagingException
public void onFailure(Message<java.io.File> failedMessage, java.lang.Throwable t)
public void onSend(Message<java.io.File> sentMessage)
receive()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |