[rules-users] Dynamic updates of stateful sessions

Mattias Avelin mattias.avelin at netlight.se
Mon Apr 18 10:41:22 EDT 2011


We have a application in which we have both stateless & stateful sessions
running. We're using the KnowledgeAgent and ChangeSets to automatically
update our knowledge bases when the rules are changed. 
This works fine for our stateless sessions for which we are creating a new
session for each request and if the rules have been updated this is
reflected in next session we create.

But for stateful sessions I'm not quite as sure on how to get it working. I
can see in the logs that the KnowledgeBase is re-built when the
KnowledgeAgent detects the updated rule files. But my "long running" session
is does not reflect these changes (which it shouldn't right?). But how do we
apply these changes to the stateful session without loosing all the facts I
accumulated? 

The way I've solved it now is to keep a "last updated" timestamp for the
knowledgeBase and a "created" timestamp for the session and then compare
these before using the session. If the knowledgeBase's "update timestamp" is
later that the sessions "creation timestamp" I create a new Session and then
"manually" copy all facts from the former to the latter. 

Is this the way you would do this or is there a better way?

Best Regards

Mattias Avelin





More information about the rules-users mailing list