[rules-users] Drools Fusion, best practise?!

Alexander Wolf mail at alexander-wolf.net
Wed Oct 16 13:11:37 EDT 2013


Hey, 

I try to use drools fusion to detect patterns in an event stream.
Each time an event occurs I insert it into my ksession and call fireAllRules().

Most of my rules need to reason over the newest event (the one that just came in) in conjunction with events that happend before or after that. 
I also have a "state" within my environment. e.g. temperature (HIGH, MEDIUM, LOW). (but also other state variables)

e.g. [pseudo code]
WHEN
	temperature MEDIUM or LOW
	newest event (value >= 20)
	last previous event (value >= 20)
then
	set temperature to HIGH


Now I run into lots of problems with this e.g. that I can not easily get the "newest" and "last previous" events. When i get Events() there is usually more than one (as some of them are not immediately expired)
Also the rule is triggert when temperature is changed without a new event being inserted. 

I could theoretically "mark" events that have been used, but I might run into problems when other rules are added that depend on the same events. Also it seems to be untidy to do so.
For now I used this to get the "newest" event, but it seems to be very non-declarative to do it like that

	//most recent event	
	Stack(size > 0, $event: pop, $event.value == 1) 
		from collect( Event())	


Are there any best practices especially for working with the "newest" event and with events + facts (as "states")?

- Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20131016/99e47e66/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 841 bytes
Desc: Message signed with OpenPGP using GPGMail
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20131016/99e47e66/attachment.bin 


More information about the rules-users mailing list