2017-03-27 4 views
0

Esper (CEP)의 win_ext 창에 대한 이해에 도움이 필요합니다. 나이 (처음 2) 이벤트가 여전히이 된 경우에도 업데이트-방법에 팝업 이유가 궁금하네요 "만료"esper_ext timed가 이전 항목을 필터링하지 않는 이유

public class MyCepTest { 

    public static void main(String...args) throws Exception{ 
     System.out.println("starting"); 
     MyCepTest ceptest = new MyCepTest(); 
     ceptest.execute(); 
     System.out.println("end"); 
    } 

    public void execute() throws Exception{ 
     Configuration config = new Configuration(); 
     config.addEventType(MyPojo.class);   
     EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(config); 
     EPAdministrator admin = epService.getEPAdministrator(); 

     EPStatement x1 = admin.createEPL(win); 
     EPStatement x2 = admin.createEPL(win2);   

     x1.setSubscriber(this); 
     x2.setSubscriber(this); 

     EPRuntime runtime = epService.getEPRuntime(); 

     ArrayList<MyPojo> staffToSendToCep = new ArrayList<MyPojo>(); 
     staffToSendToCep.add(new MyPojo(1, new Date(1490615719497L))); 
     staffToSendToCep.add(new MyPojo(2, new Date(1490615929497L))); 

     for(MyPojo pojo : staffToSendToCep){ 
      runtime.sendEvent(pojo);  
     } 
     Thread.sleep(500); 
     System.out.println("round 2...");//why two first Pojos are still found? Shouldn't ext_timed(pojoTime.time, 300 seconds) rule them out? 

     staffToSendToCep.add(new MyPojo(3, new Date(1490616949497L)));   

     for(MyPojo pojo : staffToSendToCep){ 
      runtime.sendEvent(pojo);  
     }   
    } 

    public void update(Map<String,Object> map){ 
     System.out.println(map); 
    } 

    public static String win = "create window fiveMinuteStuff.win:ext_timed(pojoTime.time, 300 seconds)(pojoId int, pojoTime java.util.Date)";  
    public static String win2 = "insert into fiveMinuteStuff select pojoId,pojoTime from MyPojo"; 
} 

class MyPojo{ 
    int pojoId; 
    Date pojoTime; 
    MyPojo(int pojoId, Date date){ 
     this.pojoId = pojoId; 
     this.pojoTime = date; 
    } 

    public int getPojoId(){ 
     return pojoId; 
    } 
    public Date getPojoTime(){ 
     return pojoTime; 
    } 

    public String toString(){ 
     return pojoId+"@"+pojoTime; 
    } 
} 

나는 잠시 동안이와 당황 봤는데 도움이 될 것이라고 크게

감사

답변

0

문서의 처리 모델을 참조하십시오. http://espertech.com/esper/release-6.0.1/esper-reference/html/processingmodel.html 들어오는 삽입 스트림 이벤트는 모두 수신기와 구독자에게 전달됩니다. 너의 창문에 관계없이. 하나의 쿼리 창에있는 경우, 고려할 이벤트의 하위 집합을 정의하므로 집계, 패턴 일치 또는 반복에 사용할 수있는 항목을 정의합니다. 참고로 "select * from MyPojo"를 시도하십시오. 외부 시간을 읽을 때의 조언은 http://espertech.com/esper/release-6.0.1/esper-reference/html/api.html#api-controlling-time 을 참조하십시오. 일반적으로 "외부 시간대"를 원하면 이벤트 시간이 엔진 시간을 늘리 길 원합니다.