How to read threshold data from a route

This cookbook applies for new Thresholds and Dispersion Multipliers types and will not work for ThresholdLevels - old and BaselineMultipliers - old.

Context

You have injected Thresholds or Dispersion Multipliers values from the Data Integration screen or using a WebService. You have followed the procedures in the How to inject thresholds and dispersion multipliers values cookbook. 

This topic provides an example on how to read threshold data from a route.

Important

The following route works assuming you have an observed attribute named ThresholdRisk (the one you configured in How to inject thresholds and dispersion multipliers values) and a query called readThreshold.

Configure the readThreshold query

Start with configuring the query that your route requires to read threshold data.

  1. On the main menu, click the cog icon > Data Integration
  2. On the left menu, click Queries
  3. In the Name field, enter readThreshold.
  4. Click the Add dimension button, and select the Process dimension. 
  5. Click the Add Value button and select Name and the relevant threshold value, for example, thresholdRisk.

Write the route

The following provides an example route to read threshold data.

To create a route, on the left menu click Routes.

Read threshold data route
 <?xml version="1.0" encoding="UTF-8"?>
<routes xmlns="http://camel.apache.org/schema/spring" xmlns:u="http://www.systar.com/aluminium/camel-util">
    <route>
        <from uri="timer://once?repeatCount=1"/>
        <setProperty propertyName="tnd-query.parameters">
            <u:map-create>
                <u:map-entry key="tnd-query.referenceTime">
                    <constant>2016-09-19T00:02:00</constant>
                </u:map-entry>
            </u:map-create>
        </setProperty>
        <to uri="tnd-query:readThreshold"/>
        <setHeader headerName="thresholdValue">
            <simple>${body.rows[0][thresholdRisk].value[rules][0][threshold]}</simple>
        </setHeader>
        <log message="The threshold value is ${header[thresholdValue]} for the first rule"/>
        <to uri="mock:thresholdValues"/>
    </route>
</routes>

Once you start your route, the logs for the route indicate the threshold value for any given rule. 

Related Links