[rules-users] Automatic updating of Guvnor Rules appears to be not working.

Stephen Mcgruer s0840449 at sms.ed.ac.uk
Fri Jun 25 03:48:01 EDT 2010


Unfortunately that might be quite tricky, although I can try if  
necessary. I do think that perhaps the problem lies in the way I  
handle the auto-updating, I think I'm doing it wrong. Originally I  
just created the knowledge base and knowledge agent like so, and  
started the ResourceChange Notifier and Scanner services:

//construct a knowledgebase that uses Equality mode assert behaviour  
so that it can match beans properly
KnowledgeBaseConfiguration knowledgeBaseConfig =  
KnowledgeBaseFactory.newKnowledgeBaseConfiguration();
knowledgeBaseConfig.setProperty("drools.assertBehaviour", "equality");
knowledgeBase = KnowledgeBaseFactory.newKnowledgeBase(knowledgeBaseConfig);

//create a new knowledgeAgent to track changes
knowledgeAgent = KnowledgeAgentFactory.newKnowledgeAgent(  
"knowledgeAgent", knowledgeBase );
knowledgeAgent.applyChangeSet( ResourceFactory.newClassPathResource(  
"changeSet.xml" ) );
knowledgeBase = knowledgeAgent.getKnowledgeBase();

ResourceFactory.getResourceChangeNotifierService().start();
ResourceFactory.getResourceChangeScannerService().start();


This seemed to claim to update the knowledge base, but nothing changed  
as I mentioned before. At the moment, I'm trying rebuilding the  
knowledgebase when I detect a change, but this involves re-inserting  
the entire database which could be big eventuallly... And it doesn't  
even work entirely correctly either XD.

What are the correct steps to take to keep a knowledgeBase  
auto-updating, and do you have to re-create it each time?

Thanks,
Stephen


Quoting Esteban Aliverti <esteban.aliverti at gmail.com>:

> Could you please try your example using latest SNAPSHOT or 5.1M2?
>
> Thanks
>
> On Thu, Jun 24, 2010 at 10:20 AM, Stephen Mcgruer   
> <s0840449 at sms.ed.ac.uk>wrote:
>
>> Sorry, I'm using Drools 5.0.1
>>
>> Cheers,
>> Stephen
>>
>> Quoting Esteban Aliverti <esteban.aliverti at gmail.com>:
>>
>> > Which version of drools are you using?
>> >
>> > On Thu, Jun 24, 2010 at 5:33 AM, Stephen Mcgruer
>> > <s0840449 at sms.ed.ac.uk>wrote:
>> >
>> >> Hi there. I'm trying to get automatic update of rules working in my
>> >> project, and seem to
>> >> have run into a problem. As far as I can tell, automatic polling and
>> >> updating is turned
>> >> on, and claims to update the knowledgebase, but changes to the rules
>> >> don't seem to have
>> >> any effect. A simple example - if I add the rule:
>> >>
>> >> rule "TestRule"
>> >>         dialect "mvel"
>> >>         when
>> >>         then
>> >>                 System.out.println("Hello, world!");
>> >> end
>> >>
>> >> And start my application, I get:
>> >>
>> >> Firing all rules...
>> >> Hello, world!
>> >> All rules fired.
>> >>
>> >> As expected. If I then change the rule as follows:
>> >>
>> >> rule "TestRule"
>> >>         dialect "mvel"
>> >>         when
>> >>         then
>> >>                 System.out.println("I have changed!");
>> >> end
>> >>
>> >> I get this output (timestamps trimmed for readability):
>> >>
>> >> ResourceChangeScanner attempt to scan 1 resources
>> >> ResourceChangeScanner modified resource=[UrlResource
>> >> path='
>> >>
>> http://localhost:1337/drools-guvnor/org.drools.guvnor.Guvnor/package/ERMIE/v0.1
>> >> ']
>> >> :
>> >> 1277371031000 : 1277371254000
>> >> ResourceChangeNotification received ChangeSet notification
>> >> ResourceChangeScanner thread is waiting for 60
>> >> ResourceChangeNotification processing ChangeSet
>> >> ResourceChangeNotification ChangeSet modified resource=[UrlResource
>> >> path='
>> >>
>> http://localhost:1337/drools-guvnor/org.drools.guvnor.Guvnor/package/ERMIE/v0.1
>> >> ']
>> >> for listener=org.drools.agent.impl.KnowledgeAgentImpl at e2d0b2
>> >> KnowledgeAgent received ChangeSet changed notification
>> >> ResourceChangeNotification thread is waiting for queue update
>> >> KnowledgAgent applying ChangeSet
>> >> KnowledgeAgent ChangeSet requires KnowledgeBuilderKnowledgeAgent
>> >> rebuilding KnowledgeBase
>> >> using ChangeSet
>> >> KnowledgeAgent building resource=[UrlResource
>> >> path='
>> >>
>> http://localhost:1337/drools-guvnor/org.drools.guvnor.Guvnor/package/ERMIE/v0.1
>> >> ']
>> >> KnowledgeAgent adding KnowledgeDefinitionsPackage ERMIE
>> >> KnowledgeAgent new KnowledgeBase now built and in use
>> >>
>> >> So, this makes it seem like everything has worked. However, if I
>> >> insert a new fact and
>> >> fire all rules...
>> >>
>> >> Inserting new fact...
>> >> Hello, World!
>> >>
>> >> So, it hasn't worked. What might I have done wrong?
>> >>
>> >>
>> >> -Stephen
>> >>
>> >> --
>> >> The University of Edinburgh is a charitable body, registered in
>> >> Scotland, with registration number SC005336.
>> >>
>> >>
>> >>
>> >> _______________________________________________
>> >> rules-users mailing list
>> >> rules-users at lists.jboss.org
>> >> https://lists.jboss.org/mailman/listinfo/rules-users
>> >>
>> >
>> >
>> >
>> > --
>> > XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>> >
>> > Esteban Aliverti
>> >
>>
>>
>>
>> --
>> The University of Edinburgh is a charitable body, registered in
>> Scotland, with registration number SC005336.
>>
>>
>>
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>
>
>
> --
> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
>
> Esteban Aliverti
>



-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.






More information about the rules-users mailing list