对尚未发生的事件使用悉地模式 [英] Using Siddhi patterns for events that haven't happened

查看:32
本文介绍了对尚未发生的事件使用悉地模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 CEP 引擎中,我可以为尚未发生的事件寻找模式.

In the CEP engine can I look for a patterns for events that haven't occurred.

编辑欺诈模式检测查询:如果在一天内两次购买同一张卡,并且第一次购买低于 10 美元而第二次购买低于 10 美元,我可以触发该事件吗不是超过 10,000 美元.

Editing the fraud pattern detection query: Can I fire the event if two purchases of the same card are made within one day and if the first purchase is less than $10 and the second one isn't greater than $10,000.

从每个 (a1 = purchase[price > 10] ) NOT -> a2 = purchase [price >10000 and 1.cardNo==a2.cardNo] 在 1 天内插入潜在欺诈 a1.cardNo 为 cardNo,a2.price 为价格,a2.place 为 place;

from every (a1 = purchase[price > 10] ) NOT -> a2 = purchase [price >10000 and 1.cardNo==a2.cardNo] within 1 day insert into potentialFraud a1.cardNo as cardNo, a2.price as price, a2.place as place;

如果 event1 在过去一小时内没有跟随 event2 则触发,而不是在 event1 在过去一小时内跟随 event2 时触发?

Fire if event1 hasn't been followed by event2 within the last hour rather than fire if event1 has been followed by event2 within the last hour?

推荐答案

从 CEP 3.1.0 开始不支持不出现(但它将在下一个版本 4.0.0 中可用).

Non occurrences are not supported as of CEP 3.1.0 (but it will be available in the next version, 4.0.0).

但是您的用例可以以另一种方式实现.由于您要查找过去一小时内至少发生 1 个 > 10 且没有事件 > 10000(每个卡号)的事件,您可以执行以下操作:

But your use case can be implemented in an alternative way. Since you want to find the occurrence of at least 1 event > 10 and no events > 10000 (per card no.) in the last hour, you can do something like follows:

  1. 添加一个过滤器来过滤价格 > 10 的事件
  2. 将它们发送到一个时间窗口(1 小时)
  3. 在时间窗口中,使用函数计算 max() 值(使用 group by)并使用输出事件发出最大值
  4. 在过滤器中,检查 max <10000

这将查找一个或多个价格 > 10 但在过去一小时内少于 10000 的事件.

This will look for one or more events with price > 10, but less than 10000 in the last hour.

您会发现以下文档有助于实现此目的:https://docs.wso2.com/display/CEP310/Windows

You'll find the below documentation useful for implementing this: https://docs.wso2.com/display/CEP310/Windows

这篇关于对尚未发生的事件使用悉地模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