[rules-users] Drool 5 API and Agenda Listeners

Pegram, Macon zmpegram at choosehmc.com
Sun Oct 11 18:46:43 EDT 2009


The primary reason to move to the "Knowledge APIs" apart from what
you've already mentioned is that they help to bring together the newest
features of Drools.  In a single KnowledgeBase you can now have not only
rules, but Flows, and Complex Event Processing.   

As to tracking activity on the agenda... there's two ways...
1. If you're using Eclipse, one great feature of the Drools plugin is
the Audit Log.  You can start logging with the following code:
KnowledgeRuntimeLogger logger =
KnowledgeRuntimeLoggerFactory.newFileLogger(knowledgeSession, FILENAME);
Then open the resulting log in the Eclipse Drools Audit Log tab and get
a pretty good graphical representation of what happened during your run.
See the following URL for a screenshot:
http://downloads.jboss.com/drools/docs/5.0.1.26597.FINAL/drools-expert/h
tml_single/index.html#d0e6801

2. Create your own AgendaEventListener.   Simply implement the interface
and place whatever actions you want on each event.  Then attach it to
your session before you start processing like this:
knowledgeSession.addEventListener(new YourAgendaListener());

Macon

-----Original Message-----
From: rules-users-bounces at lists.jboss.org
[mailto:rules-users-bounces at lists.jboss.org] On Behalf Of SPAAARKY21
Sent: Sunday, October 11, 2009 12:26 PM
To: rules-users at lists.jboss.org
Subject: [rules-users] Drool 5 API and Agenda Listeners


I recently moved from Drool 4 to 5 in a little example application I had
written.  At first I hesitated because I thought the API had changed
drastically. When I did upgrade, I found that there were few changes. 
However, I was still using all of the "Rule" classes instead of the
"Knowledge" classes - like RuleBase and StatefulRuleSession instead of
KnowledgeBase and StatefulKnowledgeBase.  It sounds like the "Knowledge"
API
is the way of the future so to speak but I haven't been able to find
much
information on it.  What is the advantage in using the new "Knowledge"
API? 
Will the "Rule" API become deprecated at some point?

Anyway, after switching to the Knowledge API, I have been working on an
agenda listener I had written.  What I want to do is iterate through
agenda
groups on the focus stack and, for each group, iterate through the
activations in the order in which they are queued up.  However, I don't
see
any way to do that.  In fact, since switching to Drools 5 and the
"Knowledge" API, it looks like the API for dealing with the agenda and
activations and whatnot has become quite small.  Or at least it is when
you
stick to the interfaces.  Am I missing a better way of doing this?

Brandon
-- 
View this message in context:
http://www.nabble.com/Drool-5-API-and-Agenda-Listeners-tp25844904p258449
04.html
Sent from the drools - user mailing list archive at Nabble.com.

_______________________________________________
rules-users mailing list
rules-users at lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users




More information about the rules-users mailing list