3 Replies Latest reply on Aug 30, 2012 7:00 AM by Andrea Carpineti

    How to get external event to cancel human task and progress process

    stevearoonie Newbie

      Hi all,

       

      I my application I have the possibility that whilst a process is sitting at a Human Task node that an external event could make that task no longer necessary, in which case I want my workflow to progress. I have attempted to do this using the following pattern:

       

      Screen shot 2012-08-27 at 2.20.27 PM.png

       

      The gateway is an XOR. When I test this by completing Task 1, the process correctly moves to Task 2. If instead I trigger the event (via ksession.signalEvent("TaskPerformed", null, processInstance.getId());)

      I get the sub-process End node being triggered but Task 1 is still active and Task 2 is not entered.

       

      To test this I am just using a customized version of ProcessTest that is created in a new jBPM Project.

       

      If instead I try processInstance.signalEvent("TaskPerformed", null); I get an NPE in ProcessInstanceImpl (kruntime is null).

       

      Can anybody tell me what I am doing wrong, or possibly another way I can produce the behaviour I desire?

       

      thanks in advance

      Steve

        • 1. Re: How to get external event to cancel human task and progress process
          stevearoonie Newbie

          I solved this by using Guvnor instead of eclipse to edit the process which allowed me to do the following:

           

          - add a boundary event on Task 1 catching the TaskPerformed event

          - set cancelActivity="true" for the event

           

          Screen shot 2012-08-27 at 3.54.25 PM.png

           

          Much simpler!

          • 2. Re: How to get external event to cancel human task and progress process
            Maciej Swiderski Master

            you should put a boundary interrupting event on your user task (or sub process if needed) to have alternative flow taken in case of external event and ensure that user task will be canceled.

             

            HTH

            • 3. Re: How to get external event to cancel human task and progress process
              Andrea Carpineti Newbie

              Trying to use a boundary intermediate event on my user task (as used by Steve) I get an error when I try to build the package

              400 An error occurred building the module.

              the server.log reports

              12:52:17,206 ERROR [stderr] (http-localhost-127.0.0.1-8080-5) java.io.NotSerializableException: org.jbpm.bpmn2.xml.ProcessHandler$1

               

              12:52:17,206 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)     at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)

               

              [...]

               

               

              12:52:17,237 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:952)

               

              12:52:17,237 ERROR [stderr] (http-localhost-127.0.0.1-8080-5)     at java.lang.Thread.run(Thread.java:662)

               

              12:52:17,237 INFO  [stdout] (http-localhost-127.0.0.1-8080-5) ERROR 30-08 12:52:17,237 (LoggingHelper.java:error:67)      An error occurred building the module [defaultPackage]: org.jbpm.bpmn2.xml.ProcessHandler$1

               

              12:52:17,237 INFO  [stdout] (http-localhost-127.0.0.1-8080-5) ERROR 30-08 12:52:17,237 (LoggingHelper.java:error:74)      Service method 'public abstract org.drools.guvnor.client.rpc.BuilderResult org.drools.guvnor.client.rpc.ModuleService.buildPackage(java.lang.String,boolean,java.lang.String,java.lang.String,java.lang.String,boolean,java.lang.String,java.lang.String,boolean,java.lang.String) throws com.google.gwt.user.client.rpc.SerializationException' threw an unexpected exception: org.drools.repository.RulesRepositoryException: An error occurred building the module.

               

              12:52:17,237 INFO  [stdout] (http-localhost-127.0.0.1-8080-5) org.drools.repository.RulesRepositoryException: An error occurred building the module.

               

              12:52:17,237 INFO  [stdout] (http-localhost-127.0.0.1-8080-5)     at org.drools.guvnor.server.builder.PackageAssembler.getCompiledBinary(PackageAssembler.java:186)

               

              [...]

               

              12:52:17,253 INFO  [stdout] (http-localhost-127.0.0.1-8080-5)     at java.lang.Thread.run(Thread.java:662)

               

              12:52:17,253 INFO  [stdout] (http-localhost-127.0.0.1-8080-5) Caused by: java.io.NotSerializableException: org.jbpm.bpmn2.xml.ProcessHandler$1

               

              12:52:17,253 INFO  [stdout] (http-localhost-127.0.0.1-8080-5)     at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)

               

              [...]

               

              12:52:17,253 INFO  [stdout] (http-localhost-127.0.0.1-8080-5)     at org.drools.guvnor.server.builder.PackageAssembler.getCompiledBinary(PackageAssembler.java:180)

               

              12:52:17,253 INFO  [stdout] (http-localhost-127.0.0.1-8080-5)     ... 40 more

               

               

              The error is easily repro just setting the CancelActivity attribute to true for Timer Intermediate Event and Signal Intermediate Event (I haven't tried the others).

               

              any idea?

              thanks