Mark,
I'm interested in this (for another mad reason).
I'm guessing that you're refering to AgendaEventListener; Are you
suggesting using an implementation of this listener that has a counter
to check if a rule is fired too many times , then calls
workingmemory.halt() if required?
Or is there a better way of doing this?
Thanks
Paul
Mark Proctor wrote:
There is no out of the box way to do this, you could add an event
listener and check yourself for recursion and halt the session if it
is spotted.
Mark
Isabelle Hupont wrote:
Hi!
I'm developing a software where the user creates his own rules, saves
then,
and finally fires them in order to preprocess a set of data.
I have implemented a method for controlling infinite loops (its simply a
timer). I would like to notify to the user the rule that has caused the
infinite loop, in order to change it. My code is the following:
public void fireRules(Instances instances) {
try {
assertInstances(instances);
// Worker thread to execute task that may hang.
WorkerThread workerThread = new WorkerThread();
// Wait for timeout or task end.
synchronized (this) {
workerThread.start();
try {
this.wait(60000);
} catch (InterruptedException e) {
log.error(e.getLocalizedMessage(),e);
}
if (!workerThread.isWorkDone()) {
// If work is not done then
workingMemory.fireAllRules()
// hasn't finished (the timeout has expired).
workingMemory.halt();
// Here comes the code for
capturing
rule that has code the loop
throw new PersistenceException("Operation
timeout. Please modify rule
XXX" );
}
}
cleanWorkingMemory();
} catch (PersistenceException e) {
log.error(e.getLocalizedMessage(),e);
}
log.debug("Rule firing finished");
}
private class WorkerThread extends Thread {
private boolean workDone = false;
public boolean isWorkDone() {
synchronized (SingletonInferenceEngine.this) {
return workDone;
}
}
public void run() {
workingMemory.fireAllRules();
synchronized (SingletonInferenceEngine.this) {
workDone = true;
SingletonInferenceEngine.this.notifyAll();
}
}
}
Can you help me?
Thanks in advance!
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users