[jboss-jira] [JBoss JIRA] (DROOLS-1624) Map Handling with Property Reactive Always Enabled

Mario Fusco (JIRA) issues at jboss.org
Wed Jun 21 06:11:00 EDT 2017


    [ https://issues.jboss.org/browse/DROOLS-1624?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13424559#comment-13424559 ] 

Mario Fusco commented on DROOLS-1624:
-------------------------------------

I tried to do what you suggest (see my test case I'm pasting below) but it works for me. Is my use case different from yours? If so what should I change to reproduce the problem?

{code}
    @Test
    public void testPropertyReactivityOnMap() {
        // DROOLS-1624
        final String drl =
                "import " + Map.class.getCanonicalName() + ";\n" +
                "rule R1 when\n" +
                "    $key : String( )\n" +
                "    $m : Map( this[$key] == \"Mario\" )\n" +
                "then\n" +
                "    delete($key);\n" +
                "    modify($m) { put(\"enabled\", \"true\") };\n" +
                "end\n" +
                "rule R2 when\n" +
                "    $m : Map( this[\"enabled\"] == \"true\" )\n" +
                "then\n" +
                "    modify($m) { put(\"enabled\", \"false\"), put(\"result\", \"OK\") };\n" +
                "end\n";

        final KieSession ksession = new KieHelper().addContent(drl, ResourceType.DRL).build().newKieSession();

        ksession.insert("name");
        Map<String, String> map = new HashMap<>();
        map.put("name", "Mario");
        FactHandle mapFh = ksession.insert(map);
        ksession.fireAllRules();
        System.out.println(map);
        assertEquals( "OK", map.get("result") );
    }
{code}

> Map Handling with Property Reactive Always Enabled
> --------------------------------------------------
>
>                 Key: DROOLS-1624
>                 URL: https://issues.jboss.org/browse/DROOLS-1624
>             Project: Drools
>          Issue Type: Bug
>          Components: core engine
>    Affects Versions: 7.0.0.Final
>         Environment: * JDK8
> * Docker running Alpine
>            Reporter: KimJohn Quinn
>            Assignee: Mario Fusco
>            Priority: Minor
>
> Referencing a conversation on [Google Groups - Drools Usage|https://groups.google.com/forum/?fromgroups#!topic/drools-usage/G7rlz3oI1HQ] and as requested by Mario Fusco...
> We currently have a ruleset that relies heavily on Map facts.  In Drools 6.5 we fire approximately 400 rules.  
> In Drools 7.0 we get only about 50 rules unless we add the "<property key="drools.propertySpecific" value="ALLOWED"/>" to the kmodule.xml, in which case we fire the full 400 rules or by using @Watch(*) or @Watch(!*) on the rules.  It "seems" like only the first evaluations of the rules are firing and then no others after that.
> Our flow generally follows something like below, within a stateful session, using rules only.  We fire all rules per-request then close the session.
> Watch for changes to the Map properties
> If a certain property or properties exist a 'populate' rule fires (calls modify())
> The populate rule enriches the map fact. (calls modify())
> Based on #3, more rules fire when certain properties exist (calls modify())
> We are work heavily with rules that depend on loaded available facts up-front and computed properties throughout evaluation.  
> I have a couple of usage questions regarding Drools 7, the default enabling of Property Reactive and using Maps as the facts:
> In general, how do maps work with property reactive and respond to modify/insert events?  Does Drools look at the Map as a whole, any change re-evaluates the tree, or each individual property within the map re-evaluates the change?
> In Drools 7, by defaulting the property reactive setting, does that mean all rules need to be annotated or they should they work as is (dao or map-based facts) when using modify/insert?
> For reference, we are relying on this doco https://docs.jboss.org/drools/release/7.0.0.Final/drools-docs/html_single/index.html#_fine_grained_property_change_listeners.
> I am looking into details or an example how to properly use Maps in Drools 7 with Property Reactive features always enabled (as suggested per the doco)....



--
This message was sent by Atlassian JIRA
(v7.2.3#72005)


More information about the jboss-jira mailing list