wso2 - 如何使用计时器之类的东西进行流查询?
问题描述
我正在制作一个 siddhi 应用程序。如果在特定时间没有具有相同 ID 的事件到达,我需要一个查询以从流中获取事件。
这适用于带有 WSO2 流处理器的 SiddhiApp。
假设一个 json 在时间 0s 到达
{“id”:“1566”,“状态”:“科恰班巴”}
然后另一个在 1s 有不同的 ID
{“id”:“1575”,“Departamento”:“拉巴斯”}
另一个在 4s
{“id”:“1575”,“Departamento”:“拉巴斯”}
查询应该做的是只输出第一个 1
{“id”:“1566”,“状态”:“科恰班巴”}
因为它符合条件。5 秒内只发生一个事件。另一个 1575 在那个时候有两个事件。
解决方案
我找到了一种检测非发生事件的方法
https://wso2.github.io/siddhi/documentation/siddhi-4.0/#detecting-non-occurring-events
from every( s1 = SweetProductionStream) -> not SweetProductionStream[s1.id == id ] for 8 seconds
select s1.resource1 as resource
insert into resource1;
此代码表示,在到达事件时,如果具有相同 id 的事件在 8 秒内没有到达流,它将等待,然后它将插入到 resource1 流中
推荐阅读
- php - 如何修复“在 null 上调用成员函数 update()”错误?
- go - Go 惯用的类型转换函数命名
- html - HTML 敏捷包获取类
- reactjs - 如何在 react js 中创建单独的管理路由?
- django - 如果我将应用程序重新组织到应用程序文件夹,Django 无法识别应用程序的 __init__.py 中指定的包
- php - 用 DOM 获得的路径指向 php 中的播放器
- python - 我们如何将某个变量的先前值存储在python中的某个其他变量中?
- javascript - 从嵌套的 json 中获取所有键值
- r - 如何在 csv 文件中忽略带引号的换行符以创建 Hive 外部表?
- wordpress - 隐藏 Woocommerce wc-message: "item*" 已删除。撤消?