@POST
@Path("/minPrice")
@Consumes(MediaType.APPLICATION_JSON)
public String minPrice() {
String userQuery = "select min(price) from MyEventClass";
String userFileName = "MyInputFIle.csv";
SimpleLayout layout = new SimpleLayout();
ConsoleAppender appender = new ConsoleAppender(new SimpleLayout());
Logger.getRootLogger().addAppender(appender);
Logger.getRootLogger().setLevel((Level) Level.WARN);
MyEventClass MEC = new MyEventClass();
//configuration
Configuration configuration = new Configuration();
configuration.addEventType(MEC.getClass());
EPServiceProvider epService;
epService = EPServiceProviderManager.getDefaultProvider(configuration);
epService.initialize();
//including the data stream to the eventclass
AdapterInputSource source = new AdapterInputSource(userFileName);
try {
//registering the query with the CEP
EPAdministrator cepAdm = epService.getEPAdministrator();
EPStatement cepStatement2 = cepAdm.createEPL(userQuery);
CEPListener6 listener = new CEPListener6();
//connecting the listener
cepStatement2.addListener(listener);
} catch (Exception e) {
System.out.println("Incorrect syntax in the statement " + e);
}
System.out.println("ehefjfhkjfhskfhsfksf");
CSVInputAdapter inputAdapter = new CSVInputAdapter(epService, source, "MyEventClass");
inputAdapter.start();
return "Build success!!";
}
我是Esper CEP引擎的新蜜蜂。任何方式在这一刻我都可以从csv文件中获取事件,并使用EPL语句提取数据,并从相关监听器获取输出值。Esper CEP和Rest API
事情是我开发了这个作为一个普通的Java应用程序,但现在我想实现它作为一种服务,所以客户端(这是一个意味着Web应用程序)可以调用我的方法和提取数据使用我的应用程序作为服务。 为此,我正在开发应用程序作为使用泽西框架的休息服务。
编写服务后,我使用“邮递员”检查了它,但输出表示请求失败。 我调试并检查了它工作的产品,直到达到最后3行。 下面的行会产生问题吗?请告诉我如何使其正确 “CSVInputAdapter inputAdapter = new CSVInputAdapter(epService,source,”MyEventClass“);”
我的服务器端代码不显示任何错误,即使在运行时它也不会显示任何异常。 我能做什么错?请让我知道我的方法是否正确? 还是有其他方法可以做到这一点吗? 我也附上了我的服务班。 预先感谢您
是的,我已经将文件包含到服务器。我发现使用try catch子句的异常,它说“MyInputFile.csv”不在类路径中。然后我将文件移到相关位置。然后它运行良好。感谢你们对我的帮助 :) –