| Samples > Rule-Based Programming > How to Process a Large Number of Objects |
How to Process a Large Number of Objects |
PREVIOUS NEXT |
This sample shows how ILOG JRules can be adapted or configured to fit some cases where performance is crucial. The scenario executes a simple cashback computation process involving accounts and a very large number of credit card events per account.
Key features include:
FinderFinancialEventFactoryImpl.findByAccountId(String accountID) finder is called by the collect condition of some rules. Its purpose is to return a list of correct objects (in the case of this sample, the events attached to an account) and prevent exhaustive and costly iterations required to compute join conditions on large numbers of objects. A finder generally enables you to avoid inserting these objects into the engine's working memory.
CashEventCollector extends IlrDefaultCollector which is used in the collect condition to carry the collection to be returned. This specific collector publishes additional methods (getTotalAmount and getAverageAmount) available in some rule conditions. This allows these computations to be shared at the condition level in the RetePlus and then prevents them from being executed in the actions of several rules.
To import the manyobjects sample:
samples > engine > manyobjects sample.
Make sure you are in the Rule perspective before running this sample.
To run the sample:
Java Application With Rules > manyobjects-application launch configuration.
The rule project manyobjects-rules contains the ruleset to be executed. An ilrmain function creates and inserts objects in the working memory and executes the ruleset. The rule execution output is displayed in the Rule Studio Console.
An engine.conf file is used to activate the useFinders option to assist with rule execution.
For each account to be processed:
This sample uses the flexibility of ILOG JRules to solve the problem. It provides ways to perform efficient pattern matching on many objects using ruleflow, finders, and collectors.
The rule project contains:
ilrmain function that creates objects for simulation, and then executes for each account object
Rules are applied on a set of instances of several classes. This object model is a simple model made of few interfaces, implementation classes, and factories. It is referenced from the financialevent-xom Java project.
At runtime, the sample processes all the created accounts and logs information on the console. A large number of cash events are processed in a short time, and accounts are granted a REFUND computed with the rule-based rate. By default, 50,000 events are processed on 20 accounts (giving 1,000,000 possible combinations). The Java application provided in this sample is pre-configured to raise the maximum Java Virtual machine memory in order to successfully process this many combinations.
| Copyright © 1987-2008 ILOG S.A. All rights reserved. Legal terms. Documentation homepage. | PREVIOUS NEXT |