INT-4188: Add Idle Event Interval Support

JIRA: https://jira.springsource.org/browse/INT-4188

* add `<idle-event-interval>` XSD element
* add `FileTailingIdleEvent`
* move `TaskScheduler` and `getRequiredTaskScheduler` to `FileTailingMessageProducerSupport`
* add `setIdleEventInterval`

use taskExecutor instead of creating one
stop the scheduled task in case of `doStop()`
other required changes

update Test and Reference

implement changes required

What do you think about this checking if file exist before sending event.

Mock is used for `file.exist()` plus other minor updates

Polishing
* Some typos in the code as well as in the docs
* Fix `FileTailingMessageProducerTests.testIdleEvent()` to verify that `FileTailingIdleEvent` isn't emitted when file does not exist
This commit is contained in:
Ali Shahbour
2016-12-22 13:23:52 +02:00
committed by Artem Bilan
parent 1e46fb84f3
commit f7b1ec8885
12 changed files with 224 additions and 25 deletions

View File

@@ -411,6 +411,10 @@ Examples of such events are:
This sequence of events might occur, for example, when a file is rotated.
Starting with _version 5.0_, a `FileTailingIdleEvent` is emitted when there is no data in the file during `idleEventInterval`.
`[message=Idle timeout, file=/tmp/foo] [idle time=5438]`
NOTE: Not all platforms supporting a `tail` command provide these status messages.
Messages emitted from these endpoints have the following headers:
@@ -418,7 +422,7 @@ Messages emitted from these endpoints have the following headers:
- `FileHeaders.ORIGINAL_FILE` - the `File` object
- `FileHeaders.FILENAME` - the file name (`File.getName()`)
NOTE: In versions prior to _5.0_, the `FileHeaders.FILENAME` header contained a string representation of the file's absolute path.
NOTE: In versions prior to _version 5.0_, the `FileHeaders.FILENAME` header contained a string representation of the file's absolute path.
You can now obtain that by calling `getAbsolutePath()` on the original file header.
Example configurations:
@@ -458,6 +462,18 @@ If the tail command fails (on some platforms, a missing file causes the `tail` t
By default native adapter capture from standard output and send them as messages and from standard error to raise events.
Starting with _version 4.3.6_, you can discard the standard error events by setting the `enable-status-reader` to `false`.
[source,xml]
----
<int-file:tail-inbound-channel-adapter id="native"
channel="input"
idle-event-interval="5000"
task-executor="exec"
file="/tmp/foo"/>
----
`IdleEventInterval` is set to 5000 then, if no lines are written for 5 second, `FileTailingIdleEvent` will be triggered every 5 second.
This can be useful if we need to stop the adapter.
[source,xml]
----
<int-file:tail-inbound-channel-adapter id="apache"

View File

@@ -55,6 +55,9 @@ See <<feed>> for more information.
The new `FileHeaders.RELATIVE_PATH` Message header has been introduced to represent relative path in the `FileReadingMessageSource`.
See <<file-reading>> for more information.
The tail adapter now supports `idleEventInterval` to emit events when there is no data in the file during that period.
See <<file-tailing>> for more information.
==== (S)FTP Changes
The inbound channel adapters now have a property `max-fetch-size` which is used to limit the number of files fetched during a poll when there are no files currently in the local directory.