Usage Note 60693: Reading a growing input JSON file in SAS® Event Stream Processing using the 'growinginputfile' option
SAS Event Stream Processing file and socket publisher connectors and dfesp_fs_adapters can be configured to read growing input files in the JSON format. The SAS Event Stream Processing JSON publisher requires that the input JSON text conforms to the following format:
[[event_block_n],[event_block_n+1],[event_block_n+2],....]
The outermost brackets define an array of event blocks. Each nested pair of brackets defines an array of events that corresponds to an event block.
To read in a growing JSON input file, you can specify the growinginputfile parameter to read data from the file or named pipe as the data is being written to the input file. There are three ways to enable the growinginputfile option:
- If you are using SAS Event Stream Processing Studio, you can enable the growinginputfile option in the publisher connector settings.
- To specify the growinginputfile option for the dfesp_fs_adapter, use the '-i' option as shown below, which tells the adapter to read from a growing input file:
dfesp_fs_adapter -k sub - h <url> -f <fsname> -t <binary | csv | xml | json | hdat> -i
- For the file and socket publisher connector, you must add the following property to the connector properties in the XML to enable the growinginputfile option:
<property name="growinginputfile"><![CDATA[true]]></property>
Important Note: When using growing JSON files, if you completely enclose the JSON file in double brackets, the file connector reads the second set of double brackets as the end of file marking, finishes the processing, and shuts down. If the connector sees ']]' or any consecutive double brackets anywhere in the file, the ESP file connector creates no additional events. See the examples below.
Example 1. This input does not work because the connector reads the last bracket as an indication that the JSON file is complete and no more events are going to come in.
[[
{
"id":123,
"string1":"FirstString",
"field1":77
}
]]
Example 2. This input allows the connector to wait for additional events to come in because there is no closing bracket at the end.
[[ {
"id":456,
"string1":"SecondString",
"field1":88
}
]
To add an additional event, format the JSON as follows:
,[ {
"id":789,
"string1":"SomeOtherString",
"field1":99
}
]
Note that separate events must be comma delimited.
Operating System and Release Information
| SAS System | SAS Event Stream Processing Engine | Microsoft® Windows® for x64 | | |
| 64-bit Enabled AIX | | |
| 64-bit Enabled Solaris | | |
| HP-UX IPF | | |
| Linux for x64 | | |
| Solaris for x64 | | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
This note explains how to use the 'growinginputfile' option in the SAS® Event Stream Processing file connector to read in a growing JSON file.
| Date Modified: | 2017-07-12 15:36:04 |
| Date Created: | 2017-06-27 10:15:42 |