[rules-users] Drools 5.5 Property Reactive on Maps

gboro54 gboro54 at gmail.com
Thu Nov 14 11:12:27 EST 2013


So I have an object with a map like follows:

protected ConcurrentMap<String, Double> accumulations = new
ConcurrentHashMap<String, Double>();

I wrote a convince method on the class that will look up the value in the
map and add to it if it exists and 
if not there will put it in the map:

    @Modifies({ "accumulations " })
    public void addToAccumulation(String code, long volume) {
        if (accumulations .containsKey(code)) {
            Double value = accumulations .get(code) + volume;
            accumulations .put(code, value);

        } else {
            accumulations .putIfAbsent(code, new Double(volume));
        }
    }

I have a rule to listen on the change of this filed on the object(i.e
accumulations["someCode"]!=null) but 
when I modify the object the rule doesn't fire. I have added
@PropertyReactive to the Object and build the kbase as follows:

        Properties props = new Properties();
        props.setProperty("drools.dialect.java.compiler", "JANINO");

        KnowledgeBuilderConfiguration config = KnowledgeBuilderFactory
                .newKnowledgeBuilderConfiguration(props);
        config.setOption(PropertySpecificOption.ALWAYS);


Any insight into why this may not work?




--
View this message in context: http://drools.46999.n3.nabble.com/Drools-5-5-Property-Reactive-on-Maps-tp4026782.html
Sent from the Drools: User forum mailing list archive at Nabble.com.


More information about the rules-users mailing list