Skip to content
Luke Taylor edited this page Jun 10, 2013 · 2 revisions

This page describes how to setup and run a stream that tails a file. Spring Integration provides a File Tailing Inbound adapter.

Start the XD stream server

as instructed in the Getting Started page.

Create the streams

The tail source has 3 options:

  • name: the absolute path to the file to tail (default: /tmp/xd/input/<streamName>)

  • lines: the number of lines from the end of an existing file to tail (default: 0)

  • delay: on platforms that don’t wait for a missing file to appear, how often (ms) to look for the file (default: 5000)

Run the Demo

mkdir -p /tmp/xd/input
touch /tmp/xd/input/tailtest                               (1)
curl -d "tail | file" http://localhost:8080/streams/tailtest
echo blah >> /tmp/xd/input/tailtest
cat /tmp/xd/output/tailtest
  1. Note: this step is not necessary on some platforms; for example, on Linux, the tail command suspends when a missing file is tailed. However, on Mac OSX, the tail command exits in this situation. When this happens, the tail source keeps trying to open the file every 5 seconds. Since, by default, the tail source tails from the end of the file, some lines might be missed.

or

curl -d "tail --name=/tmp/foo --lines=5 | file --name=bar" http://localhost:8080/streams/tailtest
echo blah >> /tmp/foo
cat /tmp/xd/output/bar

Status Events

Some platforms, such as linux, send status messages to stderr. The tail module sends these events to a logging adapter, at WARN level; for example…​

[message=tail: cannot open `/tmp/xd/input/tailtest' for reading: No such file or directory, file=/tmp/xd/input/tailtest]
[message=tail: `/tmp/xd/input/tailtest' has become accessible, file=/tmp/xd/input/tailtest]

Clone this wiki locally