4 Replies Latest reply on Jan 27, 2006 10:21 PM by Fred Muhlenberg

    task-node Q

    Fred Muhlenberg Newbie

      I'm trying to get a task-node working.

      I build my workflow that includes a task node. If I create tasks (as suggested) in the enter-node action, the task-node doesn't block but I can then read the tasks in the database without error.

      If I assign the task within the task-node handler, the node blocks but I get exceptions when querying the database for tasks.

      If I do nothing in the task-node handler, a task is created but not assigned, the task-node doesn't block, and I can read the task in the database without error.

      What is a correct way to create and assign a task such that the associated task-node blocks in a workflow?

        • 1. Re: task-node Q
          Elmo Novice

          Hi fmuhlenberg,

          If I remember, I think by default tasks will be created automatically in a task-node unless you specify create-tasks attribute to false. You dont need to specify it in a node-enter event. If you want blocking or signalling tasks, you need to specify blocking attribute from the task to true, and signalling to true. Again if I remember correctly, by default tasks are signalling but not blocking. A task is also automatically assigned if you specify a swimlane for it.

          Regards,

          Elmo

          • 2. Re: task-node Q
            brittm Novice

            enazareno is correct. Specifically, a <task-node> has these default properties:
            create-tasks="true"
            signal="last" //completion of the last task also signals the default transition

            And a <task'> element under the <task-node> by default has:
            blocking="no"

            See the user guide, sections 13.3.7 and 13.3.23 for other options and what they all mean.

            With default settings, tasks defined in a <task'> element will be automatically created when the <task-node> is entered. The only reason you wouldn't want this behavior, is if you need to programatically determine which tasks need to be created based on process instance specific data; in that case, you would set create-tasks="false" and would need to create your task(s) with an action handler on the node-enter event. Remember that if you are programatically creating tasks, you'll have to be careful that your blocking boolean (and other properties) is set according to your expectations. Also, while the documentation doesn't provide for a "signaling" property on <task'> in the process definition XML, you can turn signaling on or off for individual taskInstances via the API to suit your needs when you create the tasks in your action handler.

            If you create your tasks programatically and receive errors when trying to retreive them from the database, check that you have specified any appropriate object or circular references, ie:

            taskInstance.setToken(yourToken);

            -Britt

            • 3. Re: task-node Q
              Fred Muhlenberg Newbie

              I'm not having success with your suggestions.




              The configuration below allows creation of tasks upon entering the NotifyApprovers
              node but the node does not block and the Assignment handler is never called.
              I can view the tasks by accessing the (terminated) process instance by calling

               ProcessInstance pi
               pi.getTaskMgmtInstance().getTaskInstances()
              


               <task-node name="NotifyApprovers" create-tasks="false" signal="true">
               <task name="ApproveDocument" blocking="true">
               <assignment class="workflow.assignment.ApproveDocumentAssignmentHandler" config-type="bean"></assignment>
               </task>
               <event type="node-enter">
               <action name="CreateTasks" class="workflow.action.CreateApproverTasksAction" config-type="bean"></action>
               </event>
               <transition name="Process" to="ExecuteDocument"></transition>
               </task-node>
              


              Is there something specific I need to do when creating my tasks that would
              enable blocking at the task-node?


              The configuration below blocks upon entering the NotifyApprovers node and
              calls the Assignment handler. An ApproveDocument task is created but not
              filled with any data (everything except the name is null or empty) and I
              cannot access the task through the process instance. Calling

               ProcessInstance pi
               pi.getTaskMgmtInstance().getTaskInstances()
              


              generates an exception.

              org.hibernate.HibernateException: null index column for collection: org.jbpm.graph.exe.ProcessInstance.instances

               <task-node name="NotifyApprovers">
               <task name="ApproveDocument">
               <assignment class="workflow.assignment.ApproveDocumentAssignmentHandler" config-type="bean"></assignment>
               </task>
               <transition name="Process" to="ExecuteDocument"></transition>
               </task-node>
              




              • 4. Re: task-node Q
                Fred Muhlenberg Newbie

                I found the error of my ways.

                In the action handler of node-enter, I needed to remove code that specified an exit transition (as in remove the code ectx.leaveNode() )

                Now, the workflow pauses as I expect.

                Now, I'm off to look at some other issues related to assignment handlers.

                -fm