ILOG JRules User Guide > Managing Rule Execution Server > Tasks > Monitoring Rule Execution Server Events > Receiving Notification of Rule Engine Events Using the API > Extending the IlrRuleEngineEventPlugin

To receive rule engine events (IlrRuleEngineEvent) you need to extend the class ilog.rules.bres.xu.plugin.IlrRuleEngineEventPlugin and implement the method ruleEngineEventRaised.

images/IlrRuleEngineEventListener.png

To extend the plug-in:

import ilog.rules.bres.xu.plugin.*;
import ilog.rules.bres.xu.event.*;
public class MyPlugin extends IlrRuleEngineEventPlugin {
    public void ruleEngineEventRaised(IlrRuleEngineEvent event) {
        // ...
        // Do something with the event
        // ...
    }
}

The notification of rule engine events is not limited to one plug-in for each XU instance.

To write a plug-in for a particular ruleset:

public class MyRulesetPlugin extends IlrRuleEngineEventPlugin {
   public static final String THIS_CANONICAL_RULESETPATH = "ThisRuleApp/1.0/ThisRuleset/1.0";
   public void ruleEngineEventRaised(IlrRuleEngineEvent event) {
   if (event.getCanonicalRulesetPath().equals(THIS_CANONICAL_RULESETPATH))
   {
      thisEngineEventRaised(event);
   }
   public void thisEngineEventRaised(IlrRuleEngineEvent event) {
      // code handling a rule engine event only for this ruleset
      [....]
   }
}

The rule engine events will only be raised for rulesets that have the ruleset trace mode enabled, that is, the XU ruleset property ruleset.trace.enabled must be set to true. You can add this property for each ruleset through the Rule Execution Server Console. For more information, see the Rule Execution Server Console Online Help.

Note
To receive notifications from tasks using the sequential mode, you must enable debugging for this mode.

Related Concepts

Rule Execution Server Management Model

Related Tasks

Execution Events Monitoring
XU Plug-in Packaging
Configuring the XU for the XU Plug-in