Execution trace sample details
This sample demonstrates how to get a simplified execution trace. To run the sample, you use the Samples Console.
Running this sample
To run the sample:
- Open the Samples Console.
- In the Samples Commands tab, expand .
- Double-click the execute command.
The command compiles the code. It first checks whether the ruleset is deployed to the Rule Execution Server database, and a ruleset parameter file is provided. Then, the command runs the ruleset to apply for a loan of 100000, asking for a full trace.
The full trace is saved as a file in the output directory. A simplified trace is also saved in a file in the output directory. The samples console shows the simplified trace.
To see a different trace, edit the application/data/paramsde.xml file to change the amount to 500000. Save the file, and run the execute command again.
You see in the output that the amount is different and that different rules are fired.
To adapt this sample to your application
- Modify the arguments that you pass to the deploy.ruleapp command, by defining them in the build.xml file. These arguments include the project import path, the server list file, and the configuration to be built and deployed.
- Modify the application/data/paramsde.xml file that specifies the input parameters in the XML format.
Rebuilding this sample
- Open the Samples Console.
- In the Samples Commands tab, expand .
- Double-click the clean command. The command compiles the code and does
the following tasks:
- Removes the RuleApp, the trace-xom resource, and the library link on Rule Execution Server.
- Removes the classes and the output directories.
Source files
You can find this sample in <InstallDir>/executionserver/samples/tracedisplay. The JavaClient.java file is the class that calls the REST API and produces the simplified trace.
- The constructor creates the
HttpClientinstance and sets the preemptive authentication. All further requests use theapiauthURL where the credentials are already given. - The
executemethod calls the REST API to run the ruleset and store the trace results in a file. It produces a trace that is less detailed than the one received in the response. - The
displayFilesmethod shows the trace. - The
cleanmethod calls the REST API to delete the RuleApp and XOM from the Rule Execution Server database.
The JavaClient class API is called by the Ant commands in the build.xml file. The server-list.xml file contains the target Rule Execution Server information for RuleApp deployment.
You can view and modify the sample source files in Rule Designer:
- Open the Samples Console.
- In the Samples and Tutorials tab, expand .
- Under Execution trace, click Import projects.
- Switch to the Java™ perspective to view and modify the projects.