13 Replies Latest reply on Jan 8, 2012 5:02 AM by Adam Bach

    Guide to creating custom human task service

    Michael G Novice

      Hello,

       

      I was wondering if there is documentation on how one would go about creating a custom human task service.  I found this document and it gives some good explainations on things but i didn't seem to include anything that would show how to create my own task server. (unless i missed it)

       

      http://docs.jboss.org/jbpm/v5.2/userguide/ch.Human_Tasks.html

       

      Would taking a look at the mina task server source be my best bet?

       

      Thanks

        • 1. Re: Guide to creating custom human task service
          Mauricio Salatino Master

          The first question that I have for you if why do you want to create your own implementation?

          You can adapt the current one if doesn't fits your needs and we can help you with that. If you want to create your own service you can and then using a workItemHandler you will need to create the connectors to talk with your new service as any other WorkItemHandler communication with an external service. But once again, why do you want to do that?

          Cheers

          • 2. Re: Guide to creating custom human task service
            Michael G Novice

            Thanks for the reply.

             

            Ok, my situation is that i want to run in an environment that already provides a front end portal to handle user tasks, so we won't be using the provided consoles for monitoring nor starting, etc... the processes and tasks.  We don't want to use the provided method to create the forms (flt) but rather take the task parameters and pass them along to the front end portal which will provide the user interface and notifications that the user has a task.  So once the user completes their task, etc... any return params will be sent back to the process engine and continue.

             

            So i thought creating my own task server would allow me to perform this type of integration.  Now i'm still learning the ropes so i don't know if jbpm ootb provides this capability or not.  If it does could you explain how i would go about achieving the above.

             

            Thank you very much.

            • 3. Re: Guide to creating custom human task service
              Mauricio Salatino Master

              Hi Michael,

              If you already have an accesible component that handles the Human Tasks, that's ok, there is no problem about integrating the engine with your component, but you need to be sure that you component is accessible via some APIs (java, ws, corba, whatever) and the component handles the lifecycle of those interactions (task-started, completed, suspended, etc). If your component do that, the only thing that you need to do is to create an implementation of the WorkItemHandler interface that will do the integration.

              Cheers

              1 of 1 people found this helpful
              • 4. Re: Guide to creating custom human task service
                Mauricio Salatino Master

                With that I mean, you don't need to create your own task server, because you already have a component that do that.. you only need the connector to the engine communicates with it (WorkItemHandler == connector)

                • 5. Re: Guide to creating custom human task service
                  Maciej Swiderski Master

                  Michael, looking at what you described here is not really a question about task server but more task client. Process engine can utilize existing implementation of task server to maintain task life cycle and your portal solution would be more to provide presentation layer for your users. Whenever user makes an action, task client should be used to inform task server about what happened and then task server notifies process engine to continue with the flow. Task client should be used to get task list, task details (including variables, etc) as embedded component of your portal.

                   

                  That means that you need to pass variables back and forth between portal and task engine. One interesting addition to that is smart tasks by Mauricio, Demian and Esteban (apologies if I missed someone involved in that project) that provides abstraction layer over jbpm task client stuff (and mouch more than that).

                   

                  HTH

                  1 of 1 people found this helpful
                  • 6. Re: Guide to creating custom human task service
                    Michael G Novice

                    Interesting.  I will take a look at the smart tasks.

                     

                    From your explaination it sounds like i should be able to use the task server provided and follow some of the task client examples. 

                     

                    Thanks i will give that a go.

                    • 7. Re: Guide to creating custom human task service
                      Michael G Novice

                      Ok, reading a bit more it looks like i need to create a TaskClient to access the task service and from there i should be able to then redirect things to my portal application and progress the process.

                       

                      Thanks for the help.

                       

                      So another quick question related to this, if i wanted to use the hornetq task service do i need to register the workitem handler or can i use the default one.  (Following this example - http://docs.jboss.org/jbpm/v5.2/userguide/ch.Human_Tasks.html)

                       

                      I prefer the benefits of using hornetq.

                       

                      Thanks

                      • 8. Re: Guide to creating custom human task service
                        Mauricio Salatino Master

                        Hmm .. you don't need to use the hornetQ implementation. If you are going to use your own module to handle human task, just choose the best transport that you component is already exposing and create a task client that uses that transport to do the communications.

                        The current task clients implementation will not help you to solve your problem, because you need to connect with you already implemented component.

                        Cheers

                        • 9. Re: Guide to creating custom human task service
                          Michael G Novice

                          I was planning on not creating my own task service since Maciej suggested that i can just query the task service and get the necesarry info out and back in and to progress the process.  So i can utilize what exist already.  Reading up there seems to be a couple existing task services and Hornetq wa one that we wanted to use. 

                           

                          So with that doesn the current human task work item work with it or is it only going to work with the mina task service?  We want to keep the existing process editor in eclipse as is, so if if we switched out mina for hornetq with that affect the eclipse editor.  trying to minimize the changes and coding necessesary.

                           

                          Thanks

                          • 10. Re: Guide to creating custom human task service
                            Maciej Swiderski Master

                            By default work item handlers use Mina connector for task client. So there are two options:

                            • create your workitem handler implementation that just extends default and override connect method
                            • for some work item handlers (for instance WSHumanTaskHandler) there is a dedicated method to set task client that can be used

                             

                            What you need to do is to create task client instance that utilize hornetq client handler and client connector:

                             

                            TaskClient client = new TaskClient(new HornetQTaskClientConnector("HornetQConnector",
                                                new HornetQTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));
                            
                            taskClient.connect(host, port);
                            
                            
                            // this method is not available for all handlers
                            handler.setClient(client);
                            

                            HTH

                            • 11. Re: Guide to creating custom human task service
                              Michael G Novice

                              Ok, so if i understand what you are saying would i be able to still create the process from any of the editors (eclipse or web) put in a human task node,

                              and in code start the process but register the extended workitem handler that overrides the default.

                               

                              like so - ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new MyCustomHornetQHumanTaskHandler());

                               

                              and this will allow me to then connect to hornetq?

                               

                              Or do i need to override the handler and then repackage the jbpm lib in order to use it?

                               

                              Thanks

                              • 12. Re: Guide to creating custom human task service
                                Maciej Swiderski Master

                                Yes, registering should be enough. No need to repackage jbpm.

                                • 13. Re: Guide to creating custom human task service
                                  Adam Bach Novice

                                  From what I understand You have already working web UI for human tasks, so You should already have support for showing available actions like suspend/resume/finish etc... than You actualy dont need humantaskservice. You only need to put in your services 2 methods for starting and finishing human task, just implement humantaskhandler. Beside that get some human task state object to your model to save intermediate states between start and finish.

                                   

                                  Adventages? You dont need to stick to presetted human task flow which You can't change. Every company and even every task has different stepps possible and not every body can be suttisfied with standard solution.

                                  You could even use simpler and yet possibly more powerfill option: use subprocesses instead of standard user tasks, those subprocesses could consist of different possible human task flows so you even dont have to implement complicated flow login int your code. Here human task implementation would be simply start/finish support. Flow would be taken care by designed process which is better for business ppl who could change that human task flow or create new ones when needed whithout help from technical ppl or even server restart.