您应该为事件 A 、 B 和 C 提供 3 个单独的语句
并将单独的听众附加到他们身上。
例如,我有针对证券的股票事件 - SAPE、PNG 和 GOOG。我将编写 3 个单独的查询,例如
@Name('Select SAPE > 20')
select * from StockTick.win:time(10) having avg(price) > 20 and symbol = 'SAPE'
@Name('Select PNG > 25')
select * from StockTick.win:time(10) having avg(price) > 25 and symbol = 'PNG'
@Name('Select GOOG> 19')
select * from StockTick.win:time(10) having avg(price) > 19 and symbol = 'GOOG'
在代码中,我将得到如下语句
EPStatement PNGSignal = epService.getEPAdministrator().getStatement(
"Select PNG > 25");
EPStatement SAPESignal = epService.getEPAdministrator().getStatement(
"Select SAPE > 20");
EPStatement GOOGSignal = epService.getEPAdministrator().getStatement(
"Select GOOG > 19");
然后对于每个语句,我将为每个语句附加一个更新侦听器
PNGSignal.addListener( new updateListener {@Override
public void update(EventBean[] arg0, EventBean[] arg1) {
//Sysout - inside PNG Signal
}
});
GOOGSignal.addListener( new updateListener {@Override
public void update(EventBean[] arg0, EventBean[] arg1) {
//Sysout - inside GOOG Signal
}
});
有关更多信息,您可以参考我的 CEP/ESPER 视频
http://www.youtube.com/watch?feature=player_embedded&v=emwwpvfaddw