Rule Execution Server persistence layer

You can store RuleApps as archives in a file persistence or database persistence system. The persistence layer provides a solution for file persistence (file system) or for database persistence (JDBC or data source).

You can set the persistence type to one of the following values:
  • file for a file persistence in Java™ SE
  • datasource for a database persistence in Java EE
  • jdbc for a database persistence in Java SE

File persistence and database persistence that use light embedded databases, such as hsqldb or derby, are easy to configure. Developers can easily write prototype projects and quick demonstrations.

When a new version of a ruleset is added to the management model, a notification of the update is sent through the Java Management Extension (JMX) or through the TCP/IP connection services to the execution unit (XU). The XU receives the new resource.

Important:
  • The ruleset persistence settings must be the same in the execution unit as in the Rule Execution Server console. See Changing the ruleset persistence type in the console.
  • Use database persistence when you deploy to a Java EE cluster environment. If you use file persistence, there is a risk of inconsistency. If, nevertheless, you choose to use file persistence with a clustered Rule Execution Server, you must make sure that all instances have access to a common network file system.

File persistence

File persistence targets the Java SE platform. It is useful for developers who test on a single local instance of the application server.

The file persistence system relies on two configuration parameters:
  • A parameter to switch the persistence to file mode.
  • A parameter to set the working directory of file persistence.

RuleApp archives are JAR files. JAR files provide efficient packaging and access to distributed content. When a RuleApp archive is extracted, its contents is written to a root directory as a single JAR file.

Rulesets with no managed Java XOM

The root directory is named yourWorkingDir/res_data by default. You can change this name by using the res-setup Ant task. The default res_data directory, or your customized root directory, is structured as follows:

  • One subdirectory for each level of the canonical ruleset path.
    • RuleApp
    • RuleApp version number
    • Ruleset
    • Ruleset version number
  • Each version subdirectory contains files that store the properties of the ruleset and ruleset archive.
    • The description.txt file describes the RuleApp or ruleset. It is not mandatory.
    • The display_name.txt file contains the alternative name of the RuleApp or ruleset. It is not mandatory.
    • The creation_date.txt file contains the creation date of the RuleApp or ruleset. It is mandatory.
    • The properties.txt file contains the properties of the RuleApp and ruleset. It is mandatory only for the ruleset, as it contains at least the status of the ruleset.
    • The ruleset archives are extracted as JAR files from the RuleApp (ruleset.jar).

The following tree illustrates that structure.

Tree structure of extracted RuleApp archives
Rulesets with managed Java XOM

The root directory is named yourWorkingDir/res_xom by default. You can change this name by using the res-setup Ant task. The res_xom directory, or your customized root directory, is structured as follows:

  • Two files for each deployed resource:
    • One file for the initial content of the JAR file. This file takes the initial file name, combined with the version number computed during the deployment process. For example: myjarfile_1.0.jar
    • One file for the checksum value (SHA-1 algorithm). This file takes the name of the previous file with an additional .sha1 file name extension. For example: myjarfile_1.0.jar.sha1
  • One subdirectory for each library name. This subdirectory contains a subdirectory for each version of the library. Each version-number subdirectory contains a .ref file which contains the list of URIs in the library.

If the name of a library contains a slash ('/') character, a subfolder is added. As an example, the creation of the myLib/myTag version 1.0 results in the following subfolders: ./res_xom/myLib/myTag/1.0

The following tree illustrates this structure.

File persistence for managed Java XOM: content of the version-number subfolder

Database persistence

The database persistence system relies on relational SQL schemas, represented by diagrams that use the following legend:
  • The key icon marks primary keys (PK).
  • Bold denotes NOT NULL values.
  • Arrows start directly from foreign key (FK) names.

The following diagram shows the relational tables for RuleApps and rulesets.

SQL relational tables for database persistence of rulesets

The following diagram shows the relational tables for execution traces.

SQL relational tables for database persistence of execution traces

The following diagram shows the relational tables for XOM resources and libraries.

SQL relational tables for database persistence of managed XOM resources

Database schemas

Rule Execution Server uses a simple database schema that relies on the following tables. In addition to these tables, a view is created to list all the enabled rulesets dynamically, if the targeted database management system supports the feature. All database management systems support it, except MySQL 3.x and 4.x. Indexes are created to speed up the search.

Restriction:

For RuleApps, RuleApp properties, ruleset properties, and ruleset resources, MySQL and Sybase database management systems are limited to the length of the VARCHAR type (255).

The following table describes the database schema for RuleApps.

Table 1. Database schema for RuleApps
Column Name Mandatory Database Type Comments
ID   INTEGER The value is autogenerated and handled directly by the database. Autogeneration is database dependent.
NAME Inline tick denoting enabled feature VARCHAR(256) This column stores the name of the RuleApp.
MAJOR_VERSION Inline tick denoting enabled feature INTEGER This column stores the major version number of the RuleApp.
MINOR_VERSION Inline tick denoting enabled feature INTEGER This column stores the minor version number of the RuleApp.
CREATION_DATE Inline tick denoting enabled feature BIGINT This column stores the creation date of the RuleApp as a long data type.
DISPLAY_NAME   VARCHAR(256) This column stores a possible alternative name of the RuleApp.
DESCRIPTION   VARCHAR(256) This column stores a text that describes the RuleApp.

The following table describes the database schema for rulesets.

