CEP ルール言語

CEP ルールの言語とパラメーターについて説明します。

CEP の規則の例
 
"name":"This followed by that",                      // required; unique in tenant
"createdAt": "2020-01-08T21:09:10Z",                 // generated; readonly
"updatedAt": "2020-01-08T21:09:10Z",                 // generated; readonly
"ruleId": "2a3ad91---xxx-xxx-xxxxxx-----xxxx-xxx,    // generated; readonly
"version": 1.0,                                      // generated; readonly
"status": {                                          // generated; readonly
        "code": "live",
        "details": "Version 1.0 of this rule is live and processing."
},
"instructions: {                                     // required
 "dimension": [	                                     // optional
            {
                "fieldPath": "eventDetails.businesssObject.supplierId
                "type": "String"
            }
 ]
 "pattern" : {
   "ifEvent": {                                      // required
	       "condition": {                        // required
	       		//Boolean expression	              
	       }
	       "repeated": {                         // optional
  	           "minOccurences": 3		     // optional
	           "maxOccurences": 5		     // optional
		   "consecutive": true               // optional; default=false
	           "withoutEvent": {                 // optional
		       // Boolean expression
	           }
 	           "allowCombinations": true .       // optional; default=false
	       }
}
"andThenEvents: [                                 // optional
{
"optional": true	                     // optional; default=false
"condition": { 	                     // required
// Boolean expresssion
}
"shouldOccur": false                  // optional; default=true
"consecutive": true                   // optional; default=false
"withoutEvent": {                     // optional
// Boolean expression
}
"allowCombinations": true             // optional; default=false
}
]
"within": {		                             // optional
"timeWindow": 60			     // required
"fieldPath":"timestampEventOccurred"  // optional
}
}
"thenOutput": {				     // required
"resultAlias":""
//allow mapping?
"resultContext": [                   // optional
{
"fieldPath": "eventDetails.businessObject.id
}
{
"fieldPath": "eventDetails.businessObject.orderValue
}
]
}
}

各項目の意味は次のとおりです。

dimension
オプションで、特定のフィールドによるイベントの区分化。 (注文 ID など)。
 "dimension": [						      
            {
                "fieldPath": "eventDetails.businesssObject.suppliedId
                "type": "String"
            }
 ]
pattern
パターンを検出するためのイベントのシーケンス。
"pattern" : {
ifEvent
必須の初期イベント。
"ifEvent": {
condition
初期イベントの必須条件。
"condition": {// Boolean expression}
repeated
イベントを繰り返す必要がある回数に関するオプションの条件。 andThenEvents が指定されている場合は許可されません。
"repeated": {
minOccurrences
イベントが発生する最小回数を指定するオプションの整数。
注:最大値がない場合は、timesNOrMore(n)を使用する。 n=0の場合はoneOrMore() を使用する。min==0の場合は optional() を使用します。
"minOccurences": 3
maxOccurrences
イベントが発生する最大回数を指定する整数 (オプション)。
注: min == max の場合は、times (n, m) を使用してください。
"maxOccurences": 3
consecutive
イベントが直前のイベントの直後に続く必要があるかどうか、またはその間に別のイベントが発生する可能性があるかどうかを指定するブール値 (オプション)。 デフォルト値は false です。
注: min が指定されているが max が指定されていない場合、状態のクリアには within window または unlessEvent のいずれかの条件が必要です。
"consecutive": true
withoutEvent
min/maxOccurencesが指定されているときに有効な、事前にマッチしたパターン'stateOnlyを無効にするオプションのブール式。
"withoutEvent": {//Boolean expression}
allowCombinations
オプションのブール値。 デフォルト値は false です。 連続が trueの場合は無効です。
"allowCombinations": true
} // end `repeated`
   } // end `ifEvent`
andThenEvents
初期イベントの後に続く必要があるイベントのオプション・リスト。 repeatedifEventで提供されている場合は許可されません。
"andThenEvents: [{
optional
このイベントがイベントのシーケンスで必須かどうかを示すブール値 (オプション)。 デフォルト値は false です。
"optional": true
condition
イベントを記述する必須のブール式。
shouldOccur
イベントを発生させるかどうかを示すオプションのブール値。 デフォルト値は trueです。 false を使用して、イベントが発生しないように要求します。
"shouldOccur": false
consecutive
イベントが直前のイベントの直後に続く必要があるかどうか、またはその間に別のイベントが発生する可能性があるかどうかを指定するブール値 (オプション)。 デフォルト値は false です。
"consecutive": true/false
withoutEvent
以前に一致したパターンの状態を無効にするブール式 (オプション)。これは、このパターンの実行を停止することを意味します。
"withoutEvent": { //Boolean expression}
allowCombinations
オプションのブール値。 デフォルト値は false です。 consecutivetrueの場合は無効です。
"allowCombinations": true
} // end sample event in andThenEvents
   ] // end `andThenEvents` array
within
開始から終了までのパターン全体が発生する必要がある、オプションの時間枠。
"within": {
timeWindow
必要な時間 (秒単位)。
"timeWindow": long
fieldPath
使用する時刻を含むイベント内のフィールドへのオプション・パス。 デフォルト値は timestampEventRecieved です。
"fieldPath":"timestampEventOccurred"
} // end `within`
} // end `pattern`
thenOutput
必要な出力定義。 起動されたパターンの名前が含まれます。 出力に含めるオプションのコンテキスト・フィールド。
 "thenOutput": {					      
                "resultAlias":"<name of the pattern>"
		//allow mapping?
		"resultContext": [
		   {
                	   "fieldPath": "eventDetails.businessObject.id
                   }
		   {
                	   "fieldPath": "eventDetails.businessObject.orderValue
                   }
                ]
  } // end `thenOutput`