Hi, I have some rules in Kie server container, Im firing rules via Kie Server client and I want to get the result objects to write them in database after rules are fired, I tried an example that I found in google but doesn't worked for me: they told I need to add the command "getObjectCommand getObjectCommand = new GetObjectCommand();" and setting an OutIdentifier to it, but if I add this to my client and run it, that gives me a null pointer exception(because of fact handler) crashing the client.
public class KieServerClient {
public KieServerClient() {
}
String user = "kieserver";
String password = "kieserver1!";
String containerId = "Container";
KieServicesConfiguration cfg = KieServicesFactory.newRestConfiguration(serverUrl, user, password);
cfg.setMarshallingFormat(MarshallingFormat.JAXB);
// configuration.setMarshallingFormat(MarshallingFormat.JAXB);
Set<Class<?>> extraClasses = new HashSet<Class<?>>();
extraClasses.add(TmEmpleados.class);
extraClasses.add(TmPres.class);
cfg.addJaxbClasses(extraClasses);
KieServicesClient kieServicesClient = KieServicesFactory.newKieServicesClient(cfg);
List<GenericCommand<?>> commands = new ArrayList<GenericCommand<?>>();
InsertObjectCommand insertObjectCommand = new InsertObjectCommand(factPresencia, "marking");
InsertObjectCommand insertObjectCommand2 = new InsertObjectCommand(factEmpleado, "employee");
GetObjectCommand getObjectCommand = new GetObjectCommand();
getObjectCommand.setOutIdentifier("f1");
FireAllRulesCommand fireAllRulesCommand = new FireAllRulesCommand();
commands.add(insertObjectCommand);
commands.add(fireAllRulesCommand);
// commands.add(getObjectCommand);
BatchExecutionCommandImpl executionCommand = new BatchExecutionCommandImpl(commands);
executionCommand.setLookup("KSESSIONAP");
String xStreamXml = MarshallerFactory
.getMarshaller(extraClasses, MarshallingFormat.JAXB,
this.getClass().getClassLoader())
.marshall(executionCommand);
RuleServicesClient ruleServicesClient = kieServicesClient.getServicesClient(RuleServicesClient.class);
ServiceResponse<String> response = ruleServicesClient.executeCommands(containerId, xStreamXml);
}
}
I was following Accelerate your bussiness tutorial but I didnt saw here the way of obtaining jaba objects from the fired rules
Currently I have workbench and kie server 6.4 and wb and server 6.3 in another machine and in both servers the client crashes when I add the "getObjectCommand" to the batch execution, does someone know what I'm doing wrong or can tell me the correct way of building a kie server client for kie server 6.4 and obtain objects from the fired rules?
I have 6.3 snapshot client dependencies maven; currently I'm not interested in JBPM, just rules
Thanks in advance, regards.