I guess you are trying to use the same session you had after the modifications are applied. And unfortunately you can't do that using 5.0.1 :(. Since 5.1.M1 you can use the "incremental change set processing" feature that allows you to do what you are looking for. Without this feature, kagent creates a new Knowledge Base every time a change set is processed. So if you want to "see" the changes you will need to do something like this:
   
knowledgeAgent.getKnowledgeBase().newStateful/StatelessKnowledgeSession();

and then insert all your facts again :(

If you try to use the original kbase, you won't see the changes applied by the agent.
Using incremental change set processing the agent's kbase is reused, allowing you (among other things) to reuse any previous session you have.

Best,


On Fri, Jun 25, 2010 at 4:48 AM, Stephen Mcgruer <s0840449@sms.ed.ac.uk> wrote:
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@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@sms.ed.ac.uk>wrote:
>
>> Sorry, I'm using Drools 5.0.1
>>
>> Cheers,
>> Stephen
>>
>> Quoting Esteban Aliverti <esteban.aliverti@gmail.com>:
>>
>> > Which version of drools are you using?
>> >
>> > On Thu, Jun 24, 2010 at 5:33 AM, Stephen Mcgruer
>> > <s0840449@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@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@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@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@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



--
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Esteban Aliverti