6 Replies Latest reply on Sep 23, 2011 11:01 AM by rajan01

    From where taskClient.getTasksAssignedAsPotentialOwner(user, "en-UK", taskSummaryHandler); picks up the tasks

    rajan01

      I am running the HumanTaskService in JBoss and its persistence is done in my Oracle db.

      but when I run process with "UserTasks" in it, and it successfully runs through end.

       

      My ques is when I call the "taskClient.getTasksAssignedAsPotentialOwner(user, "en-UK", taskSummaryHandler);"

      then from where it picks up the data,

      1. from session?

      2. or from db?

       

      If it picks it from session, then please tell me how i persisted the session of the whole "ProcessInstance" in my db and picks the pending task from there.

       

      Below is the code used to pick and complete the "UserTask".

       

                TaskClient taskClient = new TaskClient(new MinaTaskClientConnector("MinaConnector",

                 new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));

                 taskClient.connect("127.0.0.1", 9123);

                     

                BlockingTaskSummaryResponseHandler taskSummaryHandler = new BlockingTaskSummaryResponseHandler();

                taskClient.getTasksAssignedAsPotentialOwner(user, "en-UK", taskSummaryHandler);

                   

                TaskSummary task1 = taskSummaryHandler.getResults().get(0);

                BlockingTaskOperationResponseHandler taskOperationHandler = new BlockingTaskOperationResponseHandler();

                taskClient.start(task1.getId(), user, taskOperationHandler);

                taskClient.complete(task1.getId(), user, null,  taskOperationHandler);

       

       

      Regards.

      Rajan Bansal

        • 1. Re: From where taskClient.getTasksAssignedAsPotentialOwner(user, "en-UK", taskSummaryHandler); picks up the tasks
          salaboy21

          For retrieving the human task information you are using the Human Task services that is running here:

           

          taskClient.connect("127.0.0.1", 9123);

           

           

          That service has its own database decoupled from the session database to store the information about the human tasks. When you connect to that server and call the getTasks... or start.. it go to that database and niteracts with the information there.

          Cheers

          • 2. Re: From where taskClient.getTasksAssignedAsPotentialOwner(user, "en-UK", taskSummaryHandler); picks up the tasks
            rajan01

            Actually I start the "HumanTaskService" with my own in JBoss using the below code:-

             

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

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

                    TaskServiceSession taskSession = taskService.createSession();

             

                     Map vars = new HashMap();

                    Reader reader = new InputStreamReader( StartTaskService.class.getResourceAsStream( "LoadUsers.mvel" ) );    

                    Map<String, User> users = ( Map<String, User> ) eval( reader, vars );  

                    for ( User user : users.values() ) {

                        taskSession.addUser( user );

                    }          

             

                    reader = new InputStreamReader( StartTaskService.class.getResourceAsStream( "LoadGroups.mvel" ) );     

                    Map<String, Group> groups = ( Map<String, Group> ) eval( reader, vars );    

                    for ( Group group : groups.values() ) {

                        taskSession.addGroup(group);

                    }

             

                    MinaTaskServer server = new MinaTaskServer(taskService);

                    Thread thread = new Thread(server);

                    thread.start();

                    taskSession.dispose();

                    System.out.println("Task service started correctly !");

                    System.out.println("Task service running ...YAHOOO..");

             

            and I make the changes in jbpm-human-task-5.1.0.Final.jar's Persistence.xml, so it now points to my db.

            And with this all the task related imformation is stored in my db and I can see it properly.

             

            But the only thing is: if a "Process" having "3UserTasks" then on starting the Process, the db can contain only the imformation about the "first pending" but not others 2.

             

            But as soon as I complete the first task then its status changes to "complete" and then "second pending user" shows in my db.

             

            So please tell me how I store "session db" to my own db.

            • 3. Re: From where taskClient.getTasksAssignedAsPotentialOwner(user, "en-UK", taskSummaryHandler); picks up the tasks
              salaboy21

              you can have two different persistence units.. one for the JPAKnoledgeService and the other to the minaTask Server in this case. That will allow you to configure different databases for the sessions and for the tasks.

              Cheers

              • 4. Re: From where taskClient.getTasksAssignedAsPotentialOwner(user, "en-UK", taskSummaryHandler); picks up the tasks
                rajan01

                In the first reply you told that :

                That(HumanTask) service has its own database decoupled from the session database to store the information about the human tasks.

                 

                Is it possible to re-direct service db to my own db?

                if yes, then HOW???

                 

                Regards.

                • 5. Re: From where taskClient.getTasksAssignedAsPotentialOwner(user, "en-UK", taskSummaryHandler); picks up the tasks
                  salaboy21

                  I've already explained how:

                   

                  "you can have two different persistence units.. one for the JPAKnoledgeService and the other to the minaTask Server in this case. That will allow you to configure different databases for the sessions and for the tasks."

                   

                  Probably right now you have a single persistence unit that includes the SessionInfo and ProcessInstanceInfo entities plus all the Task Related entities. You can basically create to different persistence units and configure different databases for each of them. All that configuration is related with JPA and HIbernate, it is not really dependant on jBPM5.

                  Cheers

                  • 6. Re: From where taskClient.getTasksAssignedAsPotentialOwner(user, "en-UK", taskSummaryHandler); picks up the tasks
                    rajan01

                    Thanks.

                     

                    I ll try with it and revert back if any problem occurs.

                     

                    Regards.