5 Replies Latest reply on Jul 17, 2012 3:39 AM by cristiano.nicolai

    Continue process Instance

    marcosdutto

      Hi,

      I have a simple process with 3 User Tasks. I am trying to load the session and continue with the process but it doesn't work.

      When i complete a task from a process created in the same execution of the program it works. But when I complete a User task from a process saved previously it doesn't work. I think that the task is completed but jbpm doesn't know where it has to continue or something like that.

       

      Doing a test i use the lines:

                processInstance2 =  (RuleFlowProcessInstance) ksession.getProcessInstance(XX);

                NodeInstance nodeInstance = processInstance2.getNodeInstance();

       

      and the node Instance is always an instance from the first User Task. Moreover, being at the second Task of my processInstance i saved the session after that i loaded that session and the same thing happened (the node Instance was an instance from the first User Task).

       

      This is my piece of code:

       

      public static final void main(String[] args) throws Exception {        
              startUp();
              KnowledgeBase kbase = readKnowledgeBase();
              EntityManagerFactory emf = Persistence.createEntityManagerFactory( "org.jbpm.persistence.jpa" );
              Environment env = KnowledgeBaseFactory.newEnvironment();
              env.set(EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
              StatefulKnowledgeSession ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(2, kbase, null, env );
              ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new CommandBasedWSHumanTaskHandler(ksession));
      
              JPAWorkingMemoryDbLogger dblogger = new JPAWorkingMemoryDbLogger(ksession);
              
              Map<String, Object> params = new HashMap<String, Object>();
                      Thread.sleep(1000);
              ksession.addEventListener(new GecosProcessListener());
              ksession.signalEvent("Trigger", null);
              Thread.sleep(2000);
              RuleFlowProcessInstance processInstance =  (RuleFlowProcessInstance) ksession.startProcess("simple",params);
              
              Thread.sleep(1000);     
              System.out.println("Id session: "+ksession.getId());
              System.out.println("Process Instances: "+ksession.getProcessInstances().size());
              System.out.println("Process Instance ID: "+processInstance.getId());
                ...
                ...
                ...
              dblogger.dispose();
              ksession.dispose();
              System.exit(0);
        }
      

       

       

      sdlgjh

        • 1. Re: Continue process Instance
          swiderski.maciej

          you need to ensure that session is active and HT handler is connected to the task server at the time when you complete your tasks.

           

          HTH

          • 2. Re: Continue process Instance
            marcosdutto

            How can i check that?

            if i do

               ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new CommandBasedWSHumanTaskHandler(ksession));

            my HT handler is created and i think that it is connected.

             

            how can i check that session is active?

             

            Thanks

            • 3. Re: Continue process Instance
              swiderski.maciej

              Try invoking method connect on CommandBasedWSHumanTaskHandler before registering on the session - assuming you use default configuration. if that is not the case use configureClient method on the handler by submitting your configured and connected client.

               

              HTH

              • 4. Re: Continue process Instance
                shijuj

                For human task serveice you should start  the human task server before you register the handler.

                 

                Folowing is the code for starting the Mina Task server.

                 

                 

                 

                 

                 

                EntityManagerFactory emfTask = Persistence.createEntityManagerFactory("org.jbpm.task");

                TaskService taskService =  new TaskService(emfTask,SystemEventListenerFactory.getSystemEventListener());

                 

                TaskServiceSession taskSession = taskService.createSession();

                MinaTaskServer minaTaskServer = newMinaTaskServer(taskService,9123);

                 

                Thread thread =  new Thread(minaTaskServer ));

                 

                thread.start();

                 

                 

                 

                 

                • 5. Re: Continue process Instance
                  cristiano.nicolai

                  Hi Marcos,

                   

                  I was facing a similar problem and turns out the problem was related to the following issue https://issues.jboss.org/browse/JBPM-3706

                  If you're using JPA2, just change your JBPMorm-JPA2.xml to use temporal TIMESTAMP instead of DATE.