Before You Begin
This 15-minute tutorial shows you how to create supporting artifacts for a Stream Analytics pipeline. This pipeline lets you track financial losses that are attributed to specific products from various suppliers. This tutorial takes approximately 15 minutes to complete.
In this series, you learn how to use Stream Analytics application for tracking financial losses from various product suppliers. This is the first tutorial in the Tracking Financial Losses from Various Suppliers by Using a Stream Analytics Application series. Read them sequentially.
- Creating Supporting Artifacts for a Pipeline
- Creating a Pipeline
- Publishing and Deploying a Pipeline
Access to Stream Analytics
To complete the tutorials of this course, you need access to Oracle Integration Cloud, which has the Stream Analytics included in it.
Background
Stream Analytics is a feature of Oracle Integration Cloud. It is an intuitive, web-based interface, powered by Spark Streaming and Apache Kafka Messaging runtime, and the interface enables you to explore, analyze, and manipulate streaming data sources in real time.
What Do You Need?
- Access to an instance of Stream Analytics
- Chrome browser
- Data and events pushed to Kafka
- Installed Java Runtime Environment and JDK (8 or later)
- Any SQL Client or IDE that supports a connection to Oracle Database such as SQL Plus
- Host and credential details to access the database
- The resourcesfortutorials ZIP file from the Product page.
- Keep the utility running throughout your work on this
tutorial.
Push Sample Data
- Extract the
resourcesfortutorials.zip
file to a folder on your machine. The folder contains the following files:BusEvents.json
SalesTransactions.json
OsacsEventFeeder.jar
suppliers.sql
- To create and populate the
SUPPLIERS
table in your database, in SQL*Plus, run thesuppliers.sql
script. The sample data in this table is required to enrich the stream in this tutorial. - Open a command prompt on your machine.
- Navigate to the location where you extracted the
resourcesfortutorials.zip
file. - To push events, run the following command:
java -jar OsacsEventFeeder.jar -r <RESTURL> -j SalesTransactions.json -u <username> -p <password>
Note:
RESTURL
is the the REST Proxy endpoint URL
for the Kafka topic that you provisioned in your Event Hub
Service. See Provisioning Oracle Integration Cloud for
reference. For example, the RESTURL may look like: https://<IPAddress>:1080/restproxy/topics/salestransactions
.
The topic name used in this tutorial is
salestransactions
. The following response confirms that
data is being seeded to the salestransactions
topic:
RESPONSE:{"offsets" : [{"partition" :0, "offset" :28,
"error_code" :null, "error" :null}], "key_schema_id" :null,
"value_schema_id" :null}
Create a Database Connection
- Sign in to the Stream Analytics instance.
- In the left navigation tree, click Catalog.
- In the Create New Item menu, select Connection.
- In the Create Connection
dialog box, on the Type
Properties tab, enter the following and click Next.
- In the Name
field, enter
SuppliersDatabaseConnection.
- In the Tags
field, enter
tutorial
,retail.
- From the Connection Type drop-down list, select Database.
- In the Name
field, enter
- In the Connection Details section, enter the following details:
- Database service name: The service name for the database service name. (For example, XE)
- Host name: The host where the database resides and is running
- Port: The port where the database is running
- Username
- Password
- Click Test Connection.
- Click Save.
Create a Kafka Connection
- In the left navigation tree, click Catalog.
- From the Create New Item
menu, select Connection.
- In the Create Connection dialog box, do the following and click Next.
- In the Name
field, enter
SupplierAnalysis.
- In the Tags
field, enter
tutorial
,retail
. - From the Connection Type dripSelect Kafka.
- Enter the Zookeepers URL you have saved earlier at the time of provisioning.
- Click Test Connection.
- Click Save.
Create a Reference
- Click Catalog.
- From the Create New Item
menu, select Reference.
- In the Create Reference dialog box, do the following and click Next:
- In the Name
field, enter
ListOfSuppliers.
- In the Tags
field, enter
tutorial
,retail.
- In the Reference Type drop-down list, select the Database Table.
- On the Source Details tab, in the Connection drop-down list, select the SuppliersDatabaseConnection and click Next.
- On the Shape tab,
do the following and click Save.
- In the Shape Name drop-down list, select SUPPLIERS.
- Change the UNITCOST type to Number.
Create a Stream
- Click Catalog.
- From the Create New Item menu, select Stream.
- In the Create Stream dialog box, on the Type Properties tab, do the following and click Next.
- In the Name
field, enter
SalesTransactions.
- In the Tags
field, enter
tutorial
,retail.
- From the Stream Type drop-down list, select Kafka.
- On the Source Details tab, do the following and click Next:
- In the Connection field, select SupplierAnalysis.
- From the Topic name drop-down list, select salestransactions.
- On the Shape tab, click Infer Shape. The fields are auto populated.
- Click Save.
Create a Target
- Click Catalog.
- In the Create New Item
menu, select Target.
- In the Create Target dialog, do the following and click Next.
- In the Name
field, enter
SupplierAnalysis.
- the Tags field,
enter
tutorial
,retail
. - From the Target Type drop-down list, select Kafka.
- On the Target Details page, do the following information and click Next:
- In the Connection drop-down list, select SupplierAnalysis.
- In the Topic name
field, enter
supplieranalysis
. - On the Shape page,
click the Manual Shape
option, enter the following, and click Save:
Field Path Field Type TxnTime Text ProductLine Text TxnLoss Number TxnCost Number TxnRevenue Number ProductType Text Product Text QuantitySold Number CountrySold Text Channel Text Supplier Text