Complex event processing Esper:EPL";选择";未能找到验证错误

Complex event processing Esper:EPL";选择";未能找到验证错误,complex-event-processing,esper,epl,Complex Event Processing,Esper,Epl,我试图用Esper运行一个简单的测试(第14章)。代码非常简单: public class EventLengthWindowTest { public class LoanRequestEvent { public int amount =2; public LoanRequestEvent(int a){ amount += a; } } private int sumAmount = 0; @Test public void testEve

我试图用Esper运行一个简单的测试(第14章)。代码非常简单:

public class EventLengthWindowTest {
  public class LoanRequestEvent {
    public int amount =2;

    public LoanRequestEvent(int a){
        amount += a;
    }
}

private int sumAmount = 0;

@Test
public void testEventLengthWindow() {
  Configuration configuration = new Configuration();
  configuration.addEventType(LoanRequestEvent.class); 

  EPServiceProvider epService = EPServiceProviderManager.getDefaultProvider(configuration);
  EPAdministrator admin = epService.getEPAdministrator();
  EPStatement epStatement = admin.createEPL("select sum(amount) as sumAmount from LoanRequestEvent.win:length(2)");

  ...
}
我收到一条关于EPL部件的错误消息:

"select sum(amount) as sumAmount from LoanRequestEvent.win:length(2)"
它说:

com.espertech.esper.client.EPStatementException: Error starting statement: Failed to validate select-clause expression 'sum(amount)': Property named 'amount' is not valid in any stream [select sum(amount) as sumAmount from LoanRequestEvent.win:length(2)]

知道为什么会发生这种情况吗?

如果您希望Esper读取和/或写入事件类中的事件属性,则需要为它们提供JavaBean getter和setter。要使示例正常工作,您需要添加一个getter,如下所示:

public class LoanRequestEvent {
    public int amount =2;

    public LoanRequestEvent(int a){
        amount += a;
    }

    public int getAmount() {
        return amount;
    }
}