Shobhit Tyagi [
https://community.jboss.org/people/roxy1987] created the discussion
"Problems with Local Task Service"
To view the discussion, visit:
https://community.jboss.org/message/809857#809857
--------------------------------------------------------------
Guys,
I have a process with 2 tasks. I am using local task service. The process starts fine and
completion of 1st task is also clean. but the 2nd task is not assigned. neither it is
listed in the database. What could be the reason?
Following is my code for initiate process and complete task.
Initiate :
StatefulKnowledgeSession ksession;
long processInstanceId = -1;
try
{
ksession = BpmRepositoryConfig.createSession(processName);
KnowledgeRuntimeLogger logger1 =
KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, "testlog", 1000);
LocalHTWorkItemHandler handler = new LocalHTWorkItemHandler(ksession);
org.jbpm.task.service.TaskService service = BpmRepositoryConfig.getService();
TaskService taService = BpmRepositoryConfig.getTaskService(ksession, service);
handler.setClient(taService);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task",
handler);
JPAWorkingMemoryDbLogger logger2 = new JPAWorkingMemoryDbLogger(ksession);
ProcessInstance prcInstance = ksession.startProcess(processDefId, mapParameters);
processInstanceId = prcInstance.getId();
}
catch (Exception e)
{
e.printStackTrace();
}
Complete :
StatefulKnowledgeSession ksession = BpmRepositoryConfig.createSession(processName);
org.jbpm.task.service.TaskService tservice = BpmRepositoryConfig.getService();
TaskService taskService = BpmRepositoryConfig.getTaskService(ksession,tservice);
try
{
for(long task : taskId)
{
taskService.start(task, userId);
taskService.complete(task, userId, null);
}
}
catch (Exception e)
{
e.printStackTrace();
}
Other methods :
public static org.jbpm.task.service.TaskService getService()
{
EntityManagerFactory emf =
Persistence.createEntityManagerFactory("org.jbpm.task");
org.jbpm.task.service.TaskService tservice = new org.jbpm.task.service.TaskService(emf,
SystemEventListenerFactory.getSystemEventListener());
TaskServiceSession taskSession = tservice.createSession();
taskSession.addUser(new User("Administrator"));
taskSession.addUser(new User("krisv"));
taskSession.addUser(new User("john"));
taskSession.addUser(new User("mary"));
return tservice;
}
public static TaskService getTaskService(StatefulKnowledgeSession
ksession,org.jbpm.task.service.TaskService taskService)
{
TaskService client = new LocalTaskService(taskService);
LocalHTWorkItemHandler localHTWorkItemHandler = new LocalHTWorkItemHandler(client,
ksession);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task",
localHTWorkItemHandler);
return client;
}
Thanks.
--------------------------------------------------------------
Reply to this message by going to Community
[
https://community.jboss.org/message/809857#809857]
Start a new discussion in jBPM at Community
[
https://community.jboss.org/choose-container!input.jspa?contentType=1&...]