Table of Contents | ||
---|---|---|
|
...
This sample demonstrates how you can send notifications through events published from WSO2 DAS using Apache Spark. The notifications are sent to alert about records of an existing table in the Spark environment satisfying a defined condition(s). This sample includes involves creating a table with a few product names and quantities in the DAL, and sending notifications when the quantity of a product falls below a defined value.
...
- Log in to the DAS management console using the following URL: https://<DAS_HOST>:<DAS_PORT>/carbon/
- Click Main, and then click Streams.
- Click Add Event Stream.
- Enter the values as shown below to create an event stream named PRODUCTS_STREAM with two attributes as product name and quantity. For more information on creating event streams, see Understanding Event Streams and Event Tables.
- Click Next (Persist Event).
- Enter the values as shown below in the next screen to persist the created event stream. For For more information on creating event streams, see Persisting Event Streams .
- Click Save Event Stream.
Sending events to the receiving event stream
...
- Log in to the DAS management console using the following URL, if you are not already logged in: https://<DAS_HOST>:<DAS_PORT>/carbon/
- Click Tools, and then click Event Simulator.
- Upload the events to be sent to it in a CSV file (e.g. footwear.csv), and click Configure as shown below.
- Enter the details as shown below, and click Configure.
- Click Play in the next screen as shown below.
- Click Main, and then click Message Console and select Data Explorer. Select the name of the table to view it as shown below.
Creating the corresponding table in Apache Spark
...
When this query executes, output of the select query is inserted into the PRODUCT_ALERTS table. It reads all the products from the PRODUCTS_STREAM Spark table which have its quantity less than 50. During the query execution, individual rows returned from the select query are published into the PRODUCT_ALERTS stream as events.
- You view the text events that are published to the CEP server in the logs of it in the CLI as shown below.