Notifying a XU on Java SE of a ruleset update

In a Java™ SE application, you can notify the execution unit (XU) that a ruleset is no longer valid because it has been updated.

About this task

To notify the execution unit (XU) of a ruleset update on Java SE, you create a management session from a Java SE rule session factory, you retrieve the canonical ruleset path, and you pass the IlrManagementSession.invalidate method on the instance of management session bean. This method takes a canonical ruleset path. To retrieve the canonical ruleset path, use the solveRulesetPath method. When a ruleset is invalidated, that ruleset is parsed at the next request. Therefore, this action might significantly affect performance.

In either of the following configurations, you can have the XU notified of ruleset updates by connecting the XU instances to a TCP/IP server:
  • The Java SE XU does not run in the same Java virtual machine (JVM) as the Rule Execution Server console.
  • The Java SE XU runs outside the application server cluster to which the Rule Execution Server is deployed.

Procedure

  1. Get the rule session factory.
    IlrJ2SESessionFactory sessionFactory = new IlrJ2SESessionFactory(new PrintWriter(System.out));
  2. Create the management session.
    IlrManagementSession managementSession = sessionFactory.createManagementSession();
  3. Retrieve the canonical path of the ruleset.
    IlrPath rulesetPath = IlrPath.parsePath("/RuleApp/1.0/RuleSet/1.0");
  4. Invalidate the ruleset.
    managementSession.invalidate(rulesetPath);

Example

Here is the entire code sample.
 IlrJ2SESessionFactory sessionFactory = new IlrJ2SESessionFactory(new PrintWriter(System.out));
 IlrManagementSession managementSession = sessionFactory.createManagementSession();
 IlrPath rulesetPath = IlrPath.parsePath("/RuleApp/1.0/RuleSet/1.0");
 managementSession.invalidate(rulesetPath);