javacomplex-event-processingesperepl

Esper Deployment Error: invalid return type for static method, expecting Java class


My application configures and deploys an esper engine that parses an epl module that's stored in a MySQL database as a string. Everything works except when I try to call a static method from the epl module. I get the following error at deployment of the engine: DeploymentActionException: Deployment failed in module 'MyModule' in expression 'select...': Error starting statement: Invalid return type for static method 'myMethod' of class 'MyClass', expecting Java Class.

Here is the method:

public static String myMethod() {
    String symbol = "GOOG";
    logger.info("Hello From EPL");
    return symbol;
}

Here is the engine configuration and module deployment:

Configuration configuration = new Configuration();
        configuration.addEventType("MyEvent", MyEvent.class);
        configuration.addImport(com.tp.main.MyClass.class);
        epService = EPServiceProviderManager.getProvider("Service", configuration);
        EPDeploymentAdmin deploymentAdmin = epService.getEPAdministrator().getDeploymentAdmin();
        Module module = deploymentAdmin.parse(epl);
        String moduleId = deploymentAdmin.add(module);
        deploymentAdmin.deploy(moduleId, null);

Here is the epl module:

module MyModule; select propertyA, propertyB from MyEvent as propertyA unidirectional, method:MyClass.myMethod as propertyB

MyEvent has a getter for propertyA that returns String.

I have read and re-read the documentation backwards and forwards. It looks like everything should work. I've found examples on-line that further suggest all is well. But I cannot get past this error.

I've tried moving the imports to the epl module. I've tried changing from POJO events to Map events and back again. I've tried create schema in the epl module and using the runtime API to configure the event types and back again.

If I take out this method call, everything works as far as the other statements (not shown) in the epl module.

What am I missing?


Solution

  • "string" is not a POJO, its is in effect a primitive type. In the from-clause it should return an event type or POJO and a primitive type is not a possible value as it does not have any properties.

    public class Result {
      String result;
    }
    
    public static Result myMethod() {
      String symbol = "GOOG";
      logger.info("Hello From EPL");
      return symbol;
    }