The email is big just because I tried to big as clear as possible, but it&#39;s a quick reading, I promise!<br><br>No one?<br><br>Cheers,<br>Leo.<br><br><div class="gmail_quote">On Tue, Nov 24, 2009 at 10:42 PM, Leonardo Gomes <span dir="ltr">&lt;<a href="mailto:leonardo.f.gomes@gmail.com">leonardo.f.gomes@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hello,<br><br>Regarding the session recreation, you&#39;re absolutely right, thanks!<br><br>
Anyway, I still have a problem and I believe it&#39;s more a design thing. Let me try to clarify it.<br><br>I have different types of facts, let&#39;s say:<br>
<br>* Types: FactA, FactB, FactC;<br>* A stateful session with rules operating on them;<br>* And a global variable, called output, which is a list of messages generated as consequences of those rules;<br>* From time to time, I get notified that a fact of type FactA changed, then I have to:<br>

  - retract all facts of type FactA from my working memory<br>  - reload them from the database (with java beans being created)<br>  - reinsert them in that stateful session<br><br>Now, let&#39;s say FactA(1) indicates a fact of type FactA and id = 1.<br>

<br>- Then, in the beginning, I insert FactA(1) and FactA(2) in my working memory and fire the rules.<br>- I have several rules operating on different types of facts, but I&#39;m interested in one rule in particular which operates against FactA and reads something like:<br>

<br>rule &quot;test non existence&quot;<br>when<br>    not FactA( id == 4 )<br>then<br>    output.add(&quot;there&#39;s no FactA id 4&quot;);<br><br>- This rule is fired and the message is added to my output object.<br><br>

Later on, I have a notification that a FactA has changed, then I:<br>- retract all FactAs from my working memory<br>- clear all FactA-related messages from my output object<br>- reload FactAs (let&#39;s say now I have FactA(1), FactA(3), but NOT FactA(4))<br>

- reinsert them in the WM<br>- fire the rules<br><br>The rule that checks that there&#39;s no FactA(4) doesn&#39;t refire. All other rules operating against FactA do, and since I had removed all FactA-related messages from my output object, this time I don&#39;t get the &quot;there no FactA id 4&quot; message in my output.<br>

<br>It sounds like a situation for a stateless session, but I actually have several different rules, operating on different types of facts and don&#39;t want to refire all rules, just because a fact of type A changed.<br>

<br>Maybe I should have an strategy of creating different sets of stateless sessions. I&#39;m not sure. Advice is really welcome!<br><br>Thanks again.<br><br>Leo.<br><br><br><br><br><br><br><br><br><br><br><div class="gmail_quote">

2009/11/17 Edson Tirelli <span dir="ltr">&lt;<a href="mailto:ed.tirelli@gmail.com" target="_blank">ed.tirelli@gmail.com</a>&gt;</span><div><div></div><div class="h5"><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<br>   Leonardo, <br><br>   First, I believer there is a misconception in your reasoning: creating sessions is supposed to be much much cheaper than retracting all facts. Creating a rulebase is heavier, because it requires compilation, but creating a session is supposed to be very light by design. So, first thing you should do is change that.<br>


<br>   Regarding your question, if you insert:<div><br><br>SiteLanguage(language : languageCode)<br>                t : SiteSpecialServiceType(type : specialServiceType)<br><br></div>   The rule will activate and fire. If you don&#39;t, then the rule will not match. That is how it is supposed to work.<br>


<br>   Edson<br><br><div class="gmail_quote">2009/11/17 Leonardo Gomes <span dir="ltr">&lt;<a href="mailto:leonardo.f.gomes@gmail.com" target="_blank">leonardo.f.gomes@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">

<div><div></div><div>
Hi Guys,<br><br>I have the following situation while running a stateful session with Drools 4.0.7:<br><br>- I want to test that a fact with a given state doesn&#39;t exist;<br>- It works fine<br>- At a certain point I have to retract all facts and reinsert them at the stateful session - some of them actually changed and I don&#39;t want to recreate the session b/c it&#39;s expensive<br>



- Again the fact that didn&#39;t exist when I first created the session still doesn&#39;t exist<br><br>** Problem: This time the rule that verified the non-existence is not fired because I didn&#39;t insert any fact that would retrigger it.<br>



<br>Rule example:<br><br> rule &quot;022&quot;<br><br>        when<br><br>                SiteLanguage(language : languageCode)<br>                t : SiteSpecialServiceType(type : specialServiceType)<br>                not SiteLanguageSpecialServiceType(specialServiceType == type, languageCode == language)<br>



        then<br>                 &lt;&lt;consequence&gt;&gt;<br>end<br><br>How could I solve or workaround that?<br><br><br>Thanks in advance,<br>Leo.
<br></div></div>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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>
<br></blockquote></div><font color="#888888"><br><br clear="all"><br>-- <br>  Edson Tirelli<br>  JBoss Drools Core Development<br>  JBoss by Red Hat @ <a href="http://www.jboss.com" target="_blank">www.jboss.com</a><br>
</font><br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">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>
<br></blockquote></div></div></div><br>
</blockquote></div><br>