> 3. Instantiate a Rete object with engine = new
> Rete(Someclass.class) to register the context with engine.
[alan]
This isn't required to sink jess events. This constructor is for applets or EJB-style containers (I think.)
> 3.
> Register that class to receive events via
> engine.addJessListener().
[alan]
This is required.
> 4. Call engine.setEventMask() for
> each event that I want to receive.
[alan]
I assume you are combining the event mask(s) so that you only call setEventMask() once.
>
> I tried all this and didn't have any luck, so I'm obviously
> missing something.
>
> Now, for simplicity sake, let's say that Someclass contains a
> method called
> process() where:
>
> public void process() {
> engine.executeCommand("(batch main.clp)");
> engine.executeCommand("(batch resolve.clp)");
> engine.executeCommand("(batch schedule.clp)");
> engine.reset();
> engine.runUntilHalt();
> }
[alan]
When do you call Rete#addJessListener()? You proly already know this but it needs to be called before Rete#runUntilHalt();
>
> Now, I have a slew of questions:
>
> 1. While runUntilHalt() is executing, does the listening
> class need to be listening on another thread to receive
> events while the engine is running?
[alan]
No, your listener method will be called back via the thread initiating the Rete activity. In your case, it will most likely be the thread that calls Rete#runUntilHalt().
> 2. Does it matter at all
> that process() is running Jess script via
> engine.executeCommand() instead of executing API code
> directly?
[alan]
Nope, shouldn't matter.
> 3. Is this an acceptable way of programming in
> Jess? Should all the script be in one file?
[alan]
It's *all* good.
> 4. My main
> reason for wanting the events produced by Jess was to log
> them for debugging. (Jess is being used in a webapp here, and
> I am using Apache Jakarta Log4J as the logger.)
[alan]
I use it for exactly this purpose as well.
> My initial
> thought was to put logging statements in the implementation
> of eventHappened() like this:
>
> public void eventHappened(JessEvent je) throws JessException {
> switch (je.getType()) {
> case JessEvent.ACTIVATION:
> Activation activation = (Activation) je.getObject();
> String ruleName =
> activation.getRule().getDisplayName();
> logger.info("Activation: " + ruleName
> + " was activated or deactivated.");
> break;
> // ... more code
> }
>
> What's the best way of logging Jess output and events when
> Jess is embedded in a web application? (I don't mean
> generating JSP views for input/output - that I've got fine.)
[alan]
I use a jess listener to log structured information, such as rule firing, etc. However, you will find life much easier if you add an output router and send the output to your log file also.
Your problem above could be due to an error in your (batch) statements (FileNotFoundException?) or a runtime error in the LHS of one of your rules. Check your webapp/container logs for errors. Also, put a try/catch around the body of process() to catch any errors being thrown by jess.
Good luck!
alan
>
> Thanks!
> -JM
>
> ------------------------
>
> Jason Morris
> Morris Technical Solutions [EMAIL PROTECTED]
> www.morristechnicalsolutions.com
> fax/phone: 503.692.1088
>
> --------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users
> [EMAIL PROTECTED]' in the BODY of a message to
> [EMAIL PROTECTED], NOT to the list (use your own address!)
> List problems? Notify [EMAIL PROTECTED]
> --------------------------------------------------------------------
>
