1

In quarkus kogito, the rules(decision table) are picked from xls file in resources folder. I want to store the decision table in a database and the load the decision table from there.

@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Path("/credit") 
public class CreditResource {
```
    @Inject
    KieRuntimeBuilder runtimeBuilder;

    @POST
    @Produces(MediaType.TEXT_PLAIN)
    public Boolean getCredit(Person p) {
        String drl = ""; //assume that string drl holds what is returned from the database
        KieServices kieServices = KieServices.Factory.get();
        KieFileSystem kfs = kieServices.newKieFileSystem();
        kfs.write( "src/main/resources/org/acme/person-rules.xls", 
        kieServices.getResources().newReaderResource( new StringReader(drl) ) );
        kieServices.newKieBuilder( kfs ).buildAll();
        KieSession ksession = runtimeBuilder.newKieSession();
        ksession.insert(p);
        ksession.fireAllRules();
        return p.isApproved();

    }
}

 - List item

POJO of Person with fields: amount, credit, existing loan, approved.

But this doesn't seem to work as no rules are being fired when 

1 Answers1

2

Kogito dev here.

Currently it is not possible to pull the decision table from a DB. However, even if we implemented this feature, I don't think it would work the way you expect.

I assume you want to pull the decision table from a DB because you want to load it at run-time. However, in Kogito, preprocessing of the DT would still occur at build-time, as it happens in general with most of Kogito's capabilities; this means that if you applied changes to the DB you would not see those changes immediately, but you would still have to rebuild and redeploy you application.

Hope this answered your question.

Edoardo Vacchi
  • 1,284
  • 10
  • 18
  • It seems a bit strange for me. Business rules are supposed to be changed dynamically at runtime, Otherwise I personally prefer to use Java's if then clauses for its performance and simplicity. – Behdad Aug 11 '22 at 16:11