<div dir="ltr">Hi metatech,<div><br></div><div>Thanks for the response. Yes, I agree that my naive approach wouldn't work due to the disposal of the commands but I think your approach would. As it happens, I plan to use Spring and Drools together in a future project so will try to check out your patch... although ironically I tend not to use the XML configuration for Spring any more, preferring the annotation-driven approach!</div>
<div><br></div><div style>Cheers,</div><div style><br></div><div style>Patrick</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jan 15, 2013 at 9:00 AM, metatech <span dir="ltr"><<a href="mailto:metatechbe@gmail.com" target="_blank">metatechbe@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">drools_global_stateless.diff<br>
<<a href="http://drools.46999.n3.nabble.com/file/n4021534/drools_global_stateless.diff" target="_blank">http://drools.46999.n3.nabble.com/file/n4021534/drools_global_stateless.diff</a>><br>
<br>
<br>
Patrick van Kann wrote<br>
<div class="im">> So my questions are:<br>
> 1) Is this the intended behaviour or a bug? On reflection, I am now not<br>
> sure<br>
> the idea of a "batch/script" makes sense for a StatelessKnowledgeSession<br>
> since execute() is a one-shot method and any globals set this way would<br>
> not<br>
> be available to later executions, which is what I was looking for.<br>
> 2) If so, should the XSD be changed to disallow the batch element within a<br>
> stateless session (difficult, given that this is determined via the "type"<br>
> attribute) or should the documentation simply warn people that the<br>
> <spring:batch><br>
> element doesn't do anything if you set the type attribute to<br>
> stateless (somewhat confusing, I suppose)<br>
> 3) If not, should the code above be added to the<br>
> StatelessKnowledgeSessionBeanFactory.internalAfterPropertiesSet() method?<br>
> 4) Should there be another way to declare a global that isn't through the<br>
> batch element (one that would cause globals to be set via the<br>
> setGlobal(String, Object) method rather than using the SetGlobalCommand<br>
> via<br>
> the execute() method.<br>
<br>
</div>Patrick,<br>
<br>
I was also interested in making this feature work, so I had a look.<br>
The code you suggest is a good start, but is not enough : as you suggest,<br>
the setGlobal method has to be called.<br>
My understanding is that all executions on a stateless sessions are<br>
stateless, including the commands. Which means, if you execute commands,<br>
the session will be "disposed" at the end, which undoes the command<br>
executions. The answer to your questions 1, 3 and 4 is "Yes" I think.<br>
See the attachment for a working patch.<br>
<br>
Regards,<br>
<br>
metatech<br>
<br>
P.S. : I know this answer comes 2 years after your question, but maybe other<br>
people will look for a solution in the future.<br>
<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Re-Question-about-Drools-Spring-StatelessKnowledgeSession-and-globals-tp1857252p4021534.html" target="_blank">http://drools.46999.n3.nabble.com/Re-Question-about-Drools-Spring-StatelessKnowledgeSession-and-globals-tp1857252p4021534.html</a><br>
Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br></div>