@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!!";
}
I'm a new bee to Esper CEP engine. Any way at this moment I'm able to take events from a csv file and extract the data using EPL Statements and take the output values from the relevant listeners.
The thing is I developed this as a normal java application, but now I want to implement it as a service so the client(it is a mean web app) can call my methods and extract data using my application as a service. For that now I am developing the application as a rest service using jersey framework.
After writing the service I checked it using "postman" but the output says request failure. I debugged and checked the product it works until you reach the last 3 lines. The below line makes the problem? please advise me how to make it correct "CSVInputAdapter inputAdapter = new CSVInputAdapter(epService, source, "MyEventClass");"
My server side code does not show any errors, even in the run time it does not show any exceptions. What could I have done wrong? Please let me know whether my approach is even correct? or is there any other way to do this ? I have also attached my service class along with this. Thank you in advance
With userFileName as "MyInputFIle.csv", does that file reside on the client or the server? If it resides on the client you would need to upload the file to the REST server first.
I'd suggest posting the full exception stack trace with the post if you see any exceptions.