The email is big just because I tried to big as clear as possible, but it's
a quick reading, I promise!
No one?
Cheers,
Leo.
On Tue, Nov 24, 2009 at 10:42 PM, Leonardo Gomes <leonardo.f.gomes(a)gmail.com
Hello,
Regarding the session recreation, you're absolutely right, thanks!
Anyway, I still have a problem and I believe it's more a design thing. Let
me try to clarify it.
I have different types of facts, let's say:
* Types: FactA, FactB, FactC;
* A stateful session with rules operating on them;
* And a global variable, called output, which is a list of messages
generated as consequences of those rules;
* From time to time, I get notified that a fact of type FactA changed, then
I have to:
- retract all facts of type FactA from my working memory
- reload them from the database (with java beans being created)
- reinsert them in that stateful session
Now, let's say FactA(1) indicates a fact of type FactA and id = 1.
- Then, in the beginning, I insert FactA(1) and FactA(2) in my working
memory and fire the rules.
- I have several rules operating on different types of facts, but I'm
interested in one rule in particular which operates against FactA and reads
something like:
rule "test non existence"
when
not FactA( id == 4 )
then
output.add("there's no FactA id 4");
- This rule is fired and the message is added to my output object.
Later on, I have a notification that a FactA has changed, then I:
- retract all FactAs from my working memory
- clear all FactA-related messages from my output object
- reload FactAs (let's say now I have FactA(1), FactA(3), but NOT FactA(4))
- reinsert them in the WM
- fire the rules
The rule that checks that there's no FactA(4) doesn'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't get the "there no FactA id
4" message in my output.
It sounds like a situation for a stateless session, but I actually have
several different rules, operating on different types of facts and don't
want to refire all rules, just because a fact of type A changed.
Maybe I should have an strategy of creating different sets of stateless
sessions. I'm not sure. Advice is really welcome!
Thanks again.
Leo.
2009/11/17 Edson Tirelli <ed.tirelli(a)gmail.com>
> Leonardo,
>
> 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.
>
> Regarding your question, if you insert:
>
>
> SiteLanguage(language : languageCode)
> t : SiteSpecialServiceType(type : specialServiceType)
>
> The rule will activate and fire. If you don't, then the rule will not
> match. That is how it is supposed to work.
>
> Edson
>
> 2009/11/17 Leonardo Gomes <leonardo.f.gomes(a)gmail.com>
>
>> Hi Guys,
>>
>> I have the following situation while running a stateful session with
>> Drools 4.0.7:
>>
>> - I want to test that a fact with a given state doesn't exist;
>> - It works fine
>> - 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't want to
>> recreate the session b/c it's expensive
>> - Again the fact that didn't exist when I first created the session still
>> doesn't exist
>>
>> ** Problem: This time the rule that verified the non-existence is not
>> fired because I didn't insert any fact that would retrigger it.
>>
>> Rule example:
>>
>> rule "022"
>>
>> when
>>
>> SiteLanguage(language : languageCode)
>> t : SiteSpecialServiceType(type : specialServiceType)
>> not SiteLanguageSpecialServiceType(specialServiceType == type,
>> languageCode == language)
>> then
>> <<consequence>>
>> end
>>
>> How could I solve or workaround that?
>>
>>
>> Thanks in advance,
>> Leo.
>> _______________________________________________
>> rules-users mailing list
>> rules-users(a)lists.jboss.org
>>
https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>
>
>
> --
> Edson Tirelli
> JBoss Drools Core Development
> JBoss by Red Hat @
www.jboss.com
>
> _______________________________________________
> rules-users mailing list
> rules-users(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/rules-users
>
>