PMD
PMD

Reputation: 51

Is it mandatory to use Drools KIE execution server to fire a rule?

All, Is it mandatory to use Drools KIE execution server to fire a rule ? What about passing the required data to a Rules jar as a standalone approach instead of REST ?

Upvotes: 2

Views: 723

Answers (1)

Esteban Aliverti
Esteban Aliverti

Reputation: 6322

There is no need at all to use the Kie Execution Server, no. Following Drools' User Guide you can learn how to create a Kie Container in Java and how to get a Kie Session from it.

For example, if you have your rules in your classpath, you can try something like this:

KieServices kieServices = KieServices.Factory.get();
KieContainer kContainer = kieServices.getKieClasspathContainer();

KieSession kSession = kContainer.newKieSession();
Applicant applicant = new Applicant( "Mr John Smith", 16 );    
ksession.insert( applicant );
ksession.fireAllRules();

Once you have your session, you can start feeding it some facts and exercising its rules.

Hope it helps,

Upvotes: 2

Related Questions