Oracle by Example brandingCreating Business Rules in Your Stream Analytics Pipeline

section 0Before 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.

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.


section 2Create a Rule Stage

  1. In the Add a Stage menu, select Rule.
  2. 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.

section 2Add a Business Rule for Highways to Have a Name Value

  1. 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
  2. Click Done.
  3. 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.
  4. For the THEN clause, select BUS_Hwy from the SET drop-down list, and then enter UNKNOWN in the TO field.
    The DFLT_HWY business rule
    Description of the illustration t2_1.png

section 4Add a Business Rule to Identify Bus Drivers Driving Recklessly

  1. On the right side of the page, click Add a Rule.
    • Rule Name: RECKLESS
    • Description field, enter Bus drivers traveling at excessive speed
  2. Click Done.
  3. For the IF clause, select AvgSpeed from the drop-down list, then greater than, and then enter 60 in the blank field.
  4. For the THEN clause, select Violation from the SET drop-down list, and then enter RECKLESS in the TO field.
    On the SpeedViolation stage, RECKLESS business rule
    Description of the illustration t2_2.png

section 4Add a Business Rule to Identify Drivers Driving with Major Violations

  1. On the right side of the page, click Add a Rule.
    • Rule Name: Major
    • Description: Bus drivers traveling at high speeds
  2. Click Done.
  3. For the IF clause, select AvgSpeed from the drop-down list, then select greater than, and then, enter 45 in the blank field.
  4. Click the Add a Condition link and select AvgSpeed, then select lower than or Equals, and then, enter 60 in the blank field.
  5. For the THEN clause, select Violation from the SET drop-down list, and then enter MAJOR in the TO field.
    The SpeeedViolation stage with the MAJOR business rule
    Description of the illustration t2_3.png

section 5Add a Business Rule to Identify Drivers Driving with Minor Violations

  1. On the right side of the page, click Add a Rule.
    • Rule Name: Minor
    • Description: Bus drivers traveling at low speeds
  2. Click Done.
  3. For the IF clause, select AvgSpeed from the drop-down list, then select greater than, and then, enter 35 in the blank field.
  4. Click the Add a Condition link and select AvgSpeed, then select lower than or Equals, and then enter 45 in the blank field.
  5. For the THEN clause, select Violation from the SET drop-down list, and then enter MINOR in the TO field.
    The MINOR business rule on the SpeedViolation page
    Description of the illustration t2_4.png
  6. In the Live Output Stream table, you can see the completed business rules for driving violations in the Violation column.
    The Live Output Stream table with data populated in realtime
    Description of the illustration t2_5.png

next stepNext Tutorial

Configuring Graphical Views in Your Stream Analytics Pipeline