我有以下规则,当心率在5分钟以上保持在160以上时会触发。
EPStatement cepStatementRule3 = cepRule.createEPL("context PartitionByMacHeartRate "
+ "select * from pattern[every(HeartRate(heartrate > 160) "
+ "-> (timer:interval(5 min) "
+ "and not HeartRate(heartrate<=160)))]");
cepStatementRule3.addListener(new rule3Listener());
我的HeartRate类具有以下字段:
int heartrate;
String heartratesTimestamp;
String macAddress;
我想要的是能够在我的ruleListener中获取macAddress。但是这个
返回一个空的哈希图。所以我的问题是如何返回HeartRate的macAddress?
最佳答案
模式会保留并返回加标签的事件,即这样做:
// we assign the 'h' tag to the first event and the engine now retains that
// the select clause could use "h.macAddress as macAddress", for example
...every(h=HeartRate(...
关于java - Esper规则语言:从模式返回类的数据字段,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36766404/