conf.configure(grid);
GridServiceDescription<GridNode> n1Gsd = grid.get(WhitePages.class).lookup("n1");
GridConnection<GridNode> conn = grid.get(ConnectionFactoryService.class).createConnection(n1Gsd);
GridNode remoteN1 = conn.connect();
KnowledgeBuilderConfiguration kbuilderConf = remoteN1.get(KnowledgeBuilderFactoryService.class).newKnowledgeBuilderConfiguration();
KnowledgeBuilder kbuilder = remoteN1.get(KnowledgeBuilderFactoryService.class).newKnowledgeBuilder(kbuilderConf);
System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^Building Resources Remotely");
kbuilder.add(new ByteArrayResource(IOUtils.toByteArray(new ClassPathResource("processes/procedures/DumbProcedure.bpmn").getInputStream())), ResourceType.BPMN2);
System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^Finish Building Resources Remotely");
KnowledgeBuilderErrors errors = kbuilder.getErrors();
if (errors != null && errors.size() > 0) {
for (KnowledgeBuilderError error : errors) {
System.out.println(">>>>>>> Error: " + error.getMessage());
}
throw new IllegalStateException("Failed to parse knowledge!");
}
System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^Configure Remote KBASE");
KnowledgeBaseConfiguration kbaseConf = remoteN1.get(KnowledgeBaseFactoryService.class).newKnowledgeBaseConfiguration();
kbaseConf.setOption(EventProcessingOption.STREAM);
KnowledgeBase kbase = remoteN1.get(KnowledgeBaseFactoryService.class).newKnowledgeBase(kbaseConf);
kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^Finishing Configure Remote KBASE");
StatefulKnowledgeSession session = kbase.newStatefulKnowledgeSession();
System.out.println("^^^^^^^^^^^^^^^^^^^^^^^^Registering Session");
remoteN1.set("DumbProcedureSession" + this.callId, session);
return session;
// System.out.println("Starting Local Session because Remote takes to long!!!");
// KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();