...
You can have one or more templates , and one or more streams in a domain. Each template has an execution plan and with a set of parameters for that execution plan which you can configure. Define the required event streams within the <streams>
element of the execution plan.
Code Block | ||
---|---|---|
| ||
<templateDomain name="TemperatureAnalysis"> <description>Temperature Analysis Description</description> <templates> <template name="Template1"> <description>To check average room temperature within specified time window of all rooms</description> <executionPlan> <![CDATA[ /* Enter a unique ExecutionPlan */ @Plan:name('testPlan') /* Enter a unique description for ExecutionPlan */ -- @Plan:description('ExecutionPlan') /* define streams and write query here ... */ @Import('inStream:1.0.0') define stream inStream (temperature double, roomNumber int); @Export('outStream:1.0.0') define stream outStream (temperature double, roomNumber int); from inStream#window.time($timeInterval) select avg(temperature) as temperature,roomNumber group by roomNumber having temperature>= $maxVal insert into outStream; ]]> </executionPlan> <parameters> <parameter name="maxVal" type="int"> <displayName>Maximum Temperature</displayName> <description>Maximum Temperature which needs to be checked</description> <defaultValue>75</defaultValue> </parameter> <parameter name="timeInterval" type="time"> <displayName>Time Interval</displayName> <description>Time can be defined such 5 sec, 1 min and etc</description> <defaultValue>1 min</defaultValue> </parameter> </parameters> </template> </templates> <streams> <stream> { "streamId": "inStream:1.0.0", "name": "inStream", "version": "1.0.0", "nickName": "", "description": "", "metaData": [ { "name": "temperature", "type": "DOUBLE" }, { "name": "roomNumber", "type": "INT" } ], "correlationData": [], "payloadData": [] } </stream> <stream> { "streamId": "outStream:1.0.0", "name": "outStream", "version": "1.0.0", "nickName": "", "description": "", "metaData": [ { "name": "temperature", "type": "DOUBLE" }, { "name": "roomNumber", "type": "INT" } ], "correlationData": [], "payloadData": [] } </stream> </streams> </templateDomain> |
Configuring the execution plan
The execution plan and the required streams are deployed is deployed in a template in WSO2 CEP, once you save a configuration for the first time. You can modify the name specified in the execution plan, and re-deploy it by adding a configuration name. For more information on execution plans, see Working with Execution Plans.
Name the configurable parameters of the Siddhi query in the execution plan by using the “$” character. For example, in the sample query below, $timeIntervel
and $maxVal
are the configurable parameters which should be defined within the <parameters>
element of the template.
...
A template can have one or more parameters. You can set a display name and a description to show in the user interface. Also, you can set a default value if required. If the input values values need to be limited to a defined set of values, define the options as comma-separated values. These values are shown in a drop down list in the user interface. An example configuration of a set of parameters is shown below.
Code Block | ||
---|---|---|
| ||
<parameters> <parameter name="maxVal" type="int"> <displayName>Maximum Temperature</displayName> <description>Maximum Temperature which needs to be checked</description> <defaultValue>75</defaultValue> <options>75, 80, 85</options> </parameter> <parameter name="timeInterval" type="time"> <displayName>Time Interval</displayName> <description>Time can be defined such 5 sec, 1 min and etc</description> <defaultValue>1 min</defaultValue> </parameter> </parameters> |
Configuring the event streams
You can have one or more event streams in a domain template. Define the required event streams within the <streams>
element of the domain template. The input and output event streams that are defined in the template are deployed in WSO2 CEP, once you save a configuration for the first time. For information on defining event streams, see Event Streams. An example configuration of event streams is shown below.
Code Block | ||
---|---|---|
| ||
<streams>
<stream>
{
"streamId": "inStream:1.0.0",
"name": "inStream",
"version": "1.0.0",
"nickName": "",
"description": "",
"metaData": [
{
"name": "temperature",
"type": "DOUBLE"
},
{
"name": "roomNumber",
"type": "INT"
}
],
"correlationData": [],
"payloadData": []
}
</stream>
<stream>
{
"streamId": "outStream:1.0.0",
"name": "outStream",
"version": "1.0.0",
"nickName": "",
"description": "",
"metaData": [
{
"name": "temperature",
"type": "DOUBLE"
},
{
"name": "roomNumber",
"type": "INT"
}
],
"correlationData": [],
"payloadData": []
}
</stream>
</streams> |
Execution manager dashboard
...