5 Replies Latest reply on Aug 21, 2009 5:06 AM by kukeltje

    jBPM4 - Task Escalation with Timer

    djcye

      Hi,
      i try to figure out how to implement a time related reassignment of a task.
      had someone already success in implementing this ?

      currently working on:

      first idea: use the assignmenthandler.. but i cant put it in the context of a timer..

      second idea: use a second (java) node to reassing the first

      <task>
       <transition to="escalate java node">
       <timer duedate="10 seconds" />
       </transition>
      </task>


      third idea: reassignment in the same task node
      <task>
      <on event="timeout">
       <timer diedate="5 seconds" />
       <eventlistener ...>
      </on event>
      </task>


      in the second and third idea i have to access the task for reassignment without reassignment handler and i have to find the taskid somehow (use taskquery with processinstanceid and name ?).

      is there an easier way ?

      thx!

        • 1. Re: jBPM4 - Task Escalation with Timer
          kukeltje

          in a delegationclass (e.g. actionhandler within a time) you can do something like

          context.getToken().getNode()

          and if it is a tasknode do everything with it...

          • 2. Re: jBPM4 - Task Escalation with Timer
            kukeltje

            oeps. my proposal was for 3... not sure for 4 though.... I think the api should have something, just not played with this

            • 3. Re: jBPM4 - Task Escalation with Timer
              djcye

              i studied the docs and the only way to assign tasks is through the TaskService or the assignmentHandler. i tried to put the assignmenthandler inside a "timeout event" section but that isnt valide.

              well i also tried to use the eventhandler approach (to use the TaskService) without success. All TaskQuerys result in 0. Testet the same TaskQuery from a EJB Web-Service and it showed more than 0, so its not the querys fault ^^". perhaps this kind of operations is not supported from inside the handlers.

              so the only option i see is to put the

              InitialContext ctx = new InitialContext();
              ProcessEngine processEngine =(ProcessEngine)ctx.lookup("java:/ProcessEngine");
              TaskService taskService = processEngine.getTaskService();
              TaskQuery b = taskService.createTaskQuery();
              b.assignee("peter");
              List<Task> c = b.list();
              System.out.println(c.size());
              


              one additional question: if i use a transition timer inside a task node and the timer fires. will the task be completed / deleted ?

              i tried to figure it out on the server. after the timer fires the task still remains in the assigned groups but cant be claimed anymore. exceptions when trying to claim:

              16:17:22,953 INFO [DefaultCommandService] exception while executing command org.jbpm.pvm.internal.cmd.AssignTaskCm
              d@7aba71
              org.jbpm.api.JbpmException: task 55 does not exist


              actualy task 55 realy doesnt exist. the taskid i try to claim is 59 O_o

              and

              16:27:02,218 ERROR [[Resteasy]] Servlet.service() for servlet Resteasy threw exception
              org.jboss.resteasy.spi.UnhandledException: java.lang.RuntimeException: Unexpected invocation exception: null


              and

              Caused by: org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [org.jbpm.pvm.internal.m
              odel.ExecutionImpl#75]


              well i think the task gets deleted. but i am not sure.


              • 4. Re: jBPM4 - Task Escalation with Timer
                djcye

                sry, ignore the "so the only option i see is to put the.." at the moment i see none XD

                • 5. Re: jBPM4 - Task Escalation with Timer
                  kukeltje

                  djcye,

                  It is very hard for us to understand everything if we just see snippets/partial stacktraces etc... please make a unittest as described in http://www.jboss.org/index.html?module=bb&op=viewtopic&t=158610 so we can have a better look and mayve try ourselves.