[jboss-user] [jBPM] - Re: Does the ksession.dispose() work safely?

byungwoojun do-not-reply at jboss.com
Mon Jun 13 12:13:47 EDT 2011


byungwoojun [http://community.jboss.org/people/byungwoojun] created the discussion

"Re: Does the ksession.dispose() work safely?"

To view the discussion, visit: http://community.jboss.org/message/609943#609943

--------------------------------------------------------------
Since we don't change environment per knowledge session, we cache the environment and use it when we create a new stateful knowledge session. It is questionable if we need to create environment per knowledge session (e.g., Environment env = KnowledgeBaseFactory.newEnvironment();)

We chose to cache the environment, and we experienced the problems that was described in my previous section. As a resolution, my team set an additional environment property by using putting the emf.createEntityManager() into EnvironmentName.APP_SCOPED_ENTITY_MANAGER as follows:

private static Environment env = null;
...

env = KnowledgeBaseFactory.newEnvironment();
...
env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
...
*env.set(EnvironmentName.APP_SCOPED_ENTITY_MANAGER,*
*               emf.createEntityManager());*
...

StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, *env*);
...

After the above setting, the ksession.dispose() no longer created a problem. Here is my question, what is the best practice on the enviroment creation? Should we cache it or should we create it per knowledge session?

thanks,
bwj

--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/609943#609943]

Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110613/0f7f04d9/attachment.html 


More information about the jboss-user mailing list