cancel
Showing results for 
Search instead for 
Did you mean: 

How to trigger the error boundary event in the task?

kafeitu
Champ on-the-rise
Champ on-the-rise
I know how to trigger a error boundary event in subprocess(class BoundaryErrorEventTest.java in project activiti-engine-examples), but how to trigger it in the task ? :?:

For example……

xml:

<serviceTask id="servicetask1" name="User Task" activiti:class="me.kafeitu.activiti.ErrorBoundaryEventAttachToTaskService"></serviceTask>
    <boundaryEvent id="boundaryerror1" name="" cancelActivity="false" attachedToRef="servicetask1">
      <errorEventDefinition errorRef="errorOne"></errorEventDefinition>
    </boundaryEvent>

Java:

public class ErrorBoundaryEventAttachToTaskService implements JavaDelegate {

   @Override
   public void execute(DelegateExecution execution) throws Exception {
      // TODO throw error for error boundary event
   }

}
4 REPLIES 4

frederikherema1
Star Contributor
Star Contributor
From the top of my head:

You can have a gateway after the task which has 2 paths: one normal and one having an intermediate-thow-event. In your service-task, you can set a variable which influence the gateway's chose path…

kafeitu
Champ on-the-rise
Champ on-the-rise
From the top of my head:

You can have a gateway after the task which has 2 paths: one normal and one having an intermediate-thow-event. In your service-task, you can set a variable which influence the gateway's chose path…

I see, but activiti being not support for intermediate-thow-event of error. Can I trigger it by invoke api manual?

frederikherema1
Star Contributor
Star Contributor
You can use the "throw BPMNError(…)" from inside the user task to have it caught in a catching-error-boundary event. See http://activiti.org/userguide/index.html#bpmnJavaServiceTask (thawing BPMNError).

Another option is to look at the part "Exception sequence flow" in http://activiti.org/userguide/index.html#bpmnJavaServiceTask

kafeitu
Champ on-the-rise
Champ on-the-rise
You can use the "throw BPMNError(…)" from inside the user task to have it caught in a catching-error-boundary event. See http://activiti.org/userguide/index.html#bpmnJavaServiceTask (thawing BPMNError).

Another option is to look at the part "Exception sequence flow" in http://activiti.org/userguide/index.html#bpmnJavaServiceTask

:lol: very thanks for frederikheremans!!!