3 Replies Latest reply on Jun 26, 2012 7:33 AM by swiderski.maciej

    Timer BoundaryEvent and User Tasks

    jett

      Does anyone know if Timer BoundaryEvents can work when attached to User Tasks? I created a simple process model (see attached) with the said scenario and KnowledgeBuilder is unable to parse the process file.

       

      java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

                at java.util.ArrayList.RangeCheck(ArrayList.java:547)

                at java.util.ArrayList.get(ArrayList.java:322)

                at org.jbpm.bpmn2.xml.ProcessHandler.linkBoundaryEvents(ProcessHandler.java:333)

                at org.jbpm.bpmn2.xml.ProcessHandler.end(ProcessHandler.java:144)

                at org.drools.xml.ExtensibleXmlParser.endElement(ExtensibleXmlParser.java:417)

         ...

       

      I traced into source the issue and it fails in the following method from within ProcessHandler.java

       

          public static void linkBoundaryEvents(NodeContainer nodeContainer) {

              for (Node node: nodeContainer.getNodes()) {

                  if (node instanceof EventNode) {

                      final String attachedTo = (String) node.getMetaData().get("AttachedTo");

                      if (attachedTo != null) {

                                String type = ((EventTypeFilter)

                              ((EventNode) node).getEventFilters().get(0)).getType();

       

      There appears to be no issues attaching Timers to other types of tasks.

      (edited) I just tried it for other task types (Service Task, ... ) and I am getting the same error. The only way I can get it to work is if I put the nodes inside a subprocess and attach the BoundaryEvent to the subprocess. I looked at all the samples used in the junit tests of JBPM and all samples have boundary events attached to a subprocess. Is this a JBPM5 limitation (as of the current version) or is this a BPMN rule? (I remember distinctly seeing samples of BPMN2 diagrams with timers attach to tasks.

       

      Thanks in advance for any insights into this.

        • 1. Re: Timer BoundaryEvent and User Tasks
          swiderski.maciej

          Yes, from 5.3 boundary events are supported on tasks. Looking at your process it seems like there is not timer definition given:

           

               <boundaryEvent id="boundaryEvent_1" name="Boundary event" attachedToRef="userTask_1"> 
                <outgoing>sequenceFlow_4</outgoing> 
                <timerEventDefinition id="timerEventDefinition_1"/> 
              </boundaryEvent>
          

           

          and it should look like this:

           

              <boundaryEvent id="_4" name="TimerEvent" attachedToRef="_2" >
                <timerEventDefinition>
                  <timeCycle xsi:type="tFormalExpression">500ms</timeCycle>
                </timerEventDefinition>
              </boundaryEvent>
          

           

          once you'll fix the process definition you'll be able to execute boundary events on a task.

           

          HTH

          • 2. Re: Timer BoundaryEvent and User Tasks
            jett

            Thanks Maciej. That did the trick.

             

            I didn't put in the definition earlier because I was creating a script that automatically included other required nodes (e.g. message, operation, and item definitions) based on the activities in the process. The process file I attached was actually an output of that script. It looks like I also need to automatically include a timeCycle node when I find a timerEventDefinition.

             

            The only item I'm stuck now is how to get two start nodes to work (one "normal" start and one message start).

             

            Again, many thanks for your your response.

            • 3. Re: Timer BoundaryEvent and User Tasks
              swiderski.maciej

              For multiple start events you need to wait for 5.4 version or use snapshot version from master as it was introduced quite recently.