[rules-users] Query in stateless knowledge session - SOLVED

Heijink, Hank heijink at audible.com
Mon Aug 1 09:49:01 EDT 2011


Mark,

Thanks for your help! I was finally able to test, and that totally worked. I was confused by example 3.37 (4.37 in the Drools 5.2.0 docs). The key point I missed must be that newStartProcess causes all the rules to fire. Well, at least I was right about it being something simple. :-)

Best,
Hank

On Jul 31, 2011, at 12:47 PM, Mark Proctor wrote:

> On 31/07/2011 17:45, Mark Proctor wrote:
>> 
>> On 31/07/2011 17:25, Heijink, Hank wrote:
>>> 
>>> Aha! I missed the line about the dispose. That makes a lot of sense. What I don't understand is why the example 3.37 in the docs would work. If I understand what you're saying, it shouldn't. 
>> It should work, as long as the query is executed as part of the same execute batch. We have unit tests f or that too somewhere.
> ok I see the problem. Your rules will not fire until the all the command shave been executed. i.e. the implicit fireAllRules() is once all commands have been executed. Which means the query will be invoked before your rule fires to insert the object.
> 
> Instead you need to add the FireAllRules command before executing the query.
> 
> Mark
>> 
>> mark
>>> 
>>> Thanks!
>>> Hank
>>> 
>>> Sent from my iPhone
>>> 
>>> On Jul 30, 2011, at 8:27 AM, "Wolfgang Laun" <wolfgang.laun at gmail.com> wrote:
>>> 
>>>> StatelessKnowledgeSession.execute(...) executes the command(s) and finally calls dispose() on the session. Use a stateful session or a global (filled with a low-salience rule) or  -  simply use the getObjects command.
>>>> -W
>>>> 
>>>> On 29 July 2011 22:47, Heijink, Hank <heijink at audible.com> wrote:
>>>> Hi all,
>>>> 
>>>> I'm new to Drools, so please excuse me if I'm asking about the obvious--it's certainly not obvious to me. The problem is this: I use a stateless knowledge session where a list of facts is inserted. The rules that fire create new facts, and after all the rules have fired, I'd like to obtain a list of all the facts (the old and the new). The best way seemed to use a query. I'm using Drools 5.1 on Linux.
>>>> 
>>>> The logger shows me that the BadgeState object is created, but the query returns an empty list. I've searched the documentation, which suggests that I'm doing it right (http://drools.herod.net/drools-expert/html/ch03.html#d0e1956, example 3.37), the archives of this mailinglist, and the web, so far without success.
>>>> 
>>>> Clearly, I'm missing something, and I have the nagging feeling that it's something simple...
>>>> 
>>>> Any help is much appreciated!
>>>> 
>>>> Best,
>>>> Hank
>>>> 
>>>> 
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>>> 
>>>> _______________________________________________
>>>> rules-users mailing list
>>>> rules-users at lists.jboss.org
>>>> https://lists.jboss.org/mailman/listinfo/rules-users
>>> 
>>> 
>>> _______________________________________________
>>> rules-users mailing list
>>> rules-users at lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/rules-users
>> 
>> 
>> 
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
> 
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20110801/32d018ac/attachment.html 


More information about the rules-users mailing list