1 Reply Latest reply on Jul 31, 2012 3:32 AM by awulms_work

    How to list human tasks with HQ API?

    awulms_work

      Hi,

       

      I have created a human task using the "human task view" plugin in eclipse. The task is made for the user "krisv". It shows-up both in the "human task view" in eclipse and in the jbpm console when I login with krisv user (based on the demo/evaluation set-up of jBPM 5.3). The task is in status reserved.

       

      I have now made a small java program that connects to the human task service on localhost on port 5445. The program is supposed to get all reserved tasks for krisv user but it returns 0 results.

       

      Here is the code that I use:

       

      public static void main(String args[])

      {

        String user="krisv";

        String language="en-UK";

        List<Status> status = Arrays.asList(new Status[] { Status.Reserved });

       

        System.out.println("*** Connecting to human task client with HornetQ protocol");

        SyncTaskServiceWrapper tk = new SyncTaskServiceWrapper(new AsyncHornetQTaskClient());

        tk.connect("127.0.0.1", 5445);

       

        System.out.println("*** Getting " + status + " tasks for " + user + " with language " + language);

        List<TaskSummary> tasks = tk.getTasksAssignedAsPotentialOwnerByStatus(user, status, language);

        tasks.addAll(tk.getTasksOwned(user, status, language));

       

        System.out.println("*** Got " + tasks.size() + " tasks");

      }

       

       

      It shows at the end "got 0 tasks"

       

      Any idea what I'm doing wrong?

       

      Any help is appreciated.

       

      Thanks and kind regards,

      Alex

       

       

      PS: Can you kindly add jBPM 5.3 to the list of "Categories" in this forum?

        • 1. Re: How to list human tasks with HQ API?
          awulms_work

          Hi,

           

          I have found a solution. Apparently I must specify a human task client (session) id to the constructor of the AsyncHronetQTaskClient class. It works fine with following code:

          public static void main(String args[])
          {
            String user="krisv";
            String language="en-UK";
            List<Status> status = Arrays.asList(new Status[] { Status.Reserved });
           
            String clientSessionID = UUID.randomUUID().toString();
            System.out.println("*** Connecting to human task service with HornetQ protocol, using client session ID: " + clientSessionID);
            SyncTaskServiceWrapper tk = new SyncTaskServiceWrapper(new AsyncHornetQTaskClient(clientSessionID));
            tk.connect("127.0.0.1", 5445);
           
            System.out.println("*** Getting " + status + " tasks for " + user + " with language " + language);
            List<TaskSummary> tasks = tk.getTasksAssignedAsPotentialOwnerByStatus(user, status, language);
           
            System.out.println("*** Got " + tasks.size() + " tasks");
           
            System.out.println("*** Closing connection");
            try {
             tk.disconnect();
            } catch (Exception e) {
             System.out.println("*** Error during disconnect: " + e.getMessage());
            }
            System.exit(0);
          }

           

          Thanks and kind regards,

          Alex

           

          PS: I found the solution thanks to the jbpm-examples module, in which the human task example also specifies a (hard-coded) client-session-id to the constructor.