As we transition to the new Hyland Community, some post links may be temporarily disrupted as we finalize redirects. We apologize for the inconvenience and are working to resolve this as quickly as possible. Details.
<process id="exceptionHandling"> <startEvent id="theStart" /> <sequenceFlow id="flow1" sourceRef="theStart" targetRef="javaService" /> <serviceTask id="javaService" name="Java service invocation" activiti:class="org.activiti.examples.bpmn.servicetask.ThrowsExceptionBehavior"> </serviceTask> <sequenceFlow id="no-exception" sourceRef="javaService" targetRef="theEnd" /> <sequenceFlow id="exception" sourceRef="javaService" targetRef="fixException" /> <userTask id="fixException" name="Fix Exception" /> <sequenceFlow id="flow4" sourceRef="fixException" targetRef="theEnd" /> <endEvent id="theEnd" /> </process>
public class ThrowsExceptionBehavior implements ActivityBehavior { public void execute(ActivityExecution execution) throws Exception { String var = (String) execution.getVariable("var"); PvmTransition transition = null; try { executeLogic(var); transition = execution.getActivity().findOutgoingTransition("no-exception"); } catch (Exception e) { transition = execution.getActivity().findOutgoingTransition("exception"); } execution.take(transition); } protected void executeLogic(String value) { if (value.equals("throw-exception")) { throw new RuntimeException(); } } }