To use MRules in an applications, some necessary steps must be respected.
Retrieving binaries
MRules binaries may be integrated in two ways:
- Using a dependency management system, with the dependency provided in the downloads page. A BOM (Bill Of Materials) is provided in order to ease modules versions management.
- Downloading the jar file and directly integrating it in the CLASS_PATH.
A valid licence file also has to be accessible in the CLASS_PATH.
Writing rules
Rules are provided to the engine using configuration files, which are read using factories. Although it is possible to use the public APIs exposed by MRules components, this method is not recommended because less evolutive.
Depending on which factory is used, a specific syntax must be adopted. This section describes how rules are written with the currently available factories :
- Light XML grammar
- Full XML grammar
- DSL Grammar (close to natural language)
In every cases, writing rules requires a good knowledge:
- Of functional needs
- Of the data model (i.e. input / output beans structure)
- Of the factory’s specific syntax
Running the engine
Running the rule engine involves adding Java code to the application, allowing to compile and optimize rules and then execute the engine.
These three phases (compilation, optimization and execution) are distinct.
The first and second ones may be performed only once, as soon as configuration does not change. They provide a rule engine instance, which can be used simultaneously and concurrently by several processes. Centralized utilities are provided to handle instances and automatically detect configuration changes.
The third phase consists in executing the rules. The application must:
- Retrieve the instance of the rule engine.
- Build the input data (Java beans).
- Lauch the execution on these beans.
- Handle the results.
More details are available in the page describing the life cycle.