2011/8/1 Matthew Erler <span dir="ltr">&lt;<a href="mailto:wires8@yahoo.com">wires8@yahoo.com</a>&gt;</span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top">
The first thing that the service method needs to do is clear out all the facts inserted during the last service method invocation.  I use StatefulKnowledgeSession.insert(Object fact) to add facts and StatefulKnowledgeSession.getAgenda().clear() to clear out all facts. </td>
</tr></tbody></table></blockquote><br>The Agenda is where all <i>rule activations</i> live. Facts are reachable via the kSession object, e.g., kSession.getFactHandles(), and you could use retract() on them. But note well that retracting facts is not a free lunch: each one updates the Rete network. <br>
<br>Calling kSession.dispose() and kBase.newStatefuleKnowledgeSession() is a perfectly reasonable way to clear the ring for the next round. <br><br>-W<br></div>