Skip to content

Dealing with Esper Exceptions

rmuthupandian edited this page Feb 11, 2015 · 1 revision

Esper Engine throws exceptions while evaluating EPL statements. This could be because of bad EPL or bad data. If these exceptions are uncaught there is a potential for memory leak. Also this can lead to unprocessed events. There is a need to surface these exceptions so they become visible and make it easy to debug.

Esper Processor supports pluggable exception handlers that can be injected as shown below. The exceptions are also logged to an error manager which can be viewed through Esper Processor's monitoring page. Once an exception is logged, no more events will be processed by the engine. All events coming in to Esper Processor will be dropped and an alert notification will be sent once. In order to route all the unprocessed events we recommend that you inject an advice listener to the Esper Processor instance. If an advice listener is plugged in all the unprocessed events will be submitted to the advice listener. Jetstream provides a default Advice Processor which can be injected. One option would be to make the Kafka Outbound Channel a sink of the Advice Processor. This way all unprocessed events can be routed to kafka and replayed back.

This is how you inject the ExceptionHandler,

ExceptionHandler class which implements Esper's ExceptionHandler Interface

<bean id="EsperExceptionHandler" class="com.ebay.jetstream.event.processor.esper.EsperExceptionHandler" />

Register the factory class which creates EsperExceptionHandler instance and gives to Engine

<bean id="EsperConfiguration" class="com.ebay.jetstream.event.processor.esper.EsperConfiguration">
 
    <property name="exceptionHandlerFactoryClass"  value="com.ebay.jetstream.event.processor.esper.JetstreamExceptionHandlerFactory"></property>**

    <property name="timerLogging" value="true" />

Sample Esper Processor Bean with ExceptionHandler

<bean id="EsperProcessor" class="com.ebay.jetstream.event.processor.esper.EsperProcessor">
   <property name="esperEventListener" ref="EsperEventListener" />
   <property name="configuration" ref="EsperConfiguration" />
   <property name="epl" ref="EPLRouter" />
   <property name="eventSinks" ref="esperRTRsinks" />
   <property name="alertListener" ref="componentStatusHarvester" />
   <property name="esperExceptionHandler" ref="EsperExceptionHandler"></property>  
</bean>