JBoss Community

Re: Loading processInstance/session via JPA, workItem executes before able to register workItems

created by Marcus Portmann in jBPM - View the full discussion

Hi Ryan,

 

I encountered the same problem but am still working on finding a solution.

 

I believe that the problem is a result of a race condition where when a persistent knowledge session is unmarshalled as part of the call-chain for JPAKnowledgeService.loadStatefulKnowledgeSession(...) the "timer job" infrastructure is initialised and any pending "timer jobs" are immediatelly executed before the knowledge session is completely initialised. In my case what happens is that a TimerJobInstance executes before the following line is executed in the initKsession method for the SingleSessionCommandService class so the CommandService for my TimerJobFactoryManager instance is still null.

 

     ((AcceptsTimerJobFactoryManager) ((InternalKnowledgeRuntime) ksession).getTimerService()).getTimerJobFactoryManager().setCommandService( this ); 

 

The issue seems to be that timer job instances should not executed until the knowledge session is completely initialised. This initialisation should include things like registering the work item handlers which should solve your problem.

 

I believe that the knowledge session itself needs some sort of "resume" method so that it can be instructed when to resume once it has been completely initialised. This "resume" method would kick-off any timer jobs. Unfortunately I am not familiar enough with the Drools/JBPM code-base to suggest how this should be implemented.

 

Regards,

 

Marcus

Reply to this message by going to Community

Start a new discussion in jBPM at Community