-
1. Re: Is WorkingMemoryLogger working?
salaboy21 Aug 23, 2011 9:00 AM (in response to lukasz.kozerski)did you try with
KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession); ?
-
2. Re: Is WorkingMemoryLogger working?
lukasz.kozerski Aug 23, 2011 9:30 AM (in response to salaboy21)Yes.
I have simple method:
private Environment environment(EntityManagerFactory emf) {
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
env.set(EnvironmentName.OBJECT_MARSHALLING_STRATEGIES,
new ObjectMarshallingStrategy[] {MarshallerFactory.newSerializeMarshallingStrategy()});
return env;
}
In this example logger works fine:
environment = environment(emf);
StatefulKnowledgeSession ksession = newSession();
int sessionId = ksession.getId();
Map<String, Object> parameters = new HashMap<String, Object>();
Object object = createObject();
parameters.put("object", object);
ksession.insert(object);
ksession.startProcess("process", parameters);
ksession.fireAllRules();
environment = environment(emf);
ksession = loadSession(sessionId);
KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession);
WorkItemManager mgr = ksession.getWorkItemManager();
mgr.completeWorkItem(workItemId, null);
ksession.dispose();
and when I will comment this line:
//environment = environment(emf); <- commented
ksession = loadSession(sessionId);
KnowledgeRuntimeLoggerFactory.newConsoleLogger(ksession);
it is not.
-
3. Re: Is WorkingMemoryLogger working?
salaboy21 Aug 23, 2011 9:40 AM (in response to lukasz.kozerski)Yes I saw that behavior before. That's probably because the you are persisting the session and the Environment keeps a reference to the old entity manager that has some value cached. When you reinitialize the environment to load once again the session you clean that object and the session is restored completely fromt the BD and works again without an inconsistent state.
If you think about the purpose of loading a session, is that you will load the session in a different thread where you need to initialize the environment once again. Cheers