0

My DRL file:

package com.sample.eventmanagement;

import com.sample.eventmanagement.CheckInEvent    
import com.sample.eventmanagement.LateCheckInEvent     

global java.util.concurrent.BlockingQueue lateCheckInEntitiesQueue;    
global java.util.concurrent.BlockingQueue clearingLateCheckInEntitiesQueue;    

declare CheckInEvent    
 @role(event)    
 serialNum : String    
 currentCheckInTime : long    
end    

declare LateCheckInEvent    
 @role(event)    
 @expires( 120m )    
 serialNum : String    
 currentCheckInTime : long    
end    

rule "Raising an Late Check-In Alert"    
when     
    $s1: CheckInEvent( $serialNum : serialNum, $currentCheckInTime: currentCheckInTime ) from entry-point apCheckInStream    
    not( CheckInEvent( serialNum == $serialNum, currentCheckInTime > $currentCheckInTime, this after[ 1s, 360s ] $s1 ) from entry-point apCheckInStream)     
then     
    lateCheckInEntitiesQueue.add($s1);    
end    

rule "Clearing Late Check-In Alert"    
when     
    $s1: LateCheckInEvent( $serialNum : serialNum, $currentCheckInTime: currentCheckInTime ) from entry-point lateApCheckInStream    
    CheckInEvent( serialNum == $serialNum, currentCheckInTime > $currentCheckInTime) from entry-point clearingApCheckInStream    
then     
    System.out.println("Clearing late checkin " + $s1);    
    clearingLateCheckInEntitiesQueue.add($s1.getSerialNum());    
end

I am running drools in stream mode in karaf 2.4.3 in linux vm, reports out of memory for 10k entity checkinevent pumping every 5 minutes.

My use case is detect latecheckinevent for entity identified by serialnumber. On late checkin event detected pumping that event to another rule and waiting for proper checkin again from that entity within 2 hours. If it happens rule 2 is fired.

Is there any problem in the way i have the written the query. ?

kaskelotti
  • 4,709
  • 9
  • 45
  • 72
Abirami
  • 87
  • 7

1 Answers1

0

Facts are going to remain in your session (in memory) until:

  • you manually retract them: using delete() or retract()
  • the engine retract as part of its truth-maintenance system: i.e. logically-inserted facts.
  • the CEP engine (fusion) detects that, because of the constraints where it is involved, a fact marked with @expires is no longer required in the session.

Your scenario doesn't appear to fall into any of these 3 cases.

** By the way, I haven't seen a query in your DRL file.

Hope it helps,

Esteban Aliverti
  • 6,259
  • 2
  • 19
  • 31
  • I added @expires for CheckInEvent, now there is no outOfMemory. Instead of mentioning it as rule , i mistyped as query. – Abirami Jan 04 '16 at 09:01