简体   繁体   English

使用Siddhi加入更新/删除WSO2 CEP事件表

[英]Join with update/delete WSO2 CEP Event Table Using Siddhi

I have a userStream having name,address,status 我有一个具有name,address,status的userStream

I want to store this details in UserDetailsTable (In memory table) 我想将此详细信息存储在UserDetailsTable (在内存表中)

Result of UserDetailsTable is below UserDetailsTable的结果如下

"Jose",  "address1","false" 
"Rockey","address2","false" 
"sibin", "address3","false"

I have another triggerStream having name,triggerStatus 我还有另一个triggerStream ,名称为triggerStatus

"Rockey","delete"
"Jose"  ,"update"

Case 1) When triggerStream comes as "Rockey", I want to join this triggerStream with UserDetailsTable according to (name and triggerStatus) and delete the row from UserDetailsTable. 情况1)triggerStream作为“ Rockey”出现时,我想根据(名称和triggerStatus)将此triggerStream与UserDetailsTable联接,并从UserDetailsTable中删除该行。

Case 2) When triggerStream comes as "Jose", I want to join this triggerStream with UserDetailsTable according to (name and triggerStatus) and update the status as "true" in UserDetailsTable. 情况2)triggerStream作为“ Jose”出现时,我想根据(名称和triggerStatus)将此triggerStreamUserDetailsTable联接,并在UserDetailsTable中将状态更新为“ true”。

Final state of UserDetailsTable is below. UserDetailsTable的最终状态如下。

"Jose",  "address1","true"
"sibin", "address3","false"

how can able to do this with WSO2 CEP? 如何使用WSO2 CEP做到这一点?

Assuming you've defined the streams and tables and an insert query to populate the in-memory table. 假设您已经定义了流和表以及一个插入查询以填充内存表。

For case 1, you can use a delete query as follows with a condition: 对于情况1,可以使用带有条件的删除查询,如下所示:

from triggerStream 
delete userDetailsTable
on name == userDetailsTable.name and triggerStatus == userDetailsTable.status;

If you want to delete specific names such as 'rockey' you can add a filter to the above query as follows: 如果要删除诸如“ rockey”之类的特定名称,则可以向上述查询添加过滤器,如下所示:

from triggerStream[name == 'rockey'] 
delete userDetailsTable
on name == userDetailsTable.name and triggerStatus == userDetailsTable.status;

For case 2, you can use an update query with a filter for 'jose' as follows: 对于情况2,可以使用带有“ jose”过滤器的更新查询,如下所示:

from triggerStream[name == 'jose']
select name, triggerStatus as status 
update userDetailsTable on name == userDetailsTable.name 

in this query, we rename the attribute 'triggerStatus' as 'status' to make it equal to table's attribute name. 在此查询中,我们将属性“ triggerStatus”重命名为“ status”,以使其等于表的属性名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM