Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
960 views
in Technique[技术] by (71.8m points)

drools - Is there a way to load decision table from database in Quarkus Kogito?

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 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...