Contents
The XML File Writer is an embedded adapter suitable for streaming tuples to a text file formatted with XML tags.
The XML file created by this adapter does not contain a root node. Each tuple streamed by the adapter should be treated as an individual document. Each field value can be optionally run through an XML escaping routine. For additional performance this can be disabled. If it is known their are no free strings then this is an unnecessary step.
The adapter will roll logfiles when they reach the (optional) max file size
parameter. File Name will be appended with
the current dated, formatted as
yyyyMMddhhmmss
If a log file already was created with this suffix then subsequent log files will be
further appended with a suffixed named -0, -1, -2, and so on.
The adapter will flush writes to disk after every tuple unless Flush Interval is specified. If Flush
Interval is specified then a flush() is done
asynchronously. Each flush and write to the log file is synchronized to prevent
partial tuples from being written to disk.
The XML File Writer adapter is configured with the properties shown in the following
table. Properties are set in the Properties view, Adapter Settings tab. In certain
cases, properties can also be set in the StreamBase Server configuration
file, sbd.sbconf.
| Property | Description | Default |
|---|---|---|
| File Name (string) | The local file path. | None |
| TruncateFile (bool) | If true, truncate log on startup. | false, append |
| Max File Size (optional int) | The maximum XML file size in bytes before roll; 0 = no roll. | 0, unlimited |
| Buffer Size (optional int) | The buffer size, which must be greater than 0; 0 = no buffer. | 0, unlimited |
| Flush Interval (optional int) | The frequency with which to force flush, in milliseconds; 0 = always flush. | 0, write immediately |
| CharsetName (optional string) |
The character set for the XML file you are writing.
NoteIf you specify a non-ASCII character set such as UTF-8, you may have to increase the maximum sizes of strings throughout your application. Remember that character mappings are not necessarily one byte to one byte in non-ASCII character sets. |
System property streambase.tuple-charset |
| Escape (optional bool) | If true, XML encode tuple data. | false |
<tuple>
<FieldName>FieldValue</FieldName>
<FieldName>FieldValue</FieldName>
<FieldName>FieldValue</FieldName>
...
</tuple>
Typechecking fails if the following optional parameters are specified and do not meet the following conditions:
Max File Size must be greater than or equal
to 0.
Flush Interval must be greater than or equal
to 0.
Buffer Size must be greater than or equal to
0.
If specified and those conditions are not met, typechecking fails.
On suspend, all tuples are written to disk and the current open log file is closed.
On resumption, caching is restarted. The first log message occurs at resume time + Flush
Interval.
