如何正确配置 Cepheus CEP 每小时重新计算一个属性?
How to correctly configure cepheus cep to recalculate a attribute every hour?
让我再解释一下。
我有这个 cep 配置:
{
"host":"http://localhost:1028", //Cepheus CEP
"in":[
{
"id":"A.*",
"type":"Pevent",
"isPattern":true,
"providers":[
"http://localhost:1027" //Cepheus Broker
],
"attributes":[
{ "name":"idEvent", "type":"string" },
{ "name":"endDate", "type":"date" }
]
}
],
"out":[
{
"id":"A",
"type":"Event",
"brokers":[
{
"url":"http://localhost:1026" //orion
}
],
"attributes":[
{ "name":"expired", "type":"int" }
]
}
],
"statements":[
"INSERT INTO Event SELECT idEvent as id, case when endDate<current_timestamp() then 1 else 0 end as expired FROM Pevent OUTPUT all"
]
}
当在 Cepheus 上下文代理中添加或修改新实体时,此配置会通知 Cepheus CEP,然后 CEP 计算实体是否过期并将结果发送到 orion.This 工作正常,没有问题。
现在的问题是我需要每小时重新计算一次过期属性(一年 365 天,每天 24 小时连续),我不知道在 cep 中是否可行,因为我做不到工作但没有找到任何信息。
非常感谢。
您需要第二条规则来检测过期事件。
您可以使用 Esper Patterns 来检测某个事件在一段时间内没有发生:
SELECT e.id as id, 1 as expired FROM pattern[every e=Pevent -> (timer:interval(1 hour) and not Pevent(id = e.id)]
让我再解释一下。 我有这个 cep 配置:
{
"host":"http://localhost:1028", //Cepheus CEP
"in":[
{
"id":"A.*",
"type":"Pevent",
"isPattern":true,
"providers":[
"http://localhost:1027" //Cepheus Broker
],
"attributes":[
{ "name":"idEvent", "type":"string" },
{ "name":"endDate", "type":"date" }
]
}
],
"out":[
{
"id":"A",
"type":"Event",
"brokers":[
{
"url":"http://localhost:1026" //orion
}
],
"attributes":[
{ "name":"expired", "type":"int" }
]
}
],
"statements":[
"INSERT INTO Event SELECT idEvent as id, case when endDate<current_timestamp() then 1 else 0 end as expired FROM Pevent OUTPUT all"
]
}
当在 Cepheus 上下文代理中添加或修改新实体时,此配置会通知 Cepheus CEP,然后 CEP 计算实体是否过期并将结果发送到 orion.This 工作正常,没有问题。
现在的问题是我需要每小时重新计算一次过期属性(一年 365 天,每天 24 小时连续),我不知道在 cep 中是否可行,因为我做不到工作但没有找到任何信息。
非常感谢。
您需要第二条规则来检测过期事件。
您可以使用 Esper Patterns 来检测某个事件在一段时间内没有发生:
SELECT e.id as id, 1 as expired FROM pattern[every e=Pevent -> (timer:interval(1 hour) and not Pevent(id = e.id)]