I suspect that the ksession defined in spring is created BEFORE the agent processes the resource. And even after the agent processes the resource, it will create a new kbase (because you are not using newInstance="false"), so the defined ksession will remain attached to an empty kbase.
Hi all,
I would like to connect to drools-server with HTTPClient with the following
config:<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:drools="http://drools.org/schema/drools-spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://drools.org/schema/drools-spring
http://anonsvn.jboss.org/repos/labs/labs/jbossrules/trunk/drools-container/drools-spring/src/main/resources/org/drools/container/spring/drools-spring-1.0.0.xsd"><drools:execution-node id="node1" /> <drools:kbase id="kbase1" node="node1"/>
<drools:kagent id="kagent1" kbase="kbase1"> <drools:resources> <drools:resource type="CHANGE_SET" source="classpath:changeset.xml" /> </drools:resources>
</drools:kagent>
<drools:ksession id="ksession1" type="stateless" kbase="kbase1" node="node1"/>
</beans>
where my changeset.xml is adding a snapshot deployed with Guvnor.
But I am not able to trig the rule with the following client:
BatchExecutionCommandImpl command = new BatchExecutionCommandImpl();
command.setLookup("ksession1");
InsertObjectCommand insertObjectCommand = new InsertObjectCommand("TEST");
FireAllRulesCommand fireAllRulesCommand = new FireAllRulesCommand();
command.getCommands().add(insertObjectCommand);
command.getCommands().add(fireAllRulesCommand);
String xml = BatchExecutionHelper.newXStreamMarshaller().toXML(command);
HttpClient httpClient = new HttpClient();
httpClient.getHostConfiguration().setHost("host", 8080);
PostMethod postMethod = new
PostMethod("/drools-5.1.1-server/kservice/rest/execute");
postMethod.setRequestEntity(new StringRequestEntity(xml, null, null));
try {
httpClient.executeMethod(postMethod);
int code = postMethod.getStatusCode();
System.out.println(code);
String rep = postMethod.getResponseBodyAsString();
System.out.println(rep);
} catch(Exception e) {...}
Do someone have any idea how to achieve this?
Thanks
Sebastien
_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users