Table 2. Database schema for rulesets
Column Name Mandatory Database Type Comments
ID   INTEGER The value is autogenerated and handled directly by the database. Autogeneration is database dependent.
NAME Inline tick denoting enabled feature VARCHAR(256) This column stores the name of the ruleset.
MAJOR_VERSION Inline tick denoting enabled feature INTEGER This column stores the major version number of the ruleset.
MINOR_VERSION Inline tick denoting enabled feature INTEGER This column stores the minor version number of the ruleset.
CREATION_DATE Inline tick denoting enabled feature BIGINT This column stores the creation date of the ruleset as a long data type.
DISPLAY_NAME   VARCHAR(256) This column stores a possible alternative name of the ruleset.
DESCRIPTION   VARCHAR(256) This column stores a text that describes the ruleset.
RULEAPP_ID Inline tick denoting enabled feature INTEGER This column stores the ID of the RuleApp to which the ruleset belongs.

The following table describes the database schema for RuleApp properties.

Table 3. Database schema for RuleApp properties
Column Name Mandatory Database Type Comments
ID   INTEGER The value is autogenerated and handled directly by the database. Autogeneration is database dependent.
RULEAPP_ID   INTEGER This column stores the ID of the RuleApp to which the property belongs.
NAME Inline tick denoting enabled feature VARCHAR(256) This column stores the name of the property.
VALUE Inline tick denoting enabled feature

VARCHAR(2000) or

TEXT (for MySQL and Sybase)

This column stores the value of the property.

The following table describes the database schema for ruleset properties.

Table 4. Database schema for ruleset properties
Column Name Mandatory Database Type Comments
ID   INTEGER The value is autogenerated and handled directly by the database. Autogeneration is database dependent.
RULESET_ID   INTEGER This column stores the ID of the ruleset to which the property belongs.
NAME Inline tick denoting enabled feature VARCHAR(256) This column stores the name of the property.
VALUE Inline tick denoting enabled feature

VARCHAR(2000) or

TEXT (for MySQL and Sybase)

This column stores the value of the property.

The following table describes the database schema for ruleset resources.

Table 5. Database schema for ruleset resources
Column Name Mandatory Database Type Comments
ID   INTEGER The value is autogenerated and handled directly by the database. Autogeneration is database dependent.
RULESET_ID   INTEGER This column stores the ID of the ruleset to which the resource belongs.
DATA Inline tick denoting enabled feature BLOB named archive This column stores the value of the resource.

The following table describes the database schema for XOM resources.

Table 6. Database schema for XOM resources
Column Name Mandatory/optional Database Type Comments
ID Optional INTEGER The value is autogenerated and handled directly by the database. Autogeneration is database dependent.
NAME Mandatory VARCHAR (256) This column stores the name of the resource.
MAJOR_VERSION Mandatory INTEGER This column stores the major version number of the resource.
MINOR_VERSION Mandatory INTEGER This column stores the minor version number of the resource.
SHA1 Mandatory VARCHAR (40) This column stores the checksum of the value of the resource (SHA-1 algorithm).
CREATION_DATE Mandatory BIGINT This column stores the creation date of the resource as a long data type.
DATA Mandatory BLOB This column stores the content of the resource.

The following table describes the database schema for managed Java XOM libraries.

Table 7. Database schema for managed XOM libraries
Column Name Mandatory/optional Database Type Comments
ID Optional INTEGER The value is autogenerated and handled directly by the database. Autogeneration is database dependent.
NAME Mandatory VARCHAR (256) This column stores the name of the library.
MAJOR_VERSION Mandatory INTEGER This column stores the major version number of the library.
MINOR_VERSION Mandatory INTEGER This column stores the minor version number of the library.
CREATION_DATE Mandatory BIGINT This column stores the creation date of the library as a long data type.

The following table describes the database schema for managed Java XOM libraries.

Table 8. Database schema for managed XOM library values
Column Name Mandatory/optional Database Type Comments
ID Optional INTEGER The value is autogenerated and handled directly by the database. Autogeneration is database dependent.
LIBRARY_ID Mandatory INTEGER This column stores the identifier of the library.
URL Mandatory VARCHAR (256) This column stores the value of the URL.

Database connections

When connecting to a database, Rule Execution Server relies on the persistence services offered by the application servers or a web server. In Java SE mode, it uses a direct JDBC connection.

Application servers provide the following facilities:
  • Connection pools to manage connections to the database.
  • Data source access to manage the data between the application server and the database.

JDBC drivers handle the connection to the database. The readme file of the product distribution provides the list of tested database drivers.

Database scripts

Before you can use Rule Execution Server with database persistence, you must create some resources, such as tables and indexes, in the database. Each application server has it own way of handling these persistence services. For more information, see the documentation of your application server.

To create the database table, use the Installation Settings wizard or run SQL scripts:
  • Run the Installation Settings wizard from the Rule Execution Server console.

    If you use the Installation Settings wizard to update database schemas, the number of steps depends on the configuration combination.
    • Four steps if one repository uses file persistence and the other database persistence
    • Eight steps if both use database persistence
    Table 9. Steps in the Installation Settings wizard for ruleset- and XOM repositories
    Ruleset repository XOM repository
    jndi A file
    file A jndi A
    jndi A jndi B
    jndi A jndi A
  • Run SQL scripts provided in the distribution here <InstallDir>/executionserver/databases/xomrepository_<database>

The product distribution provided SQL scripts for you to create database tables. You can find these scripts in <InstallDir>/executionserver/databases/<database>. The databases directory also contains a readme file. You can use any tool that can handle SQL to import and run the scripts. The following table lists the tools available for the supported databases, in alphabetical order. For more information, see the documentation of these tools.

Table 10. Tools to access database tables
Database Tool
Apache Derby ij command line processor
Hypersonic HSQLDB SqlTool
IBM® DB2® command center or db2 command line processor
MySQL mysql command line processor
Original drivers (JDBC 3) PostgreSQL
Oracle sqlplus command line processor
SQL Server Query Tool
Sybase isql command line processor