[rules-users] Setting Non-global Input Variable in ACTION Clause

mihajlo mihajlo.jovanovic at chase.com
Tue Mar 13 10:01:08 EDT 2012


Sorry, I meant input :=)

I figured this was possible, as this is how a typical rule engine works.
However I am struggling with the correct syntax for doing this with a
decision table in Drools. I basically have a table in which I want to modify
a fact in the ACTION clause that had not been referenced in any of the
CONDITIONS, and then execute it as follows:

        public void processRules(Object... facts) {
                StatelessKnowledgeSession session = threadSession.get();
                if (session == null) {
                        logger.debug("creating/setting stateless session");
                        session =
knowledgeBase.newStatelessKnowledgeSession();
                        threadSession.set(session);
                } else {
                        logger.debug("retrieving stateless session");
                }

                List factList = new ArrayList();
                factList.addAll(Arrays.asList(facts));

                session.execute(factList);
        }

Note that this worked fine by means of declaring a global variable for the
result; however I prefer this new approach.

Thanks!


--
View this message in context: http://drools.46999.n3.nabble.com/Setting-Non-global-Input-Variable-in-ACTION-Clause-tp3820353p3822263.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list