João Guerra [https://community.jboss.org/people/ciberg] created the discussion

"Duplicate tasks created after completing previous task"

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

--------------------------------------------------------------
Hi, I have a web application using JBPM 5.4 and the processes have only human 
tasks.

Sometimes when a task is completed JBPM creates the next task in the workflow 
in duplicate.
It seems that this is aggravated when multiple users are using the application.

This is the code that I use to complete a task:

          BlockingTaskOperationResponseHandler responseHandler = new 
BlockingTaskOperationResponseHandler();
try {
                              Task task = taskService.getTask(taskId);
                              TaskData taskData = task.getTaskData();
humanTaskClient.complete(taskId, user, null, responseHandler);
                              responseHandler.waitTillDone(75000);
                              StatefulKnowledgeSession ksession = 
JBPMConnectionsInitializer.accessKnowledgeSession(processPackage);
                              KnowledgeRuntimeLogger logger = 
JBPMConnectionsInitializer.activateKnowledgeRuntimeLog(ksession);

new JPAWorkingMemoryDbLogger(ksession);

                              ksession.getWorkItemManager().completeWorkItem(
                                                  taskData.getWorkItemId(), 
null);
                              logger.close();
  ...

This is the connection initializer:
public static StatefulKnowledgeSession accessKnowledgeSession(String 
processPackage) throws Exception {
                    KnowledgeBase kbase = null;
                    StatefulKnowledgeSession ksession = null;
                    EntityManagerFactory emf = 
Persistence.createEntityManagerFactory(PERSISTANCE_ENTITY_NAME);
                    Environment env = KnowledgeBaseFactory.newEnvironment();
                    env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
                    kbase = readJbpmKnowledgeBase(processPackage);
                    ksession = 
JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env);
CommandBasedHornetQWSHumanTaskHandler humanTaskHandler = new 
CommandBasedHornetQWSHumanTaskHandler(ksession);
                    humanTaskHandler.setConnection(HUMAN_TASK_SERVER_HOST, 
HUMAN_TASK_SERVER_PORT);
          ksession.getWorkItemManager().registerWorkItemHandler("Human 
Task",humanTaskHandler);
return ksession;
          }


The tasks are started with this:
                    BlockingTaskOperationResponseHandler responseHandler = new 
BlockingTaskOperationResponseHandler();
try {
humanTaskClient.start(taskId, user, responseHandler);
                              responseHandler.waitTillDone(75000);
    ...


Can you please tell me what is wrong and how can I solve this.
Maybe this is happening because I'm not disposing of the ksession, but if I do 
that the application fails after completion of the task with a session not 
available error because it was disposed of.
--------------------------------------------------------------

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

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

_______________________________________________
jboss-user mailing list
jboss-user@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to