1 2 3 Previous Next 32 Replies Latest reply on Sep 7, 2012 1:43 AM by leaf-xue

    understanding taskclient

    odelyaholiday

      I understood that in order to run HumanTask I have to register an handler. for example:

       

       

       StatefulKnowledgeSession session = session.getWorkItemManager().registerWorkItemHandler("Human Task", new CommandBasedWSHumanTaskHandler());

       

       

      I looked in the implementation of the class and realized that CommandBasedWSHumanTaskHandler in connect() method connects to port 9123 and starts a client task.

       

      However, I saw in some examples, that I need to initialize this task:

       

      TaskClient client = new TaskClient(new MinaTaskClientConnector("client 1",new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));
        client.connect("127.0.0.1", 9123);
      

       

      When do I have to invoke this TaskClient manually?

       

      Who kills the task so it wouldn't sit on the same port with other tasks?

        • 1. understanding taskclient
          krisverlaenen

          These are two different things.  The human task handler is an integration component that is registered at the engine and communicates with the human task service.  You should only register it, after that it will handle the communication between the process engine and the task service.

           

          The task client however is a client you can use to communicate with the task service, like for example query all tasks or complete a task etc.  Note that you don't need this is you use a task UI (as this will instantiate a client like this for you if you click the buttons etc.).

           

          Kris

          • 2. understanding taskclient
            odelyaholiday
            Note that you don't need this is you use a task UI (as this will instantiate a client like this for you if you click the buttons etc.).

            Can you please explain more?

            • 3. understanding taskclient
              salaboy21

              What I think that Kris is trying to explain is that if you use the gwt jbpm console, the buttons there already instantiate a task client to interact with your created human tasks.

              Greetings.

              • 4. understanding taskclient
                odelyaholiday

                It means that every time that I invoke a task - I have to start

                 

                TaskClient client = new TaskClient(new MinaTaskClientConnector("client 1",new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));

                 

                ?

                 

                Or it should be done once?

                 

                since in the Emergency application it is being invoked only once when the user logs-in to TaskUIPanel!

                • 5. understanding taskclient
                  salaboy21

                  You can do it once when the application start.. and check everytime youwant to use it is still active.. The task client creates a connectionwith the task server via socket so if the connection is interrupted youneed to connect it again. For this you can implement your own mechanismbased on the kind of environment where you are running the application.The emergency service application it's just a demo app that connect itonce and it suppose that the connection is alive forever.

                  • 6. understanding taskclient
                    salaboy21

                    The task clients connects to the task server. The server support  multiple clients, but you can close the client with client.disconnect() after you finish the interaction with the server.

                    • 7. understanding taskclient
                      odelyaholiday

                      Thanks.

                       

                      I am still not sure - when do I have to start and when to disconnect from a taskclient?

                      • 8. understanding taskclient
                        salaboy21

                        You have the task client right?

                        You need to be connected in order to use it.. When you finish the interaction you can disconnect it.

                        The common interactions are start the task (that means that an user will start working in a specific task) and complete task (that means that the user will end the current task). Once again, for calling this start and complete task methods, you need to be connected. Depending on your application, you can connect that task client when the app start (or restart) or you can connect the task client to the server each time that you want to interact.

                        Greetings.

                        • 9. understanding taskclient
                          odelyaholiday

                          In a regular web application - pet shop for instance - what would you recommend?

                          • 10. understanding taskclient
                            salaboy21

                            For each user that logs in to the application you should create a task client and disconnect it when the users logs out. That will be my first option.

                            • 11. understanding taskclient
                              odelyaholiday

                              Thanks I appreciate your help.

                              • 12. understanding taskclient
                                odelyaholiday

                                Does that mean that for each client I have to check what port on my machine is not listening? what if I have 100000 users logging at the same time?

                                • 13. understanding taskclient
                                  salaboy21

                                  Probably you are missing something. you have just one server in the 9123 port right? then you can connect any number of clients to that server?

                                  The only thing that the client must know is the server IP and Port..

                                  Why do you want to check the ports that are being used in your machine?

                                  Are you trying to start multiple task server? (task server are the only ones that require to have a free port to run.. so if you want to have multiple task server you require multiple ports, only if you want to do that in the same machine)

                                  Cheers.

                                  • 14. understanding taskclient
                                    odelyaholiday

                                    and what about StatefulKnowledgeSession - shall I have one running for web application (like pet shop) or for each client should I start and end it?

                                    1 2 3 Previous Next