[jboss-user] [jBPM] - Re: Multiple ksession dispose issue

Sanket Mohile do-not-reply at jboss.com
Sun Apr 28 08:47:51 EDT 2013


Sanket Mohile [https://community.jboss.org/people/sanket.mohile] created the discussion

"Re: Multiple ksession dispose issue"

To view the discussion, visit: https://community.jboss.org/message/810689#810689

--------------------------------------------------------------
Thought to dig more into this..... And finally found my culprit.... And a temporary solution to it....
Here is all of it :-

1. This "WARN" msg would come only in case of a process with a timer node.

2. After some more investigation, found that on each timer tick "org.drools.persistence.jpa.JDKCallableJobCommand" gets executed by JpaTimerJobInstance and it returns me CommandService of the disposed ksession. Hence the WARN message. 

|| *org.drools.persistence.jpa.JpaTimerJobInstance.java* ||
| ...
...
public Void call() throws Exception {
try { 
JDKCallableJobCommand command = new JDKCallableJobCommand( this );
             /* The following line returns me the command service object of the disposed ksession */

*CommandService commandService = ((AcceptsTimerJobFactoryManager)scheduler).getTimerJobFactoryManager().getCommandService();*
commandService.execute( command );
return null;
} catch( Exception e ) { 
logger.error("Unable to execute timer job!", e);
throw e;
}
}
  ...
   ... |

Reason? - Probably because we use the same SessionConfiguration to load both our session.... *Ref:* Read Comment by "+Sebastian Calbaza+" on  https://issues.jboss.org/browse/JBPM-3827 https://issues.jboss.org/browse/JBPM-3827 
So even after I dispose my ksession, the related *SingleSessionCommandService is still active* somewhere with a dead ksession. And the TimerJobFactoryManager class hits me with it  :( 
Please raise a JIRA if you guys think this is an issue.

3. The Workaround: In CMTDisposeCommand Class..... In the after completion method... set the CommandService object of the disposing ksession to the CommandService object of the ksession which is alive(The one you dont dispose because it has timers running on it....)
|| *CMTDisposeCommand.java* ||
| ...
...

@Override
                public void *afterCompletion*(int status) {

/* Set the Command Service of this ksession to one in which timer process started */
SingleSessionCommandService commandService = (SingleSessionCommandService)((CommandBasedStatefulKnowledgeSession)ksession).getCommandService();
InternalKnowledgeRuntime ikr = (InternalKnowledgeRuntime)commandService.getStatefulKnowledgeSession();
JDKTimerService timerService = (JDKTimerService)ikr.getTimerService();
JpaTimeJobFactoryManager manager = (JpaTimeJobFactoryManager)timerService.getTimerJobFactoryManager();

SingleSessionCommandService ksession2CommandService = (SingleSessionCommandService((CommandBasedStatefulKnowledgeSession)ksession2).getCommandService();

                      manager.setCommandService(ksession2CommandService);

/* Now dispose the ksession */
                       ksession1.dispose()
                }

...
... |

Now this solves the issue I'd report in this thread. 
Not a good option though, ideally the TimerJobFactoryManager should not return me a SingleSessionCommandService reference with a disposed ksession.
I'll mark this as answered. But please let me know if there are better fixes/steps or I'm missing something.

Thanks,
Sanket
--------------------------------------------------------------

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

Start a new discussion in jBPM at Community
[https://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/20130428/9ab2abd5/attachment-0001.html 


More information about the jboss-user mailing list