I am new to Jess, just could not figure out if there is a way to add rules to a running jess engine. I am calling jess command from a java application. All my rules are in a clp file, I use Rete.executeCommand("(batch *.clp)") to get all rules, then in a while loop I add some facts, call reset and run. It works fine if there is no need to change the rules in the clp file. I know I can move Rete.executeCommand("(batch *.clp)") into the while loop, but not sure if it's the right way to go since the rule file should not be changed very often. Please help!
Thanks in advance. [ September 10, 2004: Message edited by: Hope Zhu ]
You can define new rules at any time, and you can also remove old rules using "undefrule".
I can't explain precisely what you ought to do, because I'm not sure I understand your setup. It sounds like you want this program to run continuously, and if the rule file changes, you'd like to reload it? Is that right?
In your Java while loop, you could just use File.getLastModified() to check the modification date of the file, and if it changes, then you could just reload the file. You probably want to call Rete.clear() before reloading the file, though, as some changes (for example, adding or removing slots from a template) can't be done on a live engine.
No, Jess doesn't have any built-in way to automatically reload a batch file whenever it changes. But anything you can write in Java, you could also write directly in Jess, right? So just write the same while loop, but write it in Jess.