Before You Begin
This 20-minute tutorial shows you how to create business rules in your Stream Analytics pipeline. These business rules enable your pipeline to capture real-time information about various traffic rule violations.
This is the third tutorial in Monitoring Public Transportation Using Oracle Stream Analytics. Read the tutorials sequentially.
- Creating Artifacts for Your Stream Analytics Pipeline
- Building a Stream Analytics Pipeline
- Creating Business Rules in Your Stream Analytics Pipeline
- Configuring Graphical Views in Your Stream Analytics Pipeline
- Defining and Configuring a Target in Your Stream Analytics Pipeline
- Publishing Your Stream Analytics Pipeline
Background
Stream Analytics is a graphical tool with an intuitive web-based interface that enables you to explore, analyze, and manipulate streaming data sources in real time.
This traffic management solution uses GPS fleet data. This data is low cost, accurate, and it's created in real time. Its value for government sector customers is that this fleet data reduces congestion on roadways and enhances the traveling experience. The general features represented in this solution are real-time traffic analytics, speed violation tracking, and congestion detection. These features are combined with GPS streaming sensor feeds and historical trend data using map-based visualizations. This solution uses enterprise-grade Spark Streaming, Kafka open-source messaging, a highly scalable, extensible platform built with Stream Analytics.
Some of the key benefits with this solution are low-cost rollout with zero-road, network disruption, real-time operational intelligence, which is essential for meaningful congestion reduction, and an enhanced traveler experience, with a leading streaming big data technology.
What Do You Need?
Perform the tasks described in Creating Artifacts for Your Stream Analytics Pipeline.
Create
a Rule Stage
- In the Add a Stage menu, select Rule.
- In the Create Query dialog box, enter the
following values and click Save:
- Name:
SpeedViolation
- Description:
Determine violation speeds for the vehicles
The SpeedViolation Business Rules page is displayed. The
values you provide on this page are used for visual
analytics.
- Name:
Add a
Business Rule for Highways to Have a Name Value
- On the right side of the page, click Add a Rule and enter the following values:
- Rule Name:
DFLT_HWY
- Description:
Ensure all highways have a name value
- Click Done.
- For the IF clause, press Add a Condition and select BUS_Hwy from the drop-down list, and then select equals (case sensitive), but leave the last field blank.
- For the THEN clause, select BUS_Hwy
from the SET drop-down list, and then enter
UNKNOWN
in the TO field.Description of the illustration t2_1.png
Add a
Business Rule to Identify Bus Drivers Driving Recklessly
- On the right side of the page, click Add a Rule.
- Rule Name:
RECKLESS
- Description field, enter
Bus drivers traveling at excessive speed
- Click Done.
- For the IF clause, select AvgSpeed
from the drop-down list, then greater than,
and then enter
60
in the blank field. - For the THEN clause, select Violation
from the SET drop-down list, and then enter
RECKLESS
in the TO field.Description of the illustration t2_2.png
Add a
Business Rule to Identify Drivers Driving with Major Violations
- On the right side of the page, click Add a Rule.
- Rule Name:
Major
- Description:
Bus drivers traveling at high speeds
- Click Done.
- For the IF clause, select AvgSpeed
from the drop-down list, then select greater than,
and then, enter
45
in the blank field. - Click the Add a Condition link and select
AvgSpeed, then select lower than or
Equals, and then, enter
60
in the blank field. - For the THEN clause, select Violation
from the SET drop-down list, and then enter
MAJOR
in the TO field.Description of the illustration t2_3.png
Add a
Business Rule to Identify Drivers Driving with Minor Violations
- On the right side of the page, click Add a Rule.
- Rule Name:
Minor
- Description:
Bus drivers traveling at low speeds
- Click Done.
- For the IF clause, select AvgSpeed
from the drop-down list, then select greater than,
and then, enter
35
in the blank field. - Click the Add a Condition link and select
AvgSpeed, then select lower than or
Equals, and then enter
45
in the blank field. - For the THEN clause, select Violation
from the SET drop-down list, and then enter
MINOR
in the TO field.Description of the illustration t2_4.png
In the Live Output Stream table, you can see
the completed business rules for driving violations in the Violation
column.

Next
Tutorial
Configuring Graphical Views in Your Stream Analytics Pipeline