0
我在Esper中做了一個基於長度窗口的程序。但是當窗口已滿時,以前的事件應該成爲一箇舊事件。當我試圖在updateListener中打印那個舊事件時,我每次都變空。如何在esper中獲得舊事件?
EPServiceProvider sp = EPServiceProviderManager.getDefaultProvider();
String qry = "select count(*) from com.bizruntime.Student.win:length(2)";
EPStatement statement = sp.getEPAdministrator().createEPL(qry);
MyListener listener = new MyListener();
statement.addListener(listener);
Student student1 = new Student(44,"xyz");
Student student2= new Student(45,"pqr");
Student student3 = new Student(43,"stu");
Student student4 = new Student(41,"abc");
sp.getEPRuntime().sendEvent(student1);
sp.getEPRuntime().sendEvent(student2);
sp.getEPRuntime().sendEvent(student3);
sp.getEPRuntime().sendEvent(student4);
這是監聽器類:
public void update(EventBean[] newEvent, EventBean[] oldEvent) {
EventBean event = newEvent[0];
System.out.println(oldEvent);
System.out.println("Student Name :"+event.get("count(*)"));
}
感謝您的幫助。 – Santanu