Option to check rules before rule execution

Skip to first unread message

Bharath Ananth

Jun 25, 2021, 7:32:54 AMJun 25
to OpenRules
Hi Team,

Is there an option within OpenRules that allows us to check what rules exist before even executing the rules-engine or do we need to write our own custom HTTP endpoint to achieve this?

For ex: For our use-case, we have defined rules based on countries, so if i give some country names input, would i be able to get all the rules for that country from the Decision tables through a GET/POST call?



Jun 25, 2021, 8:32:54 AMJun 25
to OpenRules
Hi Bharath,

It's a quite typical situation for rules-based systems. Look at your use case description. The logic for checking rules existence is business logic as well, so it should be inside the decision model which you invoke via your endpoint. The very first table in the decision model should check if the provided country can be handled by the existing rules. If not, it should return a negative result (using a predefined decision variable) with the proper explanation. We have a customer that supports different document processing logic for different countries classified into some groups. They also have rules for countries which do not belong to any group, and it's not always a rejection but some default processing logic. The point it that it is still the business (!) logic and it should be presented inside your decision service. If you are afraid that the invocation of your main decision service is too expensive you may create a separate small decision service that finds which service could handle this particular country and automatically invoke this service - see Service Orchestration. If you need help presenting your "rules existence" logic, contact us at sup...@openrules.com.


Bharath Ananth

Jul 5, 2021, 10:16:57 AMJul 5
to OpenRules
Thanks, that clarifies things to a certain degree. Staying on the topic of rules per country, i want to deploy these country specific rules to individual lambda

Lambda 1 -> Country 1
Lambda 2 -> Country 2..etc

Given, i need to execute my project under a single repo in a CI/CD pipeline, Given this, how should i organize my project structure
Do i just create a rules folder and plugin country specific rules in individual folders? Could all the .mvnw wrapper (build/test/scripts to deploy to Lambda) reside in the parent directory. I suppose a for loop inside each .mvnw script is then needed to traverse all the country specific subdirectories.

I know this could be more of a java mvn question, than openrules, but would you have an example highlighting this, more in terms of CI/CD deployment, if so that would be great.



Jul 5, 2021, 10:23:06 AMJul 5
to OpenRules

There are multiple options for organizing and deploying your decision project. Here is the one with one decision model for all countries deployed as one Lambda.

Your project may look similar to any sample project like VacationDays. A possible structure of your rules repository:

  • rules
    • Main
      • MainDecision.xls
      • SelectCountryRules.xls
    • Common
      • Glossary
        • Glossary.xls
      • RulesCommonForAllCountries
        • CommonRules.xls
        • InputValidationRules.xls
    • Country1 – specific for Country 1
      • RulesCountry1.xls
    • Country2 – specific for Country 2
      • RulesCountry2.xls
    • CountryGroup1
      • RulesCountryGroup1
  • Test
    • Country1 – tests specific for Country 1
      • TestCountry1.xls
    • Country2 – specific for Country 2
      • TestCountry2.xls

Your MainDecision.xls may start with running some common rules (like InputValidationRules.xls) that will set the variable “Input Validation Result”. If Input Validation Result is SUCCESS then it will execute CommonRules and SelectCountryRules (a multi-hit decision table). We assume that Country is your input variable.  For different countries, you use ActionExecute to invoke the proper rule like RulesCountry1. This schema may work fine at least for the start.

If you find out that some rules require too much data going through the network, you may create a separate country-specific project and deploy it as a separate Lambda. Then you may invoke this Lambda from the same table SelectCountryRules just using already mentioned Service Orchestration. Contact us if you have specific questions and we will help.

OpenRules Support

Reply all
Reply to author
0 new messages