Alvins
Alvins

Reputation: 887

Esper get notify when data is lost without spamming

I've got a data stream that send a packet every 10 seconds. I need a query for Esper that generate event (with last packet received) when the device is down. I assume device lost if no data arrives for 30sec but I need to get only 1 notify every 5h until the device came back, to avoid spam

Here is my base query:

select * from pattern [every tick=MyInputStream-> (timer:interval(30 sec) and not MyInputStream)] output every 5 hours 

But it doesn't work, after first event i got:

Event: 
-> {tick=BeanEventBean eventType=BeanEventType name=MyInputStream clazz=mypackage.MyInputStream bean=MyInputStream [field1=1, field2=2]}
  Event: 
ERROR - Unexpected exception invoking listener update method on listener class 'GenericListener' :       NullPointerException : null
 java.lang.NullPointerException at cep.listener.GenericListener.update(GenericListener.java:11)
     at  com.espertech.esper.core.service.StatementResultServiceImpl.dispatchInternal(StatementResultServiceImpl.java:381)
     at  com.espertech.esper.core.service.StatementResultServiceImpl.processDispatch(StatementResultServiceImpl.java:256)
     at  com.espertech.esper.core.service.StatementResultServiceImpl.execute(StatementResultServiceImpl.java:242)
     at com.espertech.esper.core.service.UpdateDispatchViewBase.execute(UpdateDispatchViewBase.java:75)
     at com.espertech.esper.core.service.UpdateDispatchFutureSpin.execute(UpdateDispatchFutureSpin.java:85)
     at com.espertech.esper.dispatch.DispatchServiceImpl.dispatchFromQueue(DispatchServiceImpl.java:52)
     at com.espertech.esper.dispatch.DispatchServiceImpl.dispatch(DispatchServiceImpl.java:31)
     at com.espertech.esper.core.service.EPRuntimeImpl.dispatch(EPRuntimeImpl.java:1340)
     at com.espertech.esper.core.service.EPRuntimeImpl.processTimeEvent(EPRuntimeImpl.java:540)
     at com.espertech.esper.core.service.EPRuntimeImpl.processEvent(EPRuntimeImpl.java:425)
     at com.espertech.esper.core.service.EPRuntimeImpl.sendEvent(EPRuntimeImpl.java:197)
     at com.espertech.esper.core.service.EPRuntimeImpl.timerCallback(EPRuntimeImpl.java:171)
     at com.espertech.esper.timer.EPLTimerTask.run(EPLTimerTask.java:61)
     at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
     at java.util.concurrent.FutureTask.runAndReset(Unknown Source)
     at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(Unknown Source)
     at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
     at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
     at java.lang.Thread.run(Unknown Source)

Also I think that my query is not 100% correct for my problem.

Can anyone help me?

Upvotes: 1

Views: 460

Answers (1)

user650839
user650839

Reputation: 2594

The exception indicates that the listener code throws the NullPointer. You'd want to check your code. Check context partitions for the start and end type logic.

Upvotes: 1

Related Questions