Hello,
I am currently working with the drools-camel-server and would like to retract all objects
in the KB (via Commands that connect using JAXRS).
Some of the objects are created by rules and so I do not have all the FactHandles.
How do I achieve this, please?
Interestingly, the newGetObjects command will return all the objects but not their
associated facthandles since if it did, I could simply have looped over this list and
issued a RetractCommand for each.
Any ideas (apart from re-creating the knowledge base), please?
Cheerio,
Nic
Nicholas Hemley
Show replies by date
One option is to send a special "cleanup" trigger fact and add a rule:
rule "Cleanup"
when
$c : Cleanup()
$o : Object( this != $c )
then
retract( $o );
end
You'll then need to retract the Cleanup fact. For example, you might use
another rule or make it an event with expiration
--
View this message in context:
http://drools.46999.n3.nabble.com/rules-users-drools-camel-server-Retract...
Sent from the Drools: User forum mailing list archive at
Nabble.com.
... and don't forget the 'Cleanup trigger' cleanup rule too ...
You can also do that kind of rule without 'Cleanup trigger', using a very low
salience, or specific agenda-group or ruleflow-group.
But if you really retract ALL facts, it will be far much faster to create a new kSession
(not a new KB, but a new session of the same KB, terms are important here). Remember that
retracting facts will trigger RETE evaluation (and beware if you have logical insertions
too). And last (but not least), at end of rules execution, I think you are expecting to
get the newly created objects ... but they won't be there anymore.
To me, massive retracts inside rules are only relevant if you want to keep some knowledge
in the current kSession. And even in this case, I really find cleaner to insert-at-init /
retract-at-end in the same place (both java or both rules).