イベントの欠落の検出

イベントの有無を検出するために、when <event> has occurred 節を使用するルールを作成します。

あるイベントが特定の期間の間に発生したかどうかをテストするには、固定のカレンダー持続期間、参照イベントの処理を延期します。ルールには、同じ期間に発生したイベントをチェックする条件も含めます。

以下のルールでは、購入額が 1000 を超えている場合、最近の購入の 1 日後にアクションを実行する必要があります。このルールは、最近の購入後 1 日間、他の購入イベントがないことを検出します。

when a purchase event has occurred 1 day ago, called 'recent purchase'
where the amount of 'recent purchase' is more than 1000 
if
    the number of purchase events during the period of 1 day after 'recent purchase' is 0
then 
    print "No other purchase events after the recent purchase"

固定の絶対持続期間またはカレンダー持続期間中、または処理対象イベントに関連するエンティティーの属性によって定義された絶対持続期間またはカレンダー持続期間中に、イベントが存在しないことを検出できます。

以下の例では、ユーザーがこのユーザーの試用期間の期限が切れる前にサービスを購入したかどうかが、ルールによりチェックされます。

when a create account event has occurred,after a delay of the trial period of 'the user',
if
    the number of purchase events is 0
then
    print "The trial period of " + the name of 'the user' + "has expired. The user must purchase the service to continue using it."

また、now が別のイベントと同時であることをチェックすることにより、when 部分を含まないルールでイベントの欠落を検出することもできます。条件 (definitions 部分と if 部分) はイベントの参照のみを行う必要があります。さもないと、ルールのインスタンスがそれぞれ複数回実行される可能性があります。

以下の例では、フライト出発イベントがエージェントによって受信されると、ルールは、そのエージェントがフライト到着イベントを受信していないことをチェックします。

definitions
    set 'the flight departure' to a flight departure event;
if
    now is at the same time as the scheduled arrival time of 'the flight departure'
    and there is no flight arrival event
then
    print "Missing flight arrival event";