You can publish events from WSO2 DAS using Spark SQL queries. This feature alerts any interested party whenever the content of an existing Spark table is changed. e.g., A scheduled Spark script can periodically check whether a Spark table meets specific conditions. If the conditions are satisfied, an event can be published downstream to notify the interested parties. The following are the functions carried out to publish events from WSO2 DAS using Apache Spark.
Creating the event stream to publish events from Spark
To publish events from Spark, an event stream with the required stream attributes (i.e., attributes for which values are published from Spark) should be defined as the first step. A sample event stream definition is as follows. For more information on event streams, see Understanding Event Streams and Event Tables.
Creating the event receiver
Once you define the event stream, you need to create an event receiver of the
WSO2Event type to receive events from Spark. For more information, see WSO2Event Event Receiver.
Use the following Spark SQL queries to create a virtual table in the Spark table space to hold the published events, and to publish the rows of it into the defined event stream as events. The
org.wso2.carbon.analytics.spark.core.util.EventStreamProvider class works as the bridge between the existing Spark table and DAS event stream storage to fetch data from the existing Spark table and publish events to the defined event stream.
The parameters of the above query are described below.
The name of the Spark table that is mapped with the created event stream.
The name of the stream that should send events.
|The version number of the stream that sends events.|
A string containing stream attributes as comma-separated pairs with the name of the attribute and its data type in the following format:
|The select query to filter the required fields that should be published to the event stream from the existing Spark table. ( e.g., |
Once these functions are carried out, you can attach an event publisher (such as
JMS) to the published events stream and get the events delivered to a preferred location. For detailed instructions to configure publishers, see Creating Alerts.