0
public ParseEvents()
{       
    String classpathLocation_plm = "com/esper/Resources/dataPkt.xsd";
    String classpathLocation_status = "com/esper/Resources/helloPkt.xsd";
    URL schemaURL_plm = this.getClass().getClassLoader().getResource(classpathLocation_plm);
    URL schemaURL_status = this.getClass().getClassLoader().getResource(classpathLocation_status);
    //System.out.println(schemaURL.getPath());
    ConfigurationEventTypeXMLDOM plmcfg = new ConfigurationEventTypeXMLDOM();
    ConfigurationEventTypeXMLDOM plmstatus = new ConfigurationEventTypeXMLDOM();
    epService = EPServiceProviderManager.getDefaultProvider();
    epService1 = EPServiceProviderManager.getDefaultProvider();
    plmcfg.setRootElementName("PACKET");
    plmcfg.setSchemaResource(schemaURL_plm.toString());
    plmstatus.setRootElementName("PACKET");
    plmstatus.setSchemaResource(schemaURL_status.toString());
    plmAdm = epService.getEPAdministrator();
    plmAdm1 = epService1.getEPAdministrator();
    plmAdm.getConfiguration().addEventType("PlmEvent", plmcfg);  
    plmAdm1.getConfiguration().addEventType("PlmStatus", plmstatus);

} I have two schema in classpath of the java project. Now the xml files (as events) coming to the esper engine does not understand which schema to understand. How can this problem be resolved? Experts please suggest !

2 Answers2

0

If all XML events have the same root element name, use EventSender to identify the type of events being sent in, i.e.: EventSender s1 = epService.getEPRuntime().getEventSender("PlmEvent") EventSender s2 = epService.getEPRuntime().getEventSender("PlmStatus")

create some EPL statementds like "select * from PlmEvent" and send events via "s1.sendEvent(xmldoc)"

user650839
  • 2,594
  • 1
  • 13
  • 9
0

Thanks for the solution. I tried a different way out. After the xml event is sent, a document is created after parsing of the xml by DOM parser and then this document is sent as an event to the Esper engine. I am checking for the tag name and then the xml event is interrogating with respective schema.

doc = builderFactory.newDocumentBuilder().parse(source);
            doc.getDocumentElement().normalize();           
            if((doc.getElementsByTagName("PSTATUS").getLength() != 0))
            {
                System.out.println("*** In Status packet ***");
                EPStatement cepStatement3 = plmAdm1.createEPL("select * from " + "PlmStatus"); 
                cepStatement3.addListener(new CEPListener2());
            }
            else
            {
                System.out.println("*** In Energy packet ***");

            }
Komal Gupta
  • 1,682
  • 2
  • 15
  • 18