You build and run the sample, and look at source files to understand how the sample works.
The sample includes two build processes for the current project and baseline:
MyTest: a testing process for rulesets.
MyDeploy: a deployment process for deploying a ruleset to Rule Execution Server.
To find your local host port number (<PORT>) to run this sample, see Checking the server port number.
To configure the sample:
You create a database before running the sample:
In your browser, enter http://localhost:<PORT>/rozo. A sign-in page opens.
If necessary, enter:
Username: rtsAdmin
Password: rtsAdmin
Click Sign in. A new page opens.
Click Create DB to create the database.
Click Sign out.
Sign in to Decision Center with the username and password in Step 1.
On the Home tab, select the rule project loanvalidation-rules.
You create the ruleset that is updated by the sample.
To configure the ruleset:
Click the Configure tab.
Click Manage RuleApps.
Click New.
In Name, enter MyRuleApp.
In Rulesets, click New.
In Name, enter MyRuleset, and select loanvalidation-rules as the project.
Click Save to save the ruleset, and click Save again to save the ruleapp.
To configure a testing profile:
Click the Configure tab.
Click Continuous Integration and Configuration. The Configuration Build Management page is displayed.
Click Add profile configuration if it is not open.
In Profile Type, select Testing.
In Name, enter MyTest.
Click Apply.
In Update profile configuration, select the Enable/Disable check box to enable the profile.
Configure the profile as follows:
Property Name | Property Description | Value |
---|---|---|
Decision Center Data source | The data source holding the scenario suites. In a real project, the authoring and build instances of Decision Center should be two separate instances pointing at the same database. For simplicity, you use the same instance in this sample. | jdbc/ilogDataSource |
Decision Center Password | The password to connect to the server. | rtsAdmin |
Decision Center URL | The URL to the server. | http://localhost:<PORT>/teamserver |
Decision Center User | The user who connects to the server. | rtsAdmin |
Inactivity Threshold | The tests are launched when no authoring activities are detected during the time you specify (in minutes). | Enter 0 to execute the tests immediately. |
Interval | The minimal time between two consecutive tests (launch times specified in minutes). | Enter 0 to execute the tests immediately. |
Notification Threshold | The minimal number of authoring activities enabling test launches. | Enter 1 to execute the tests only when one rule (or a decision table) is updated. |
Query | The query that searches for the scenario suite you want to use in the tests. Note that you can use more than one query at a time. Use the + button in the user interface configuration to add more queries. | MyQuery |
Rule Execution Server Server | The server that executes the tests. | Sample (the default Rule Execution Server) |
Click Apply.
Click the Build tab to see the MyTest build profile. There are no reports at this time.
You have configured the profile as follows:
Set up a scenario suite used by MyQuery. The suite is located and executed on a Decision Center instance with the following properties:
URL: http://localhost:<PORT>/teamserver
Sign-in credentials:
Username: rtsAdmin
Password: rtsAdmin
Data source: jdbc/ilogDataSource
The project and baseline used for testing are the same as the ones you have selected. If you configure the Decision Center as remote, it should point to the database that you are currently signed in to when it configures the build.
Execute scenario suites on a Rule Execution Server named "Sample." To see the configuration of this server, click the Configure tab, and then click Manage Server .
This profile triggers the execution of the scenario suites retrieved by MyQuery under the following conditions:
No user updates, deletes, or creates an artifact in the project or baseline for one minute.
The last build was launched at least one minute ago.
A user has updated, deleted, or created an artifact at least one time.
You create the query that retrieves the scenario suite you want to execute to test the ruleset.
To create the query:
Click the Query tab.
Click New.
In Name, enter MyQuery.
Change Find to all test suites.
Click Save.
Now you configure the deployment build process.
To create a deployment profile:
On the Configure tab, click Continuous Integration Configuration. The Configuration Build Management page opens.
Click Add profile configuration.
In Profile Type, select Deployment.
In Name, enter MyDeploy.
Click Apply.
In Update profile configuration, select the Enable/Disable check box to enable the profile.
Configure the profile as follows:
Property Name | Property Description | Property Description |
---|---|---|
Decision Center Data source | The server data source with the rule project you want to deploy. In a real use, the authoring server instance and the build server instance should be two different instances of Decision Center pointing at the same database. For simplicity, you use the same instance in this sample. | jdbc/ilogDataSource |
Decision Center Password | The password to connect to the server. | rtsAdmin |
Decision Center URL | The URL to Decision Center. | http://localhost:<PORT>/teamserver |
Decision Center User | The user of the server. | rtsAdmin |
Rule Execution Server Web App. | The web application name for the server. | res |
Deployment time | The time at which the ruleset is deployed (in hour:minute format). | Enter the current time. |
Merging Policy | The ruleset deployment policy. | REPLACE_RULESET |
Rule Execution Server Host | The name of the host where the server is located. | localhost |
Rule Execution Server Password | The password used to connect to the server. | resAdmin |
Rule Execution Server Port | The port number of your server. | <PORT> (See Checking the server port number.) |
Rule Execution Server User | The user of the server. | resAdmin |
RuleApp Name | The name of the deployed RuleApp. | MyRuleApp |
Click Apply.
You have configured a profile to deploy a ruleset to a remote Rule Execution Server from a Decision Center project.
The profile triggers a deployment when the time in the Deployment time property runs out.
To trigger the MyTest profile:
Click the Explore tab.
Click the computation package.
Change the status of intialCorporateScore to Defined.
Click Finish to save your changes.
Click the Build tab.
In the Choose a build profile to display related results menu, select MyTest.
Click Refresh to start the build.
Click View to see the execution results.
To deploy and view the ruleset:
In the “Choose a build profile to display related results” menu, select MyDeploy.
Click Refresh to start the build.
Sign in to your Rule Execution Server console. You can see that the ruleset has been deployed.
To rebuild the sample:
In the Samples console, double-click the build target to compile the code.
To redeploy the sample, double-click the deploy target.
The sample is divided into three main parts:
Decision Center customization, located at:
servercontinuousintegration\src\com\ibm\rts\sample\build\client
servercontinuousintegration\client
Build server, located at:
servercontinuousintegration\src\com\ibm\rts\sample\build\client
servercontinuousintegration\client
Shared, which is used by the two other parts. It mainly contains the bean and the model for the sample.
The Decision Center customization part is divided into five layers under servercontinuousintegration\src\com\ibm\rts\sample\build\client\:
DAO: bean
Event: event
JSF helper: jsf
Decision Center helper layer: rts
Web helper: web
The sample adds the following to the Decision Center user interface:
A Build tab to display the results of builds.
A Continuous Integration Sample link to the existing Configuration tab to configure the sample.
A customized controller to handle rule authoring events, including creating, updating, and deleting business rule artifacts.
When the sample is deployed, some configuration is done to Decision Center using the Ant target set-config-param in the servercontinuousintegration\build.xml file.
To view these properties in Decision Center, go to Configure > Installation Manager, and then click Set configuration parameters.
These properties show you where to send the events. The user interface customization is in servercontinuousintegration\client\WebContent. The onCommitElement method of the controller NotificationController.java is called each time the business user updates, deletes, or creates a rule artifact. The controller sends event details through HTTP to the build server.
All the data displayed in the Build tab and the Sample Configuration is retrieved from the build server using HTTP as well.
See the servercontinuousintegration\src\com\ibm\rts\sample\build\client\event\EventManager.java class.
The build server is divided into three layers under servercontinuousintegration\src\com\ibm\rts\sample\build\server\:
DAO: dao
Task management framework: fwk
Task implementation: impl
When a user updates, deletes, or creates a rule artifact, the server event manager (EventHandler.java) receives the events from Decision Center and persists them in the sample database using the DAO layer.
At startup, the server creates a watcher thread. (WebSphere® Asynchbeans WorkManager allows you to develop multithreaded applications for use inside WebSphere Application Server). For each configured build profile, the server checks repeatedly whether it is time to trigger the profile. When it is time, the server associates an asynchronous bean, or asyncbean, with the profile for execution. An asyncbean is a Java™ object or enterprise bean that can be executed asynchronously by a Java 2 Platform Enterprise Edition (J2EE) application using the J2EE context of the asynchronous bean creator.
This sample implements the following tasks, located at \servercontinuousintegration\src\com\ibm\rts\sample\build\server\impl\:
Testing: TestingRulesetBuildWork.java
Deployment: RESDeploymentBuildWork.java
The Testing task provides two main methods:
public WorkResult doWork (List parameters) throws WorkException {...}
This build profile works as follows:
Connects to Decision Center using the build profile configuration.
Executes the scenario suites:
The queries for retrieving the scenario suites to execute.
The retrieved scenario suites with the configured Rule Execution Server.
Disconnects from the server.
public boolean doAcceptWork(BuildProfile bprofile) throws WorkException {...}
This method triggers a build under the following conditions:
The time that has elapsed since the last build is greater than the configured threshold (Interval property).
The time that has elapsed since the last update, creation, or deletion of a rule artifact is more than the configured threshold (Inactivity Threshold property).
The number of updated, created, or deleted rule artifacts is greater then the configured threshold (Notification Threshold property).
The Deployment task provides two main methods:
public WorkResult doWork (List parameters) throws WorkException {...}
This build profile works as follows:
Connects to the configured Decision Center using the build profile configuration.
Deploys the RuleApp to the configured Rule Execution Server.
Disconnects from the server.
public boolean doAcceptWork(BuildProfile bprofile) throws WorkException {...}
This method triggers a build under the following conditions:
The build profile has yet to be executed that day.
The configured time for deployment has expired.
This sample is located in the <Install Directory>\teamserver\samples\servercontinuousintegration\src folder.
The sample is written to automatically manage the user interface configured for the build profiles. You simply define the metadata configuration properties in the build profile, and the configuration page handles the read, write, and delete configuration properties in the database.
The file \servercontinuousintegration\server\resources\script.sql contains the SQL statements that create the configuration metadata properties for the two predefined build profiles you use in this sample.
This sample uses the following database schema:
Table | Description |
---|---|
BUILDS | Contains all triggered builds. |
BUILD_PROFILE_PARAMETERS | Contains the value of the properties of configured build profiles. |
BUILD_PROFILE | Contains the build profiles. |
BUILD_PROJECT | Contains tuple projects and baselines that are associated with the build profiles. |
BUILD_TYPE_PARAMETERS | Contains the metadata describing the properties associated with a build profile. |
You can also view and modify the sample source files in Rule Designer. To import the sample into your workspace, click the Import projects link for the sample in the Samples and Tutorials view, and switch to the Java perspective.