Hello,<br><br>I've been trying out the Spring integration package in Drools 5.1.1 and it works really well, but I have run into one issue I can't figure out.<br><br>I've defined 2 knowledge sessions from the same knowledge base in the app context - one stateless, one stateful but otherwise identical. They both refer to a collaborator defined as a bean in the app context which is to be used as a global in my rules. This is just an excerpt of my full Spring context, the kbase definition itself is not an issue.<br>
<br><bean id="applicantDao" class="com.acme.app.dao.impl.ApplicantDaoImpl" /><br><br><drools:ksession id="statelessKSession" type="stateless" name="statelessKSession" kbase="kbase"><br>
<drools:script><br> <drools:set-global identifier="applicantDao" ref="applicantDao" /><br> </drools:script><br> </drools:ksession><br> <br> <drools:ksession id="statefulKSession" type="stateful" name="statefulKSession" kbase="kbase"><br>
<drools:script><br> <drools:set-global identifier="applicantDao" ref="applicantDao" /><br> </drools:script><br> </drools:ksession><br><br>The issue is that this configuration works for the stateful but not the stateless session, in the sense that the stateful session appears to have a valid reference to the applicantDao object in the Globals object but the stateless session doesn't.<br>
<br>@Test<br>public void testStatelessGlobal() {<br> Globals globals = statelessKSession.getGlobals();<br> Object global = globals.get("applicantDao");<br> Assert.assertNotNull(global);<br> }<br>
<br>@Test<br>public void testStatefulGlobal() {<br> Globals globals = statefulKSession.getGlobals();<br> Object global = globals.get("applicantDao");<br> Assert.assertNotNull(global);<br>
}<br><br>The first test fails (the global variable is null) but the second passes. No errors are thrown by Drools during the setup of the Spring container.<br><br>What am I doing wrong? Should I be able to define globals in this way for stateless sessions? The XSD seems to indicate this is a valid configuration, but it just doesn't work.<br>
<br>Is anyone else working with the Spring integration that can point out my error here?<br><br>Many thanks, <br><br>Patrick<br>