Hello,
I've got the following basic code that sets up drools in STREAM mode, with a pseudo
clock.
And it fails on the last line that asserts there is an entrypoint named
"testEntryPoint".
The DRL file references the entry-point which according to the documentation is enough.
What am I missing?
Itai
declare Message
@role(event)
@timestamp(timestamp)
end
declare AppInfo
@role(event)
@timestamp(timestamp)
end
rule "Change message type after one minute"
dialect "mvel"
when
$appinfo:AppInfo() from entry-point "testEntryPoint"
$message:Message( type == "before", $msgtext : msgtext, this after[ 1m ]
$appinfo )
from entry-point "testEntryPoint"
then
System.out.println( $msgtext );
modify ( $message ) {
type = "after"
}
end
private void initDrools() {
KnowledgeBaseConfiguration config =
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
// Stream mode allows interacting with the clock (Drools Fusion)
config.setOption(EventProcessingOption.STREAM);
kbase = KnowledgeBaseFactory.newKnowledgeBase(config);
kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
// this will parse and compile in one step
kbuilder.add(ResourceFactory.newClassPathResource(RULE_FILE,
DroolsExpertTest.class), ResourceType.DRL);
// Check the builder for errors
assertThat(kbuilder.hasErrors())
.overridingErrorMessage(kbuilder.getErrors().toString())
.isFalse();
// get the compiled packages (which are serializable)
Collection<KnowledgePackage> pkgs = kbuilder.getKnowledgePackages();
// add the packages to a knowledgebase (deploy the knowledge packages).
kbase.addKnowledgePackages(pkgs);
KnowledgeSessionConfiguration conf =
KnowledgeBaseFactory.newKnowledgeSessionConfiguration();
conf.setOption(ClockTypeOption.get("pseudo"));
ksession = kbase.newStatefulKnowledgeSession(conf,null);
clock = ksession.getSessionClock();
entryPoint = ksession.getWorkingMemoryEntryPoint("testEntryPoint");
assertThat(entryPoint).isNotNull();
}
Show replies by date