Just in case anybody wonders about the effort for building a mechanism for
retracting facts based on fact attributes or other data, I outline the
solution I have implemented.
My class FactWiper implements WorkingMemoryEventListener and Runnable.
- The implementation of objectInserted( ObjectInsertedEvent event )
determines whether the object needs handling and, if so, the retraction
Date, based upon whatever strategy you care to implement, e.g., reflection
method call, Map<Class,Long>, etc. If it is to be handled, it signals
Condition "change" to the thread.
- A SortedMap<Date,Object> expiry2fact keeps track of pending
retractions.
- The thread loops into an awaitUntil( x ) on the "change" condition,
where x is (generally) the first retraction Date. If reached, it retracts
according to the foremost Map entry; if signalled it reasesses the situation
and reenters the awaitUntil.
-W
2010/11/12 Michael Anstis <michael.anstis(a)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(a)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-s...
> Sent from the Drools - User mailing list archive at
Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>
_______________________________________________
rules-users mailing list
rules-users(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users