Discussion:
[jboss-user] [jBPM] - Problems with Local Task Service
Shobhit Tyagi
2013-04-23 18:02:37 UTC
Permalink
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&containerType=14&container=2034]
Shobhit Tyagi
2013-04-24 17:02:10 UTC
Permalink
Shobhit Tyagi [https://community.jboss.org/people/roxy1987] created the discussion

"Re: Problems with Local Task Service"

To view the discussion, visit: https://community.jboss.org/message/810077#810077

--------------------------------------------------------------
Any Help here please.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/810077#810077]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Maciej Swiderski
2013-04-25 08:19:28 UTC
Permalink
Maciej Swiderski [https://community.jboss.org/people/swiderski.maciej] created the discussion

"Re: Problems with Local Task Service"

To view the discussion, visit: https://community.jboss.org/message/810229#810229

--------------------------------------------------------------
when you create new handler (LocalHTWorkItemHandler) you need to call connect on it to register event listeners so when task is completed ksession will be notified.

HTH
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/810229#810229]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Shobhit Tyagi
2013-04-25 15:17:39 UTC
Permalink
Shobhit Tyagi [https://community.jboss.org/people/roxy1987] created the discussion

"Re: Problems with Local Task Service"

To view the discussion, visit: https://community.jboss.org/message/810356#810356

--------------------------------------------------------------
Thanks for your reply Maciej. I see the next task now. But completing all the task doesnt update the process instance details. Process instance stays in progress.
So I tried using the same session and it ended the process instance too.
Now, I remember using a new session everytime with HornetQ or Mina. Is this a difference here in case of a LocalTaskService?
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/810356#810356]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Demian Calcaprina
2013-04-30 02:14:53 UTC
Permalink
Demian Calcaprina [https://community.jboss.org/people/calca] created the discussion

"Re: Problems with Local Task Service"

To view the discussion, visit: https://community.jboss.org/message/810863#810863

--------------------------------------------------------------
Where are you checking if the process instance has finished? Can you share your process definition?

Thanks

Demian
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/810863#810863]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Shobhit Tyagi
2013-04-30 04:53:13 UTC
Permalink
Shobhit Tyagi [https://community.jboss.org/people/roxy1987] created the discussion

"Re: Problems with Local Task Service"

To view the discussion, visit: https://community.jboss.org/message/810869#810869

--------------------------------------------------------------
I am checking the status in the database. I cant share the proc def right now but wll do that 1st thing in the morning.
I was absolutely fine with jbpm5 when i used it with Servlets and JSPs etc. Now that I moved to EJBs, I have started facing issues.
I am a little confused with the way we are supposed to use KnowledgeSessions and KnowledgeBases. I use the same knowledge base and create a new session whenever I need it. This worked pretty well with servlets and since creating a KnowledgeSession is not a heavy job, as per the User Guide, I dont mind having many sessions. But with EJBs, things seem a lot different. May be coz of the fact that my technology stack is EJB and Websphere, and the transaction is supposed to be Container Managed.

Confusion with session, kbases, whether or not to disconnect the task handlers, whether or not to disconnect the TaskClients, disposing the DBlogger.
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/810869#810869]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
Loading...