Sample Application Setup
Phase 3: Miniloan Sample Application Rules
Now that ODM is deployed, we will implement a decision service that externalizes loan approval logic, allowing rules to be updated without redeploying application code. For this example, a sample app called mini loan will be used to demonstrate the process.
3.1 Download Sample App Files
Download the Miniloan Service.zip and execution-payload.json from the following repo.
3.2 Import the Miniload Decision Service
Open the Decision Center Business console as admin user
Click Choose to browse and then select the
Miniloan Service.zipfile you previously downloaded (MiniLoan Service.zip).Make sure Use Decision Governance Framework is not selected. For this test we will work with an ungoverned branch of the decision service.
Click Import. The Miniloan Service decision service automatically opens. You see the Releases and Branches tabs. Because you chose not to use the decision governance framework, you can see that the Releases tab is empty.
Open the Branches tab, and then click the main branch. A decision service can contain many projects. For simplicity, all the rules of Miniloan Service are contained in its top-level project, which has the same name as the decision service.
Click All types in the Types window to display all the artifacts. In the Decision Artifacts tab, you can see a folder for the decision operations, the miniloan ruleflow, and folders that contain the rules:
3.3 Deploy Miniloan RuleApp
Click the Deployments tab to see its contents.
Click the Miniloan deployment configuration.
Click the Edit button in the upper right corner of the window.
Click the Targets tab.
Check that Decision Service Execution is selected and click the Save button.
Type “Miniloan policy”, and click Create new version.
Click the Deploy button
in the upper right corner of the window. A dialog box opens with a summary of the deployment configuration. It gives you the option of deploying to a server or creating a RuleApp archive.Leave Server selected in the dialog, and click Deploy.
Click OK in the deployment status message. The Reports subtab opens in the Deployments tab.
Click the name of the report when its status shows a check mark. The report opens and shows a summary of the deployment. It includes the target server, the configuration name, the ruleset, the deployment time, the version of the ruleset, and the deployment snapshot.
3.4 Verify in Res
Go to bash https://<your-host>/res
Option A: RES Test UI
Click the Explorer tab.
Expand RuleApps at the left-hand sidebar, and then expand /mydeployment/1.0.
Click /Miniloan_ServiceRuleset/1.0 to view the details of the ruleset in the Ruleset View.
Click Test ruleset
Switch execution request to JSON and paste the payload from execution-payload.json
{"loan": { "amount": 500000, "duration": 240, "yearlyInterestRate": 0.05 }, "__DecisionID__": "Test", "borrower": { "name": "Joe", "creditScore": 600, "yearlyIncome": 80000 }}
- Click Execute Request
Option B: API Call
You can also test the execution of the Miniloan_ServiceRuleset ruleset in a command terminal by using cURL
curl -k https://<your-host>/DecisionService \
-H "Content-Type: application/json" \
-d @execution-payload.jsonor
curl -k -X POST -H "Content-Type: application/json" \
-u <adminUser>:<adminPwd> -d "@execution-payload.json" \
https://<yourHost>/DecisionService/rest/v1/mydeployment/1.0/Miniloan_ServiceRuleset/1.0/Expect a result like
{"__DecisionID__":"Test","loan":{"amount":500000,"duration":240,"yearlyInterestRate":0.05,"yearlyRepayment":39597,"approved":false,"messages":["Too big Debt-To-Income ratio"]}}