[rules-users] Removing facts from statefulknowledgeSession's memory

Michael Anstis michael.anstis at gmail.com
Fri Nov 12 04:48:17 EST 2010


Very true Wolfgang, and I agree your comments re: accessing meta data too.

In this case if Events are raised in response to Facts and the events
themselves expire after 5 mins; I'd assume a constant time expiration policy
on the queue to be acceptable however this is based on assumption rather
than fact.

Edson\Mark are the experts in this realm so I'll defer further comment to
them.

With kind regards,

Mike

2010/11/12 Wolfgang Laun <wolfgang.laun at gmail.com>

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


More information about the rules-users mailing list