There isn't much support Drools provides for this. The listener tells you about<br>a new Fact being inserted, and then - what? Unless you are satisfied with<br>a constant expiry offset, or define expiry times by a Map<Class<?>,Long><br>
or implement getExpiryOffset in all of your classes, you don't know <i><b>when</b></i><br>to retract.<br><br>You can define @expires(...) on a declare even when the @role is not "event",<br>but getting at this value isn't simple; you have to use the unstable API<br>
<br> org.drools.definitions.impl.KnowledgePackageImp rpkg = <br> (org.drools.definitions.impl.KnowledgePackageImp)kBase.getKnowledgePackage( "some.package" );<br> org.drools.rule.TypeDeclaration td = (org.drools.rule.TypeDeclaration)rpkg.pkg.getTypeDeclaration( "FactTYpe" );<br>
System.out.println( "Expires: " + td.getExpirationOffset() );<br><br>It's difficult to accept why features which are part of the established user interface are not accessible via the stable API. <br><br>
As an aside, notice that the Expert manual teaches me to add metadata to a Java-defined class:<br> declare org.drools.examples.Person<br> @author( Bob )<br> ...<br> end<br>Great, and Bob's your uncle! How do I retrieve this author metadata?<br>
<br>Regards<br>Wolfgang<br><br><br><br><br><br>2010/11/12 Michael Anstis <<a href="mailto:michael.anstis@gmail.com">michael.anstis@gmail.com</a>>:<br>> A time based eviction queue is simply a queue that evicts its content based<br>
> upon time-based heuristic. So the WorkingMemoryEventListener would store<br>> facts inserted into the WorkingMemory in an internal queue and evict them<br>> from that queue based upon some time-based heuristic. You could use an<br>
> Executor (ScheduledExecutorService) etc to remove facts from the queue and<br>> working memory at set intervals.<br>><br>> With kind regards,<br>><br>> Mike<br>><br>> On 11 November 2010 22:31, Ayush <<a href="mailto:ayush.vatsyayan@alcatel-lucent.com">ayush.vatsyayan@alcatel-lucent.com</a>> wrote:<br>
>><br>>> Can you please elaborate on "Have it store each inserted object in a<br>>> time based eviction queue and it'll remove things for you." i.e. how can I<br>>> do it?<br>>> --<br>
>> View this message in context:<br>>> <a href="http://drools-java-rules-engine.46999.n3.nabble.com/Removing-facts-from-statefulknowledgeSession-s-memory-tp1875795p1885760.html">http://drools-java-rules-engine.46999.n3.nabble.com/Removing-facts-from-statefulknowledgeSession-s-memory-tp1875795p1885760.html</a><br>
>> Sent from the Drools - User mailing list archive at Nabble.com.<br>>> _______________________________________________<br>>> rules-users mailing list<br>>> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>><br>><br>> _______________________________________________<br>> rules-users mailing list<br>
> <a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>> <a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>><br>
><br><br>