According to this thread ,since the session will keep the state likes facts or timer , I use "one process instance per session" architecture in which each process instance is created and manutiplated by their own dedicated session.
For the human task , I use LocalTaskService which is defined as singleton Spring bean. So , after creating the session from an application scoped Knowledge base , I registered the work item handler using the following code .
StatefulKnowledgeSession session = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env); TaskService localTaskService = (TaskService)springContext.getBean("localTaskService"); LocalHTWorkItemHandler humanTaskHandler = new LocalHTWorkItemHandler(localTaskService, session); session.getWorkItemManager().registerWorkItemHandler("Human Task", humanTaskHandler);
All the session use the same localTaskService instance to call the related API to do the human task operations . Is it okay or should I create the localTaskService for each session ? I ask because it seems that calling the method of localTaskService instance will somehow invoke the method on StatefulKnowledgeSession instance .