2 Replies Latest reply on Nov 21, 2014 5:17 AM by ivanice

    number of processInstance active

    ivanice

      hi to all,

      like the title, i want to know how I have to do to know the number of the processinstance active during my execution,

      I have a simple process with one script task and two user task.

      the workflow stop the execution when reaching the user task, and just in that moment i must know the number of processIstancess.

      This is the code of my application:

       

       

      public static void main(String[] args) {

       

       

              KieServices ks = KieServices.Factory.get();

              KieContainer kContainer = ks.getKieClasspathContainer();

              KieBase kbase = kContainer.getKieBase("kbase");

       

              RuntimeManager manager = createRuntimeManager(kbase);

              RuntimeEngine engine = manager.getRuntimeEngine(null);

              KieSession ksession = engine.getKieSession();

              TaskService taskService = engine.getTaskService();

       

              ksession.startProcess("com.sample.bpmn.hello");

              ksession.startProcess("com.sample.bpmn.hello");

              ksession.startProcess("com.sample.bpmn.hello");

       

           /////// here I nedd the number of processInstances active  /////////////

              // let john execute Task 1

              List<TaskSummary> list = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK");

              TaskSummary task = list.get(0);

              System.out.println("John is executing task " + task.getName() + task.getProcessId() + task.getProcessInstanceId());

              taskService.start(task.getId(), "john");

              taskService.complete(task.getId(), "john", null);

       

              // let mary execute Task 2

              list = taskService.getTasksAssignedAsPotentialOwner("mary", "en-UK");

              task = list.get(0);

              System.out.println("Mary is executing task " + task.getName());

              taskService.start(task.getId(), "mary");

              taskService.complete(task.getId(), "mary", null);

       

              manager.disposeRuntimeEngine(engine);

              System.exit(0);

       

       

      thanks for the help.