我正在尝试使用Esper CEP引擎并试图实现以下目标。
我正在使用以下代码:
insert into CreateAlarm
select
e.measurement.time as time,
e.measurement.source.value as source,
"com_cumulocity_LuxometerAlert" as type,
"Lux value below optimum level" as text,
"ACTIVE" as status,
"MAJOR" as severity
from MeasurementCreated e
where getNumber(e, "c8y_Luxometer.lux.value") >= 0 and
getNumber(e, "c8y_Luxometer.lux.value") <= 4.0 and
e.measurement.source.value='<device id>';
insert into SendRequest
select
'post' as method,
'<rest endpoint>' as url,
aMap({"alarmID",e.alarm.id.value,"source",toJSON(findManagedObjectById(e.alarm.source.value))}) as headers,'application/json' as contentType,
toJSON(e) as body
from pattern [every e = AlarmUpdated(
alarm.status = CumulocityAlarmStatuses.ACTIVE,
alarm.severity=CumulocitySeverities.MAJOR,
alarm.type='com_cumulocity_LuxometerAlert')];
insert into UpdateAlarm
select
f.alarm.id as id,
"ACKNOWLEDGED" as status
from pattern [every f = AlarmUpdated(
alarm.status = CumulocityAlarmStatuses.ACTIVE,
alarm.severity=CumulocitySeverities.MAJOR,
alarm.type='com_cumulocity_LuxometerAlert')];
insert into CreateEvent
select
"c8y_DemoOrderCreate" as type,
"Order Create Request To Vlocity" as text,
g.alarm.time as time,
g.alarm.source as source
from pattern [every g = AlarmUpdated(
alarm.status=CumulocityAlarmStatuses.ACKNOWLEDGED,
alarm.severity=CumulocitySeverities.MAJOR,
alarm.type='com_cumulocity_LuxometerAlert')];
现在的问题是,当我的测量值落在所需值之内时,它正在创建警报和事件。但是我可以看到更少的API调用次数。理想情况下,警报和http呼叫的数量应该相同。但这不一样。
我的查询是,是CEP引擎将http请求发送给“ SendRequest”流,然后调用API。