Closed macu39 closed 8 years ago
Esper CEP has several time and cron-like features in Patterns like timer:interval:
every timer:interval(10 min)
Thanks, I didn't see it on the doc. But when I'm using that parameter I get the following error:
Caused by: com.espertech.esper.client.EPStatementSyntaxException: Incorrect syntax near ':' at line 1 column 185, please check the output rate clause [INSERT INTO Event SELECT idEvent as id, dFlag as dFlag, cast(current_timestamp() ,string) as Title, wFlag as wFlag, mFlag as mFlag, idEvent as idEvent FROM Pevent OUTPUT ALL EVERY timer:interval(1 min)]
Due to the output rate but don't know how to solve it.
My sentence is:
INSERT INTO Event SELECT idEvent as id, dFlag as dFlag, cast(current_timestamp() ,string) as Title, wFlag as wFlag, mFlag as mFlag, idEvent as idEvent FROM Pevent OUTPUT ALL EVERY timer:interval(1 min)
I want it to run it every 1 min and, when the cep broker notifies changes to. What should I do?
You are mixing the syntax for output limiting and the syntax for Patterns.
Patterns cannot be applied to output expressions, they are used in the FROM
clause:
SELECT Pevent.id, Pevent.attr1, Pevent.attr2 FROM pattern[every timer:interval(10 min)]
Please use SO with the esper tag for questions related the Esper language, you might get better answers.
An additional note: generating events on a fixed interval to update NGSI entities seems like a bad idea.
CEP are made to react to events (and "smartly" limiting them as output), not generating new entities updates all the time...
Thanks for the answer but I still don't get how to solve my problem. Let me explain it a bit more. I have this cep config:
{
"host":"http://localhost:1028",
"in":[
{
"id":"A.*",
"type":"Pevent",
"isPattern":true,
"providers":[
"http://localhost:1027" //
],
"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"
]
}
This config when new entity is aded or modified in cepheus context broker, it notifies cepheus cep and cep calculates if the entity is expired or not and send the result to orion.This is working ok with no problem.
The problem now is that I need to recalculate the expired attribute one time per hour and i don't know if it is possible in cep cause I can't make it work.
I did ask it on stack overflow to http://stackoverflow.com/questions/37466515/how-to-correctly-configure-cepheus-cep-to-recalculate-a-attribute-every-hour
Is It posible to run a cep condition every 10 min, not only when
onchange
notification is sent from cepheus broker.