use of org.drools.event.rule.DebugAgendaEventListener in project jBPM5-Developer-Guide by Salaboy.
the class TaskListJFrame method createSession.
// End of variables declaration//GEN-END:variables
private StatefulKnowledgeSession createSession() {
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
// Adds resources to the builder
kbuilder.add(new ClassPathResource("rules/SimpleRulesAndTask.drl"), ResourceType.DRL);
KnowledgeBuilderErrors errors = kbuilder.getErrors();
// Checks for errors
if (errors.size() > 0) {
for (KnowledgeBuilderError error : errors) {
System.out.println(error.getMessage());
}
throw new IllegalStateException("Error building kbase!");
}
// Creates a new kbase and add all the packages from the builder
KnowledgeBaseConfiguration kbaseConf = KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
kbaseConf.setOption(EventProcessingOption.STREAM);
KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase(kbaseConf);
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
StatefulKnowledgeSession myksession = kbase.newStatefulKnowledgeSession();
HornetQHTWorkItemHandler hornetQHTWorkItemHandler = new HornetQHTWorkItemHandler(myksession);
myksession.getWorkItemManager().registerWorkItemHandler("Human Task", hornetQHTWorkItemHandler);
KnowledgeRuntimeLoggerFactory.newConsoleLogger(myksession);
myksession.addEventListener(new DebugAgendaEventListener());
return myksession;
}
Aggregations