I can not fire a rule from jbpm business rule task. It seems that process not found rule file. Try to explain.
First, I extend a Drools example adding a business rule task in witch I set a ruleFlowGroup:
This is properties for business rule task Rule1:
The processTest.java simple set Message and start process:
package com.sample;
import org.kie.api.KieServices;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;
import com.sample.DroolsTest.Message;
/**
* This is a sample file to launch a process.
*/
public class ProcessTest {
public static final void main(String[] args) {
try {
// load up the knowledge base
KieServices ks = KieServices.Factory.get();
KieContainer kContainer = ks.getKieClasspathContainer();
KieSession kSession = kContainer.newKieSession("ksession-process");
// go !
Message message = new Message();
message.setMessage("Hello Giorgio");
message.setStatus(Message.HELLO);
kSession.insert(message);
// start a new process instance
kSession.startProcess("com.sample.bpmn.hello");
} catch (Throwable t) {
t.printStackTrace();
}
}
}
Then I run and it fire correctly the script task ("Hello world") but non found rules in RuleGroup1.drl:
//created on: 21-gen-2019
package com.sample
//list any import classes here.
import com.sample.DroolsTest.Message;
//declare any global variables here
rule "First Giorgio rule"
ruleflow-group "Group1"
when
m : Message( status == Message.HELLO, myMessage : message )
then
System.out.println( "rule0 Group1" );
end
rule "Your First Rule"
ruleflow-group "Group1"
when
//conditions
then
System.out.println( "rule1 Group1" );
end
rule "Your Second Rule"
ruleflow-group "Group1"
//include attributes such as "salience" here...
when
//conditions
then
System.out.println( "rule2 Group1" );
end
Follow Project folders:
Thanks for your help.