14 Replies Latest reply on Aug 2, 2007 11:19 AM by karstendausb

    task-assign event firing

    smokeman

      When using the "group(whatever)" expression for task assignment, my associated task-assign action is not being called. Is this the expected behavior? I apologize if this has been asked before as I did a search but did not find the answer. Also, I did notice that the EVENTTYPE_TASK_ASSIGN event is only being fired from setActorId in TaskInstance and my action is works fine for "user(whatever)". Below is the process definition.

      <process-definition
       xmlns="urn:jbpm.org:jpdl-3.1" name="esign">
       <event type="task-assign">
       <action name="task-assign-email" class="com.fedex.prs.process.action.EmailOnAssignmentHandler"></action>
       </event>
       <swimlane name="AE" />
       <start-state name="Start">
       <task name="start" swimlane="AE"></task>
       <transition name="start" to="taskNode"></transition>
       </start-state>
       <task-node name="taskNode">
       <task name="task1">
       <assignment expression="group(PIE)"></assignment>
       </task>
       <transition to="end"></transition>
       </task-node>
       <end-state name="end"></end-state>
      </process-definition>


        • 1. Re: task-assign event firing
          cpob

          From my understanding, you have the <event ...> element in the wrong section.

          task-assign events have to be inside the element to identify what task it is associated with.

          http://docs.jboss.com/jbpm/v3/userguide/jpdl.html#task.element Look at the user guide's schema layout. They have the event element inside the task element.

          event element [0..*] supported event types: {task-create|task-start|task-assign|task-end}. Especially for the task-assign we have added a non-persisted property previousActorId to the TaskInstance


          • 2. Re: task-assign event firing
            cpob

            Then again, http://docs.jboss.com/jbpm/v3/userguide/jpdl.html#processdefinition.element does show events as being able to be defined in the process definition, but not much detail specifically there.

            • 3. Re: task-assign event firing
              cpob

              Once again, I'll post to this thread, sorry for all the replies.

              I tested it out, where you have your event is ok, that works fine. (At least it does with user(bert) for me).

              Now, with a group, perhaps it doesn't fire because it is technically not being directly assigned to anyone, just placed in an actor pool/group. When an actor/user sees this task available in their pool, and then grab it to use, you are supposed to assign it to that user at that point, and BAM, that's when the real task-assign event should occur. At least, that's what I think.

              • 4. Re: task-assign event firing
                kukeltje

                 

                that's when the real task-assign event should occur. At least, that's what I think.


                Maybe, maybe not. Differentiating, not with multiple events, but maybe some other parameter) between individually assigned tasks and pooled tasks could be interesting

                • 5. Re: task-assign event firing
                  cpob

                  Ronald, so when it is assigned to a group, that event should be firing also?

                  • 6. Re: task-assign event firing
                    kukeltje

                    currently it (obviously) does not, but I would not mind having it fire with the restriction that one can determine if it was a pooled assingment event. We could also add another event (poold-task-assign), but then you have to add two eventhandlers if both can happen.

                    I think the latter is easier to implement

                    • 7. Re: task-assign event firing
                      cpob

                      I was going to agree with the 2nd event for group assign events, but then I started debating myself.

                      Either way, I agree that something should be done.
                      I just searched the JIRA and didn't see anything related to task-assign and pooled/groups.

                      smokeman, in the meantime, you could always just add the firing of the event from the TaskInstance code you referenced in setActorId(...) into the setPooledActors(...) if you can/are compile the jBPM source for your project.

                      • 8. Re: task-assign event firing
                        smokeman

                        The reason I brought this up is that I need to send an email to all users of a group letting them know that a task has been assigned to the group. I was trying to use the task-assign event, but you know the rest. Yes, I could add this to TaskInstance myself, but wanted to see if this behavior was expected and if so, whats the consensus on adding this event firing for group assignment to jBPM. I personally think that jBPM should fire the event regardless of whether its user or group assigned. I also dont care if its a separate event in that I can always test getActorId and getPooledActors in my action handler. By the way, I noticed that a send mail tag is going to be added in the near future. If thats the case, will it have a task specfic behavior and if so, will it work for group assigned tasks.

                        • 9. Re: task-assign event firing
                          cpob

                          I'd suggest you create a JIRA issue (after making sure there's none previously, I did a quick search w/ no results).

                          If you do, I'll vote on it, because I support that something needs to be done about it.
                          It could lead into a world of debate as to which way to handle the event though, which isn't a bad thing.

                          • 10. Re: task-assign event firing
                            karstendausb

                             

                            "cpob" wrote:

                            If you do, I'll vote on it, because I support that something needs to be done about it.


                            I would agree. The semantics of "task-assign" are not clear from my point of view.

                            Case 1:

                            <swimlane name="swimlane22">
                             <assignment pooled-actors="jan,nina"/>
                            </swimlane>
                            <task name="SwimlaneTestTask" swimlane="swimlane22"/>
                            


                            Case 2:
                            <task name="pooledactorassignmenttest">
                             <assignment pooled-actors="joerg,peter"/>
                            </task>
                            


                            Both cases specify group assignment and do not specify an concrete actor.
                            But in the first case a "task-assign"-event is fired, in the second case it is not.

                            I looked through TaskInstance.java, this seems to be implemented: copySwimlaneInstanceAssignment(swimlaneInstance) calls setActorId, and that is where the event is fired (though no actorid is actually set).



                            • 11. Re: task-assign event firing
                              kukeltje

                              sounds more like just a small bug to me.

                              • 12. Re: task-assign event firing
                                karstendausb

                                Sorry, didn't get it: What exactly is the bug? That the task-assign-event is fired in case 1, or that it is not fired in case 2?

                                • 13. Re: task-assign event firing
                                  kukeltje

                                  the latter, see my previous posts. If you take that into account isn't the task-assign event very clear? ;-)

                                  • 14. Re: task-assign event firing
                                    karstendausb

                                     

                                    "kukeltje" wrote:
                                    the latter, see my previous posts. If you take that into account isn't the task-assign event very clear? ;-)


                                    Yes, indeed. VERY clear ;-)

                                    I am also in favour of the idea that the engine should have a seperate event for group-assignment. However, the differentiation in "task-assign"-event firing between an assignment being done in a task and being done in a swimlane is probably a bug.

                                    I created two junit-tests and a Jira issue for this:
                                    http://jira.jboss.com/jira/browse/JBPM-1032