This example contains a Source window with a Lua connector that reads RSS feeds from scientific sites and publishes them into the project every five seconds.
NOTE: Use this example with SAS Event Stream Processing 2024.03 and later.
For more information about how to install and use example projects, see Using the Examples.
This example provides a simple demonstration of how you can use a Lua connector to feed data into a Source window. In a real-life scenario, a project might also contain additional windows to analyze the data.
Data is streamed from RSS feeds. No input files are required for this example.
The following table explains the Lua code in the connector for the Source window. To view the Lua code in context, see the model.xml file.
Step | Lua Code Section |
---|---|
Specifies the RSS feeds that the connector reads. |
|
Publishes events into the project. The "publish" function is required to use the Lua connector. When the "publish" function returns the value "true", the connector is finished. When the function returns the value "false", the connector keeps running. |
|
Maps the data from the RSS feeds into the project's output. For example, "event.source = feed" causes a feed's URL to appear in the "source" column in the output. "event.date = entry.item.pubDate" causes data within the "pubDate" XML element in the feed to appear in the "date" column in the output. "event._opcode = "upsert"" causes the opcode of each event to be set to Upsert. "request.tolua = true" causes the results to be processed as a Lua object instead of XML. |
|
Returns results as SAS Event Stream Processing events. |
|
The following figure shows the result of running the project in test mode in SAS Event Stream Processing Studio:
The actual events that appear in test mode depend on the events that are available in the RSS feeds at the time when you run the project.
You can add windows to the project to further analyze the data. For example, you might add a Filter window to extract stories that contain the word "climate".
For more information, see SAS Help Center: Using the Lua Connector.