[rules-users] Separate selectable drl files in drools kbase.. Or agenda groups

Ramon Buckland ramon at thebuckland.com
Wed Jun 5 05:03:08 EDT 2013


Hi Wolfgang, 

Thanks for the suggestions. I have a few questions, does changing the focus on the RHS work like :

kcontext.getKnowledgeRuntime().getAgenda().getAgendaGroup( "B to D" ).setFocus();

Do I need to import kcontext ? or is it implicitly in scope already ?

> a low salience rule would set
> the AG for the Spartan group and so on.

As I understand it, salience helps the engine decide "which" rule to run, when one or more matches, but does that mean identical factors ,, 
or just any that are applicable ? 

Will the below example work ? Will "b only" fire last like I want it to ?

class Foo { boolean a; boolean b; }

(object inserted has a and b == true), Agenda-group Focus is set to "Intialisation"

---
rule "a only"
agenda-group "Initialisation"
salience 10
when 
     Foo (a == true)
then 
     …
end

rule "a and b"
agenda-group "Initialisation"
salience 5
when 
     Foo (a == true, b == true)
then 
     …
end

rule "b only"
agenda-group "Initialisation"
salience 1
when 
     Foo (b == true)
then 
    kcontext.getKnowledgeRuntime().getAgenda().getAgendaGroup( "WorkerGroup" ).setFocus();
end

Many thanks
Ramon

Ramon Buckland
ramon at thebuckland.com



On 5 Jun 2013, at 06:47, Wolfgang Laun <wolfgang.laun at gmail.com> wrote:

> You can change the focus on the RHS of a rule as well, using the API.
> Starting in the default agenda group, a low salience rule would set
> the AG for the Spartan group and so on.
> 
> Notice that any attribute can be set in front of or in between rules to
> become effective in successive rules. This should also work in XLS,
> except that you may have to create three files for your three groups.
> (The XLS parser isn't very intelligent, at least wasn't last time I was
> looking.)
> 
> -W
> 
> 
> On 04/06/2013, Ramon Buckland <ramon at thebuckland.com> wrote:
>> Hi,
>> 
>> I am using a Stateless Knowledge session backed behind a web rest api.
>> The rest api is provided by spring Mvc, so I have a stateless ksession
>> injected in.
>> 
>> As it is stateless, I have found it difficult to use agenda groups to
>> meet my need. And have a question to how I set this up.
>> 
>> My task.
>> In short, I have 10 or so set up rules (init rules), then a 300 odd
>> (work) rules, then I need to fire a few (5) (finalisation) rules.
>> 
>> They need to be processed in that order. If I were using stateful I
>> see how an agenda group solves that need.. In the calling java that is
>> nice. setFocus().. But stateless blocks that api.
>> 
>> So I have attempted with auto-focus..
>> 
>> In the DRL (from XLS) however getting the agenda group settings right
>> has been a small 'mare. Suffice to say I haven't got it working.
>> 
>> My options:
>> 1. get agenda groups working.
>> 2. split the three groups into 3 DRL files. and execute in sequence
>> each one using a different ksession for each.
>> 
>> --- on 1.
>> 
>> How would I construct the flow.. .. Do I use three separate auto focus
>> rules , one for each a.group  and set a salience ( I don think
>> salience helps here ) ? How do I guarantee to stack the focus using
>> auto-focus to follow my ordering?
>> 
>> -- on 2.
>> Can I create a separate ksession for each DRL file (injecting them in
>> from spring).
>> 
>> --
>> Thoughts ? Am I solving right ?
>> 
>> Many thanks. Ramon
>> _______________________________________________
>> 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/20130605/68aeeda3/attachment.html 


More information about the rules-users mailing list