INT-984: added file locking and scanner documentation
This commit is contained in:
@@ -100,6 +100,35 @@
|
||||
you can use a <classname>CompositeFileListFilter</classname> to use any combination of filters, including a
|
||||
pattern based filter to fit your particular needs.
|
||||
</para>
|
||||
<para>
|
||||
When multiple processes are reading from the same directory it can be desirable to lock files to prevent
|
||||
them from being picked up concurrently. To do this you can use a <interfacename>FileLocker</interfacename>.
|
||||
There is a java.nio based implementation available out of the box, but it is also possible to implement your
|
||||
own locking scheme. The nio locker can be injected as follows
|
||||
<programlisting><![CDATA[ <file:inbound-channel-adapter id="filesIn"
|
||||
directory="file:${input.directory}" prevent-duplicates="true">
|
||||
<file:nio-locker/>
|
||||
</file:inbound-channel-adapter>]]>
|
||||
</programlisting>
|
||||
A custom locker you can configure like this:
|
||||
<programlisting><![CDATA[ <file:inbound-channel-adapter id="filesIn"
|
||||
directory="file:${input.directory}" prevent-duplicates="true">
|
||||
<file:locker ref="customLocker"/>
|
||||
</file:inbound-channel-adapter>]]>
|
||||
</programlisting>
|
||||
</para>
|
||||
<para>
|
||||
When filtering and locking files is not enough it might be needed to control the way files are listed entirely. To
|
||||
implement this type of requirement you can use an implementation of <interfacename>DirectoryScanner</interfacename>.
|
||||
This scanner allows you to determine entirely what files are listed each poll. This is also the interface
|
||||
that Spring Integration uses internally to wire FileListFilters FileLocker to the FileReadingMessageSource.
|
||||
A custom DirectoryScanner can be injected into the <file:inbound-channel-adapter/> on the <code>scanner</code>
|
||||
attribute.
|
||||
<programlisting><![CDATA[ <file:inbound-channel-adapter id="filesIn"
|
||||
directory="file:${input.directory}" prevent-duplicates="true" scanner="customDirectoryScanner"/>]]>
|
||||
</programlisting>
|
||||
This gives you full freedom to choose the ordering, listing and locking strategies.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section id="file-writing">
|
||||
|
||||
Reference in New Issue
Block a user