【问题标题】:Esper rule language: return datafield of class from pattern埃斯珀规则语言:从模式返回类的数据字段
【发布时间】:2016-04-21 10:09:37
【问题描述】:

我有以下规则,当心率保持在 160 以上 5 分钟时触发。

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?

【问题讨论】:

    标签: java rules rule-engine complex-event-processing esper


    【解决方案1】:

    模式保留并返回标记的事件,即这样做:

    // 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(... 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-24
      • 1970-01-01
      相关资源
      最近更新 更多