<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I think I was not clear in my note. &nbsp;I used dynamic facts with Drools 4.07 but am migrating to Drools 5, where there is no longer a second argument to the insert method. &nbsp;My POJOs do have property change listeners.<div><br></div><div>Here is an example rule that activates but never apparently fires:</div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(0, 128, 0); "><span style="color: #960000">rule</span><span style="color: #000000"> </span>"Detect insulin on"</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(150, 0, 0); ">dialect<span style="color: #000000"> </span><span style="color: #008000">"java"</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(150, 0, 0); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">        </span></span>when</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">                </span>decision : GlucoseDecision(currentInsulinDripRate > 0)</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">                </span>decisionState : GlucoseDecisionState( insulinOn == <span style="color: #960000">false</span> )</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(150, 0, 0); "><span style="color: #000000"><span class="Apple-tab-span" style="white-space:pre">        </span></span>then</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">                </span>decisionState.setInsulinOn(<span style="color: #960000">true</span>);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(150, 0, 0); ">end</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; color: rgb(150, 0, 0); "><br></div><div><div>The relevant method that is called on the RHS:</div><div><br></div><div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span><span style="color: #7f0055">public</span> <span style="color: #7f0055">void</span> setInsulinOn(<span style="color: #7f0055">boolean</span> insulinOn) {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">                </span><span style="color: #7f0055">boolean</span> oldValue = <span style="color: #7f0055">this</span>.isInsulinOn();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">                </span><span style="color: #7f0055">this</span>.<span style="color: #0000c0">insulinOn</span> = insulinOn;</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">                </span>firePropertyChange(<span style="color: #2a00ff">"insulinOn"</span>, oldValue, insulinOn);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><font class="Apple-style-span" face="Helvetica" size="2"><span class="Apple-style-span" style="font-size: 10px;"><br></span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-style-span" style="font-family: Helvetica; font-size: 10px; ">The eventual call is to fireRules which then calls executeRules in a callback. &nbsp;Previously, I had a Boolean argument to the insert</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-style-span" style="font-family: Helvetica; font-size: 10px; ">statements and all the code worked with the old RuleBase, RuleAgent objects. &nbsp;But since changing to KnowledgeSession, the rules</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-style-span" style="font-family: Helvetica; font-size: 10px; ">do not appear to fire. &nbsp;Here are the relevant methods:</span></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><font class="Apple-style-span" face="Helvetica" size="2"><span class="Apple-style-span" style="font-size: 10px;"><br></span></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span><span style="color: #7f0055">public</span> <span style="color: #7f0055">void</span> executeRules(WorkingEnvironmentCallback callback) {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">                </span>StatefulKnowledgeSession ksession = <span style="color: #0000c0">kbase</span>.newStatefulKnowledgeSession();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">                </span>callback.initEnvironment(ksession);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">                </span>ksession.fireAllRules();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">                </span>ksession.dispose();</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><br></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span><span style="color: #7f0055">public</span> <span style="color: #7f0055">void</span> fireRules(<span style="color: #7f0055">final</span> GlucoseDecision glucoseDecision, <span style="color: #7f0055">final</span> GlucoseDecisionState decisionState) {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">                </span><span style="color: #0000c0">rulesEngine</span>.executeRules(<span style="color: #7f0055">new</span> WorkingEnvironmentCallback() {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">                        </span><span style="color: #7f0055">public</span> <span style="color: #7f0055">void</span> initEnvironment(StatefulKnowledgeSession workingMemory) {</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">                                </span>workingMemory.insert(glucoseDecision);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">                                </span>workingMemory.insert(decisionState);</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">                        </span>}</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">                </span>});</div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 11px/normal Monaco; "><span class="Apple-tab-span" style="white-space:pre">        </span>}</div></div></div></div><blockquote type="cite"><div><br>Message: 2<br>Date: Wed, 11 Feb 2009 10:26:06 -0500<br>From: Edson Tirelli &lt;<a href="mailto:tirelli@post.com">tirelli@post.com</a>><br>Subject: Re: [rules-users] Shadow facts<br>To: Rules Users List &lt;<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a>><br>Message-ID:<br><span class="Apple-tab-span" style="white-space:pre">        </span>&lt;<a href="mailto:e6dd5ba30902110726t2b09ee9dtdc7e85ed4217f80a@mail.gmail.com">e6dd5ba30902110726t2b09ee9dtdc7e85ed4217f80a@mail.gmail.com</a>><br>Content-Type: text/plain; charset="iso-8859-1"<br><br> &nbsp;&nbsp;Dean,<br><br> &nbsp;&nbsp;There are two unrelated things in here... the boolean flag for dynamic<br>facts means your fact supports the property change listeners and you don't<br>need to call modify() when you change an attribute. ShadowFacts are a<br>complete different thing that should be mostly transparent to users.<br> &nbsp;&nbsp;If you can provide an example, it will be easier to help you.<br><br> &nbsp;&nbsp;&nbsp;[]s<br> &nbsp;&nbsp;&nbsp;Edson<br><br>2009/2/11 J Michael Dean &lt;<a href="mailto:mdean77@comcast.net">mdean77@comcast.net</a>><br><br><blockquote type="cite">I am migrating from 4.07 to 5 and my previous DRL file does not function<br></blockquote><blockquote type="cite">correctly; &nbsp;I previousliy inserted facts with the dynamic Boolean set true.<br></blockquote><blockquote type="cite"> I understand that this is no longer done because shadow facts are "not<br></blockquote><blockquote type="cite">needed" in Drools 5, but is it necessary to do anything different in the RHS<br></blockquote><blockquote type="cite">when modifying facts? &nbsp;My fact POJOs have a method for adding text to<br></blockquote><blockquote type="cite">themselves. &nbsp;I believe my rules are not working properly because nothing is<br></blockquote><blockquote type="cite">being modified - only the initial activation set fires and then nothing<br></blockquote><blockquote type="cite">happens.<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Restated, the documentation talks about how to "avoid" shadow facts in<br></blockquote><blockquote type="cite">Drools 4.07 - are the restrictions in this part of the docs necessary in<br></blockquote><blockquote type="cite">Drools 5?<br></blockquote><blockquote type="cite"><br></blockquote><blockquote type="cite">Thanks.<br></blockquote><blockquote type="cite">_______________________________________________<br></blockquote><blockquote type="cite">rules-users mailing list<br></blockquote><blockquote type="cite"><a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br></blockquote><blockquote type="cite"><a href="https://lists.jboss.org/mailman/listinfo/rules-users">https://lists.jboss.org/mailman/listinfo/rules-users</a><br></blockquote><blockquote type="cite"><br></blockquote></div></blockquote></div></div></body></html>