6 Replies Latest reply on Nov 10, 2011 7:27 AM by sridhar532

    Persisting Human Task, letting user to complete after server restart.

    heathcliff

      I'm All!

       

      Here is my scenerio:

      1. Web Application

      2. User is not logged in.

      3. Some Process gets to the point where a user needs to perform some task like to call a client and make an appointment and than provide that data to the system so the process can go on.

      4. Server/application gets restarted.

      5. User loggs in and sees pending tasks to do.

      6. User calls client and makes appointment.

      7. User opens the form and provides appointment data. Submit

      8. Proces receives data and follows to the next task.

       

      From what I've read in user guide User/Human Tasks depand on UI or some WebService to "suspend" the task long enough for the user to finish taks but the user must finish his job before app gets closed. There is no persisting the state of tasn and restoring it when the user comes back later.

       

      Here is my dilema. Are Tasks a work units that must be executed and finished while program is running? Like that process must get to some save point like waiting for message/event before it can be persisted? Or mabe User/Human Task can be suspended, persisted, restored and than finished somewhere in the future??? How should I model that in bpmn2?

      Sth like that models saving to database info that user must fillin the form and waits for message from application:

      SaveToDbThanMessage.png

      This isn't "good", I mean logicaly its correct but for me It should look more like:

      LongHumanTask.png

      This one uses only one element for the whole operation of storing data,retrieving them when user loggsin and entering data to the process. But I cant find a way to implement this behavior using the JBPM5 API. WorkItem and WorkItemManager are provided from the system and they can't be persisted and retrieved later on.

       

      Please help as this is actualy the most important aspect of process construction for me.

      Thx to all

       

      PS: I can use JpaWorkItemManager to load WorkItem and ie complete it but I see no way to store it. Is it stored before entering executeWorkItem() method so I can store its id then finish this function without calling completeWorkItem() and in some future call getWorkItem() to get this work item back and complete it???

       

      How does this mechanism wotk?

        • 1. Persisting Human Task, letting user to complete after server restart.
          salaboy21

          Hi Adam,

          I think that you are mixing a lot of concepts here. Don't get me wrong, it usually happens. The concept of save point also includes Human Tasks. Human interactions are considered as long living activities. For that reason the engine need to wait until the task is completed. As you mention all this waiting happens in a database, so you don't need to be worried about the application is running or not. Obviously the task server needs to be up when the user cames back and want's to interact, but it doesn't mean that needs to be up all time. Right now in jBPM5, we keep two different things persisted.

          1) A knowledge runtime snapshot (SessionInfo in the database)

          2) The status of each particular task inside the task server.

           

          The task server is configured to use persistence by default, but as far as I remember, it's configured to use an in memory database. You should go and change that to a real database like MySQL/Postgres.

          For having persistence of your processes status, that you will need if you are using human tasks interactions you need to use JPAKnowledgeService helpers to keep your sessions persisted in a database.

           

          Greetings.

          • 2. Re: Persisting Human Task, letting user to complete after server restart.
            sridhar532

            Hi , I am also facing a similar issue. After lauching a process in a session , if i Restart my Human Task Server and try Completing the Task by loading the same session, Tasks get Completed but the Workflow does not move forward. Does somebody have any thoughts ?

            • 3. Re: Persisting Human Task, letting user to complete after server restart.
              calca

              Hey,

               

              Could you please give more details about how you are making it? I mean, some test case that can help to understand why it is not moving forward.

               

              After re loading the same session, are you registering the CommandBasedWSHumanTaskHandler again to it?

               

              Demian   

              • 4. Re: Persisting Human Task, letting user to complete after server restart.
                salaboy21

                Yes, as Demian says, you need to re register the listener if the server goes down. Make sure that after the server start again the active session is registered and connected with that instance of the task server.

                Cheers

                • 5. Re: Persisting Human Task, letting user to complete after server restart.
                  sridhar532

                  Hey Demain, This is what am doing.

                   

                  1) Launching the process with a new StatefulKnowledgeSession.

                   

                  2) Calling ksession.dispose after launching the process.

                   

                  3) Claiming the Task for a user

                   

                  4) Restarting my Human Task Server.

                   

                  5) ksession.dispose() method do not make the session as "null". I could see that ksession is still available  during Completing the Task.

                   

                  6) When I Complete the Tasks gets Completed but the Workflow does not move forward.

                  • 6. Re: Persisting Human Task, letting user to complete after server restart.
                    sridhar532

                    I found the solution. After Restarting the Human Task Server we need to load the Session that created the Task and use below code to register the handler once again with the Session and Connect it before performin the Complete Operation

                     

                     

                    CommandBasedWSHumanTaskHandler wsHumanTaskHandler=new CommandBasedWSHumanTaskHandler(ksession);

                    ksession.getWorkItemManager().registerWorkItemHandler("Human Task",wsHumanTaskHandler);

                    wsHumanTaskHandler.connect();