1 Reply Latest reply on Nov 8, 2011 10:58 PM by andy.yeung

    Dispose of knowledgeSession when use with persistence

    andy.yeung

      We are trying to use JBPM 5 with persistence to handle long workflow involving human task. I have read some other dicussion in the forum and they suggest to use 1 session for each workflow while having a single session to handle all schedule task. Session is reinitialize when handling user response like complete task such that workflow will not stucked and continue to subsequent nodes. The problem comes when the task complete.

       

      BlockingTaskOperationResponseHandler responseHandler = new BlockingTaskOperationResponseHandler();

      getTaskClient().complete(pTaskId, pUserId, contentData, responseHandler);

      responseHandler.waitTillDone(10000);

      knowledgeSession.dispose();

       

      I found that responseHandler.waitTillDone already jump out when the complete msg successfully sent to task server.

      It doesn't wait until the CommandBasedWSHumanTaskHandler task completed event to be executed.

      This make the session closed and the jbpm app scope transaction manager being released and cause the transitted workflow state in CommandBasedWSHumanTaskHandler cannot be persisted.

       

      I want to know if it's just my usage or configuration problem. It seems it require me to modify the CommandBasedWSHumanTaskHandler  and let my code above to wait until CommandBasedWSHumanTaskHandler.TaskCompletedHandler to finish its job first before I dispose the session.

        • 1. Re: Dispose of knowledgeSession when use with persistence
          andy.yeung

          I did the following to make this issue gone. I am not quite certain that if every steps needed to be done or not.

           

          1. I added a CountDownLatch in BlockingCommandBasedWSHumanTaskHandler and let my main thread to wait for it. In the GetCompletedTaskResponseHandler and GetResultContentResponseHandler handler I execute countDown based on the result to release the lock to ensure the response handler completed before I dispose the session in main thread.

           

          2. I move the transaction scope to wrap my whole complete task logic.

           

          3. I also find that it was triggering multiple callback to TaskCompletedHandler due to some reason. I partially fix that part.