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

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

问题描述

我可以在 CEP 引擎中查找未发生事件的模式.

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

编辑欺诈模式检测查询:如果在一天内购买了两次同一张卡,并且第一次购买的金额低于 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 = 1 天内购买 [price >10000 and 1.cardNo==a2.cardNo]插入潜在欺诈 a1.cardNo 作为cardNo,a2.price 作为价格,a2.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. 在过滤器中,检查最大值
  5. 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

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

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