JBoss Community

When to call kSession.dispose()?

created by Ryan Peterson in jBPM - View the full discussion

I was wondering:  How often should kSession.dispose() be called for any given session?

 

For instance, suppose you have the following:

 

// create kSession

JPAKnowledgeService.newStatefulKnowledgeSession()

 

// do some operations with kSession:

ksession.getWorkItemManager().registerWorkItemHandler(x, y);

...

// start the process instance

kSession.startProcess(processId, params)

 

// Should kSession.dispose() be called here, since we're doing doing work on the ksession for now?

 

Suppose we re-load the session later:

JPAKnowledgeService.loadStatefulKnowledgeSession()

 

// Should kSession.dispose() only be called here?

 

I'm mostly unsure if .dispose() needs to be called after each transaction with a kSession, or if it should only be called once the kSession is complete/aborted?

Reply to this message by going to Community

Start a new discussion in jBPM at Community