Using Siddhi patterns for events that haven't happened

送分小仙女□ 提交于 2019-12-08 05:50:55

问题


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

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.

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;

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?


回答1:


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

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. add a filter that filters events with price > 10
  2. send them to a time window (of 1 hour)
  3. in the time window, use functions to calculate max() value (with a group by) and emit the max value with the output events
  4. In a filter, check for max < 10000

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

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



来源:https://stackoverflow.com/questions/25555714/using-siddhi-patterns-for-events-that-havent-happened

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!