<div dir="ltr">hi ,<br>i m new in drools, i m reading the Drools-JBoss-Rules-5.0-Developers-Guide book in which i found a validation rule example on its chapter 3. In this exemple, global variables were set into the session with two methods shown in this code : <br>
<br>...<br>session = knowledgeBase.newStatelessKnowledgeSession();<br>    session.setGlobal(&quot;reportFactory&quot;, reportFactory);<br>    session.setGlobal(&quot;inquiryService&quot;, inquiryService);<br>...<br><br>and these variables <span id="result_box" class="short_text" lang="fr"><span class="hps">qualified</span></span> as immutables, were called from the RuleContext <br>
<br>public static void error(RuleContext drools,<br>      Object... context) {<br> KnowledgeRuntime knowledgeRuntime = drools<br>        .getKnowledgeRuntime();<br>    ValidationReport validationReport = (ValidationReport) <br>
        knowledgeRuntime.getGlobal(&quot;validationReport&quot;);<br>    ReportFactory reportFactory = (ReportFactory) <br>        knowledgeRuntime.getGlobal(&quot;reportFactory&quot;);<br>...<br><br>and for other variables(or facts ) the Command interface was used instead :<br>
<br> List&lt;Command&gt; commands = new ArrayList&lt;Command&gt;();<br>    commands.add(CommandFactory.newSetGlobal(<br>        &quot;validationReport&quot;, report));<br>    commands.add(CommandFactory<br>        .newInsertElements(getFacts(customer)));<br>
    session.execute(CommandFactory<br>        .newBatchExecution(commands));<br><br>i m looking for accuracy in understanding when and which to use each method. <br><br></div>