[rules-users] Maintaining state across invocations

ober0n lili339 at hotmail.com
Tue Feb 17 20:44:23 EST 2009


Hi, I am a total newb to Drools and am still trying to get a clear picture of
how things work. I have the HelloWorld example running in Eclipse and am
trying to modify it.

What I'd like to do is write a program that passes single events over a set
of rules I defined in Drools. Obviously I don't know these events ahead of
time and I don't know when they will be reported. 

Another important point is that I want each of these calls to be a stateful
transaction, for example:

1) Some event type A happens and is passed through drools: Rules say to
ignore the event

2) Some time later, and event type B happens and is passed through drools:
Rules say to ignore the event

3) Then, some time later, another event type A happens and is passed through
drools: This time the rule says to do some action because both event B AND
event A occurred.
(NOTE: Here, Drools would need to realize that event B has already occurred
and needs to take this into account when it invokes the rules. Thus state
needs to be taken into consideration.) 


I have been reading the documentation and have seen the stateless and
stateful sessions in the javadocs. But, I'm not sure if this is what I need
to accomplish the job. I was discouraged when I found this post:
http://lists.jboss.org/pipermail/rules-users/2008-February/004688.html
mentioning that the difference between stateful and stateless was the number
of objects that could be inserted into working memory before calling
fileAllRules().

>From the examples I've seen, Drools seems to be a simple program you call
once and the process is terminated (as opposed to a daemon-like program that
is continuously running). (Please correct me if I'm wrong.) Further, I
understand that Working Memory is where all the facts in Drools are
contained. I am wondering if these "facts" all disappear once an invocation
of Drools has finished. Or, do stateful sessions somehow maintain state
(facts) across Drools invocations? 

My best guess is that the Working Memory gets destroyed along with the facts
after an invocation of Drools and that to achieve the state that I want, I
will need to create some sort of infinite loop to encapsulate an invocation
of Drools to keep all the facts in Working Memory. Is that true?

I am more than happy to look all of this up myself but need a push in the
right direction. (Up to this point, I've been looking mainly looking at the
"JBoss Rules User Guide" and searching on the web.)

Thanks for your help and I would be more that happy to clarify any points.


-- 
View this message in context: http://www.nabble.com/Maintaining-state-across-invocations-tp22068357p22068357.html
Sent from the drools - user mailing list archive at Nabble.com.




More information about the rules-users mailing list