简体   繁体   中英

Execute Drools process flow with multiple business rules added from POJO

I have created one process-sampleFlow.bpmn2 ( a sample rule added in the business task ) , and the same process is defined in kModule.xml. Now in a simple pojo class from main method with kieContainer it is able to initiate the process and triggers the associated rule. but only when the rules and process is being kept under the same package. Not sure if I am missing anything.

POJO Class :

KieServices ks = KieServices.Factory.get();
                KieContainer kContainer = ks.getKieClasspathContainer();
                KieSession kSession = kContainer.newKieSession("ksession-process");
                Participant request = new Participant();
                request.id="123";
                kSession.insert(request);
                kSession.startProcess("defaultPackage.sampleRuleFlow");
                kSession.fireAllRules();

kModule.xml

<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule">
  <kbase name="process" packages="process">
        <ksession name="ksession-process"/>
    </kbase>
</kmodule>

Rule :

rule sample1
ruleflow-group "group1"
when 
then 
System.out.println( "Sample1" );
end


rule sample2
ruleflow-group "group2"
when 
then 
System.out.println( "Sample2" );
end

Thanks in advance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM