[rules-users] Event processing/Drools Fusion: problem using "this after" and "@expires"

diana-mendes diana-mendes at hotmail.com
Fri Nov 4 13:54:51 EDT 2011


Hello,

I'm implementing a simple event processing application, and I'm getting
unexpected results. I use the time operator "this after" and I declare one
of my events with an "@expires" property.

I want to detect an event with a certain attribute (let's call it "main
event"), and when this event arrives I want to initiate a timer so that I
collect all the events that arrive within the next 10 seconds, regardless of
their attributes. A second timer should never be initiated until the first
one ends.

In order to implement this scenario I used an auxiliary event, named
"Context", that is inserted in the working memory when the "main event" is
detected, and expires after 10 seconds.

So I have two rules: the first one detects the "main event" (when there's no
Context in the working memory) and inserts a Context event. The second rule
fires when there's a Context event, and lists all the other events that
arrive within the next 10 seconds.



The rules are bellow:

rule "Detect Main Event"
activation-group "A"
lock-on-active true
salience 1
	when
		$event : Notif( specificProblem == "New ONT" || specificProblem == "ONT Is
Inactive" ) && not Context()
	then
	        System.out.println("Context Created by
"+$event.getSpecificProblem()+" "+$event.id);
		insert( new Context($event) );
end
		
rule "Collect Events in a 10 second window"
activation-group "A"
lock-on-active true
salience 2
	when
		$context : Context()
		$list10s : List() from collect ( Notif( this after [0s,10s] $context ))
	then		
		Notif notifContext = $context.getNotif();
		System.out.println("context: "+notifContext.getSpecificProblem()+"
"+notifContext.id);
		Helper.printList($list10s);
end




The output I get is the following:

/0s: New ONT 1/
Context Created by New ONT 1

/2s: ONT is inactive 1/
context: New ONT 1
-List:
--ONT Is Inactive1
---

/4s: ONT is inactive 2/
context: New ONT 1
-List:
--ONT Is Inactive1
--ONT Is Inactive2
---

/7s: New ONT 2/
context: New ONT 1
-List:
--ONT Is Inactive1
--ONT Is Inactive2
--New ONT2
---

*/22s: New ONT 3/
context: New ONT 1
Empty list

/27s: New ONT 4/
Context Created by New ONT 4*

The lines in italic are the events I receive, and the respective time
instance, in seconds.

The lines in bold are the unexpected results. When I receive event "New ONT
3", the "Context" should have expired by then and it should create a new
one. What could be causing this? It seems to work properly until I receive
that event.

Any help would be greatly appreciated, as I've tried several modifications
and none seem to work.
Thanks in advance,
Diana



--
View this message in context: http://drools.46999.n3.nabble.com/Event-processing-Drools-Fusion-problem-using-this-after-and-expires-tp3480800p3480800.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list