2 Replies Latest reply on Nov 8, 2011 10:46 PM by andy.yeung

    Resources Handling on TaskClient in JBPM5

    andy.yeung

      We are currently using the MinaTaskClientConnector within the TaskClient based on the example given. I noticed that CommandBasedWSHumanTaskHandler indeed need to create  TaskClient by itself. Since TaskClient involves making connection to server, I want to ask the following in order to decide how to manage the TaskClient instances.

       

      1. Does every TaskClient take up large amount of resources?

      2. Is TaskClient thread safe which I can shared among multiple knowledgeSession?

      3. I notice that clientConnnector within the TaskClient owned the BaseHandler and I notice that everytime CommandBasedWSHumanTaskHandler execute an workitem, it register an event handler in the BaseHandler. But it seems won't unregister it after use. Does it mean TaskClient is not meant to be shared?

      4. I notice that there is a isRemove interface in EventResponseHandler but I find that TaskCompletedHandler isRemove always return false. Don't know if there is reason behind that.

       

      Anyone has idea on this?

        • 1. Re: Resources Handling on TaskClient in JBPM5
          andy.yeung

          I have trace the code in CommandBasedWSHumanTaskHandler. I find that the KnowledgeRuntime pass in constructor is used by the callback handler in GetCompletedTaskResponseHandler and GetResultContentResponseHandler only. I remove that in constructor and add method registerHumanTaskSession(Long pTaskId, KnowledgeRuntime pSession) and deregisterHumanTaskSession(Long pTaskId) in it. Before I call TaskClient.completeTask, I first registerr the task id and correponding session in the CommandBasedWSHumanTaskHandler. In the callback, I change session.getWorkItemManager().completeWorkItem(workItemId, results) to sessionLookup.get(task.getId()).getWorkItemManager().completeWorkItem(workItemId, results);

           

          In this way I can share the TaskClient and BlockingComamndBasedWSHumanTaskHandler by multiple process instance.

           

          Also in the connect method,

          I configure a flag and only let the registerForEvent execute once only. Otherwise multiple callback will be triggered since executeWorkItem call connect method implicitly.

           

          I have tested this under 10 concurrent thread and seems having no problem in this way. But I am not sure if using a single TaskClient in BlockingCommandBasedWSHumanTaskHandler amongs all process instance affects performance.

          • 2. Re: Resources Handling on TaskClient in JBPM5
            andy.yeung

            IsRemove interface tells if the handler is removed after the process of callback message. TaskCompletedHandler isRemove() always return false so I think it is meant to be reused and initialized once only.