Example
Below is an example showing how Business Rules can be called from ETL, the flow of the logic defined by the rules and also how a rule calls an ETL chain.
Create Business Rules
Business logic has been defined with flows between the rules. The rules are created with ETL chains selected in their properties.
The required set of ETL chainsets are already configured.
In the properties of the rule “Is Junior”, the “On Entry” field selects the “ComputerAndBinAge” ETL chain. The “On True” field selects “NoJuniors” ETL chain and no ETL chain for “On False” field.
When the rule is triggered, the “ComputerAndBinAge” ETL chain will run. If the logic returns true, the ETL chain selected in “On True” will run, otherwise no ETL will run (“On False” is empty).
The “ComputerAndBinAge” ETL chain does the following:
It computes the ages in years and then classifies into either Junior, Adult or Senior and returns the result in “AgeClassification” output field. This record (with the additional field) becomes the record which flows through the rest of the rules.
In the “Logic” field of the property for the rule, the Decision states a statement, in this case, “AgeClassification” is “Junior”.
The output is always either true or false. Other operations, such as “and”, “Or” and “Not” can be combined with the Decision to create the statement required.
If the result returns true, the “NoJuniors” ETL chain runs and the output goes to the rule “Completed”. Else the logic moves to “Is Senior” rule.
The “NoJuniors” ETL chain is a simple JSON ETL step which just adds some fields to the record.
{
"accepted: false,
"message": "Please try again whn you are 18"
}
The “Is Senior” rule is as follows:
When triggered, it calls “GetCreditScore” ETL chain, which calls an external credit scoring agency to get a credit score. The “Logic” field has the following logic:
If it returns true, move to “Good Credit” rule, else move to “High Salary” rule. If it is moved to the “Good Credit” rule, and if the logic in the rule returns true, the flow will goes to the “Completed” rule with the JSON record in its logic.
The end result is one record out for each record in. The record emitted will contain any additional fields and values added to the record by the ETL chains that are invoked as it passes through the particular series of decision points governed by the rules. It is now possible for downstream logic to decide how to respond to the request, based on the “accepted” and “message” values that the business rules have defined - for example by sending out a rejection email with a reason.