0

Is there a way to get the last inserted event in esper core prior to rule completion?

Configuration cepConfig = new Configuration();
     cepConfig.getEngineDefaults().getMetricsReporting().
     setEnableMetricsReporting(true);
cepConfig.addEventType("Stream", Stream.class.getName());
EPServiceProvider cep = EPServiceProviderManager.getProvider("myCEPEngine", cepConfig);
EPRuntime cepRT = cep.getEPRuntime();
EPAdministrator cepAdm = cep.getEPAdministrator();
EPStatement cepStatement = cepAdm.createEPL("select * from Stream.win:length(100)") ;
cepStatement.addListener(new CEPListener());

Now for event insertion i am using this sample code

for (int i = 0; i < 500; i++) {
     GenerateRandomStream(cepRT);
     //Here I want get the last inserted event
}

Any help will be appreciated.

abhi
  • 4,762
  • 4
  • 29
  • 49

2 Answers2

0

There is a "prev" function that you could use. What specifically do you mean with "prior to rule completion"?

user650839
  • 2,594
  • 1
  • 13
  • 9
  • by saying prior to rule completion, i mean prior to *listener*.. I want to know whether there is any other way to get that information, *not using listener*, may be using the esper client package. – abhi Aug 21 '13 at 11:02
0

Use the on demand query api to make a one time query of the esper runtime engine:

String query = "select prev(0, evt) from Stream.win:length(10) as evt";
EPOnDemandQueryResult result = cepRT.executeQuery(query);
R Dub
  • 678
  • 6
  • 23