[rules-users] KnowledgeAgent with persistence?

Davide Sottara dsotty at gmail.com
Tue Sep 10 18:39:01 EDT 2013


Is the knowledge agent configured NOT to create a new knowledgebase
every time it detects an update?
That is, did you create it with the option "newInstance" set to false?

On 09/10/2013 03:26 PM, dunnlow wrote:
> I'm using Drools 5.5 (and guvnor)
>
> Can anyone point me to example where a knowledge agent is used with
> persistence.  I am trying to understand how the knowledgeagent is used with
> a persisted session.  Fundamentally when my app starts, I am trying to do
> one of two things:
>
> If a persisted session does not exist, start a new one and update it
> whenever my knowledgebase (in guvnor) changes
> ELSE
> If a persisted session already exists (i.e. at a system restart), load the
> existing session and continue to monitor it for changes.
>
> I have the persistence working and the monitoring of changes (with a
> knowledgeagent) working independently, but not together.
>
> My code:
>
>    Environment env = KnowledgeBaseFactory.newEnvironment();
>    env.set(EnvironmentName.ENTITY_MANAGER_FACTORY,myEMF);
>    env.set(EnvironmentName.TRANSACTION_MANAGER, myTxManager);
>
> To create/retrieve my ksession I have tried both:
>    ksession =
> JPAKnowledgeService.newStatefulKnowledgeSession(kAgent.getKnowledgeBase(),null,env)
> This creates a persisted session, but it is never updated with changes
>
> I also tried:
>    ksession =
> kAgent.getKnowledgeBase().newStatefulKnowledgeSession(null,env);
> This updates the ksession with changes, but never persists the session
>
> I figure I can add a KnowledgeAgentEventListener to the agent and then
> recreate the ksession by hand (in the knowledgeBaseUpdated method).  But I
> am hoping there is a cleaner/better way.
>
> Thanks for any ideas.
> -J
>
>
>
>
> --
> View this message in context: http://drools.46999.n3.nabble.com/KnowledgeAgent-with-persistence-tp4025897.html
> Sent from the Drools: User forum mailing list archive at Nabble.com.
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>



More information about the rules-users mailing list