I have a web service in which I'm using a Drools 5 StatefulKnowledgeSession object.
The object lives between web service method invocations. 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. I don't think
that .clear() is doing what I think it is because by using a println() statement inside my
one and only rule's consequence I can see information from previous rules that should
be gone. In fact, the rule's consequence is invoked multiple times and I don't
know why. It's during those multiple invocations that the .println() shows me
information about the current and previous facts. The only method to fix this that
I've come up with is to delete and recreate StatefulKnowledgeSession every time the
web service's service method
is invoked, but that feels like a poor work-around. Any direction on how to delete facts
is greatly appreciated. Thank you.