[rules-users] Question about Drools Spring, StatelessKnowledgeSession and globals

Patrick van Kann pvankann at gmail.com
Sat Jan 26 07:04:39 EST 2013


Hi metatech,

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!

Cheers,

Patrick


On Tue, Jan 15, 2013 at 9:00 AM, metatech <metatechbe at gmail.com> wrote:

> drools_global_stateless.diff
> <
> http://drools.46999.n3.nabble.com/file/n4021534/drools_global_stateless.diff
> >
>
>
> Patrick van Kann wrote
> > So my questions are:
> > 1) Is this the intended behaviour or a bug? On reflection, I am now not
> > sure
> > the idea of a "batch/script" makes sense for a StatelessKnowledgeSession
> > since execute() is a one-shot method and any globals set this way would
> > not
> > be available to later executions, which is what I was looking for.
> > 2) If so, should the XSD be changed to disallow the batch element within
> a
> > stateless session (difficult, given that this is determined via the
> "type"
> > attribute) or should the documentation simply warn people that the
> > <spring:batch>
> >  element doesn't do anything if you set the type attribute to
> > stateless (somewhat confusing, I suppose)
> > 3) If not, should the code above be added to the
> > StatelessKnowledgeSessionBeanFactory.internalAfterPropertiesSet() method?
> > 4) Should there be another way to declare a global that isn't through the
> > batch element (one that would cause globals to be set via the
> > setGlobal(String, Object) method rather than using the SetGlobalCommand
> > via
> > the execute() method.
>
> Patrick,
>
> I was also interested in making this feature work, so I had a look.
> The code you suggest is a good start, but is not enough : as you suggest,
> the setGlobal method has to be called.
> My understanding is that all executions on a stateless sessions are
> stateless, including the commands.  Which means, if you execute commands,
> the session will be "disposed" at the end, which undoes the command
> executions.  The answer to your questions 1, 3 and 4 is "Yes" I think.
> See the attachment for a working patch.
>
> Regards,
>
> metatech
>
> P.S. : I know this answer comes 2 years after your question, but maybe
> other
> people will look for a solution in the future.
>
>
>
>
> --
> View this message in context:
> http://drools.46999.n3.nabble.com/Re-Question-about-Drools-Spring-StatelessKnowledgeSession-and-globals-tp1857252p4021534.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20130126/3005d21f/attachment.html 


More information about the rules-users mailing list