4 Replies Latest reply on Jan 27, 2012 9:02 AM by gardellajp

    Mina Human Task Server and close connections - don't refresh the session

    gardellajp Newbie

      Hi folks,

       

      I have a problem and I don't found a good solution to this. The problem is that I complete a task and the session didn't refresh becouse the handler and the session is dispose. See the next code:

       

      << CODE>>>

      TaskClient client = obtainATaskClient();

      client.getTask(taskId,handler);

       

      Task task = handler.getTask();

       

      //obtain the session

      int sessionId = task.getTaskData().getProcessSessionId();

      StatefulKnowledgeSession session = JPAKnowledgeService.loadStatefulKnowledgeSession(sessionId,knowledgeBase, null, envoriment);

      CommandBasedWSHumanTaskHandler handler = new CommandBasedWSHumanTaskHandler(session);

      session.getWorkItemManager().registerWorkItemHandler("Human Task",handler);

      handler.connect();

       

      //complete the task

      client.complete(taskId, userId, outputData, responseHandler);

       

      isDone = responseHandler.waitTillDone(time);

       

      // -- Close resources --

      handler.dispose();

      session.dispose();

       

      <<< END CODE >>>>

       

      I can fix with if I put this line after the comment // -- Close resources --:

       

      Thread.sleep(500);

       

      When I put this, Mina server communicate with the handler and refresh the session. Is a very poor workaround.

       

      I try cache the session and close after some time, but if I use this approach have problems that said WorkItemInfo doesn't exists, becouse the handler delete complete human task.

       

      So my question is:

       

      How can I close the session only after the handler refresh it?

       

      Thanks,

      Juan