4 Replies Latest reply on Feb 9, 2011 5:25 AM by mohreece

    Issue in leavenode from a Task node on task-create event

    yogitabartake

      Hi All,

       

      I am using jBPM 3.2.7.

       

      I am using only tasknodes in my workflow.Of these activites some activities need human intervention and some need to be automatic.

      As I am using task node the execution waits. But when I want an automatic activity the execution should move ahead.

      So In the task-create event of the task node there is a class mapped where I have the required business logic and at the end of the class I am using executioncontext.leavenode() to go the next activity. What happens is the execution moves ahead till it gets a useractivity (which is again a task node but without the action class mapped) and then gives an error "null".

       

      I cant use a node for automatic activities in my case so please suggest a solution to move ahead from a tasknode.

      Thanks in advance for any help!!

        • 1. Issue in leavenode from a Task node on task-create event
          mohreece

          Hi Yogita,

           

          First off, I'd be really asking myself why you cannot use regular Nodes, as these are the exact node type that is intended for this type of work. Without any reason for that, I can't help you on that - but it actually seems the right thing to find out here.

           

          If you want to get out of a TaskNode programmaticaly, leaving the node yourself is not the best way, as this leaves the TaskNode's internal administration in an undefined state (hence the null). What you should do is to call the end() method on the TaskInstance, and allow the TaskNode to close shop itself before moving on.

           

          Hope this helps a bit!

           

          Regards,

          Maurice

          1 of 1 people found this helpful
          • 2. Re: Issue in leavenode from a Task node on task-create event
            yogitabartake

            Thanks for the Reply

             

            We tried using node for automatic activities but our application needs to show the history of what path a process execution has taken. With node we did not find any jbpm table which would show the log of executed nodes.

            So we took this approach...If u know of any other solution for this please do let me know.

             

            Well, we tried using taskInstance.end() in the Action handler but it gave Null pointer exception since in the handler was being called on a task-create event. Then we tried using the same in the class that implements AssignmentHandler. In this case what happens is that the execution moves ahead from the task till it gets user activity(for which the AssignmentHandler class is not mapped) but the execution starts again from the 1st automatic activity from where we are doing taskInstance.end() and goes in an infinite loop.

             

            E.g

             

            public class TaskAssignHandler implements AssignmentHandler

            {

            private static final long serialVersionUID = 1L;

            public void assign(Assignable assignable, ExecutionContext executionContext)

            {     

               executionContext.getTaskInstance().end();

             

             

            }

             

             

             

            I am assuming here that the AssignmentHandler(which I have mapped in that Handler Property of the task) class gets called on task-assign event and by this time the task has got created for me to end it from here. Please correct me if I my assumption is incorrect.

            Thanks a lot!!

            Regards,

            Yogita

             

             

             

            • 3. Re: Issue in leavenode from a Task node on task-create event
              yogitabartake

               

              This is really urgent...please give some suggestions.

              • 4. Re: Issue in leavenode from a Task node on task-create event
                mohreece

                Hi Yogita,

                 

                Sorry it took a while for me to get back to you...

                 

                1) If you need to be able to to show the history of your process executions, process logging (which is different from logging with e.g. Log4J) is something worth while looking at. See chapter 16 of the user guide on how that is done.

                If that requirement is the only thing keeping you from using regular Nodes, I strongly recommend you try this and switch to Nodes. It'll make your life much easier!

                 

                2) Why the TaskInstance cannot be ended from where you try it isn't completely clear to me. Assignment isn't part of the TaskInstance's lifecycle, so book-keeping should be up-to-date once the creation step is completed - but I'm not completely sure about that in case of the task-created event, to be honest.

                I know that it is possible to have an actor ask for the TaskInstances that are assigned to it (that's pretty much by design ), and the ones that are returned can be ended without a problem. I understand that your TaskInstances need to be ended in a way that is more automatic than what originally is intended, but if you must: would polling be an option (i.e. if you find that your event driven doesn't give you the correct result)?

                 

                Good luck,

                Maurice