How to avoid all activities to be rolled back on Flowable Exception

I have a subprocess in which a scriptTask has been added. If the script has a syntax error, the engine stops and everything is rolled back. The process instance is null.

What do i need to do to not roll back but only end with the last activity (Script) completed with the appropriate exception.

For example in my case.
problem evaluating script: ReferenceError: “x” is not defined in at line number 15

Hi,
you can make script task asynchronous. In that case process is started and a new job is created. The job execution fails (3 attempts) and is sent to dead letter job queue.
more info https://flowable.org/docs/userguide/index.html#bpmnConcurrencyAndTransactions

Regards
Martin

Great. Thanks for the quick response Martin.

We are using Java API to define the process. What would be the Java code syntax to achieve the extensionElements. We have included the below code

<serviceTask id="failingServiceTask" flowable:async="true"
    flowable:class="org.flowable.engine.test.jobexecutor.RetryFailingDelegate">

    <extensionElements>
        <flowable:failedJobRetryTimeCycle>R5/PT7M</flowable:failedJobRetryTimeCycle>
    </extensionElements>
</serviceTask>
				ExtensionElement ee = new ExtensionElement();
				ExtensionAttribute ea = new ExtensionAttribute();
				ea.setNamespace("flowable");
				ea.setName("failedJobRetryTimeCycle");
				ea.setValue("R1");
				ee.addAttribute(ea);
				scriptTask.addExtensionElement(ee);

This is the Script definition on publish. We have listeners added, but the extension for retry is missing. Need to know where are we going wrong

  <scriptTask id="Script_345c8416-e3cb-4c21-b807-2e8c55719344" flowable:async="true" scriptFormat="JavaScript" flowable:resultVariable="Script_345c8416-e3cb-4c21-b807-2e8c55719344" flowable:autoStoreVariables="true">
    <extensionElements>
      <flowable:executionListener event="start" class="com.wipro.platform.has.process.listener.ScriptStartExecutionListener"/>
      <flowable:executionListener event="end" class="com.wipro.platform.has.process.listener.ScriptEndExecutionListener"/>
    </extensionElements>
    <script><![CDATA[/* This is the initial input to the script, and it is the output of
  • the last activity. Please do not change it.
    */
    var input_to_script = JSON.parse(LAST_ACTIVITY_OUTPUT);

// Your script code goes here

/* Please assign your script output here, and do not change the

  • variable name.
    */
    output_of_script = “Hello World”]]>

Martin, Thanks

Made the script task asynchronous. Figured it out how to modify count of failed retry
scriptTask.setFailedJobRetryTimeCycleValue(“R0/”);

I want to end with a Java Delegate to be called which builds my final response for the process being executed. Not able to achieve that. Set BoundaryEvents using the needed definition but not getting called. I have shared the XML

scriptTask.setBoundaryEvents(…)

<?xml version='1.0' encoding='UTF-8'?>



<flowable:executionListener event=“end” class=“com.wipro.platform.has.process.listener.TaskEndExecutionListener”/>




<flowable:field name=“requestMethod”>
flowable:expression</flowable:expression>
</flowable:field>
<flowable:field name=“requestUrl”>
flowable:expression</flowable:expression>
</flowable:field>
<flowable:field name=“requestBody”>
flowable:expression</flowable:expression>
</flowable:field>
<flowable:field name=“requestHeaders”>
flowable:expression</flowable:expression>
</flowable:field>
<flowable:field name=“resultVariablePrefix”>
flowable:string</flowable:string>
</flowable:field>
<flowable:field name=“saveResponseParameters”>
flowable:string</flowable:string>
</flowable:field>
<flowable:field name=“requestTimeout”>
flowable:string</flowable:string>
</flowable:field>
<flowable:field name=“failStatusCodes”>
flowable:string</flowable:string>
</flowable:field>
<flowable:field name=“handleStatusCodes”>
flowable:string</flowable:string>
</flowable:field>
<flowable:field name=“saveRequestVariables”>
flowable:string</flowable:string>
</flowable:field>
<flowable:field name=“ignoreException”>
flowable:string</flowable:string>
</flowable:field>
<flowable:executionListener event=“start” class=“com.wipro.platform.has.process.listener.HttpStartExecutionListener”/>
<flowable:executionListener event=“end” class=“com.wipro.platform.has.process.listener.HttpEndExecutionListener”/>











<bpmndi:BPMNDiagram id=“BPMNDiagram_P_c0abf0ee-4261-4150-a6d2-fd6e09480059”>
<bpmndi:BPMNPlane bpmnElement=“P_c0abf0ee-4261-4150-a6d2-fd6e09480059” id=“BPMNPlane_P_c0abf0ee-4261-4150-a6d2-fd6e09480059”/>
</bpmndi:BPMNDiagram>

Hi there could be a problem with the encapsulation of extension elements.
The pull request:


should put the elements into correct place.

Regards
Martin

Thanks Martin

Our current concern is on how to instruct Flowable to call a JavaDelegate when an asynchronous activity fails. For example, a ScriptTask added with a script that has syntax error. The process execution stops. But how to get that failure response and also instruct flowable via a Boundary Event to call a Java Delegate

We are creating processs and executing them using the Java API of flowable. Not using flowable UI

This is the syntax to create a Script Task

				ScriptTask scriptTask = new ScriptTask();
				scriptTask.setId(scriptId);
				scriptTask.setScript(aActivity.getScript());
				scriptTask.setScriptFormat(scriptFormat);
				scriptTask.setAutoStoreVariables(true);
				scriptTask.setResultVariable(scriptId);
				scriptTask.setExecutionListeners(lList);
				scriptTask.setAsynchronous(true);
				scriptTask.setFailedJobRetryTimeCycleValue("R0/");
				scriptTask.setBoundaryEvents(createBoundaryEvents(scriptTask, subProcess));

This is part of the process XML that gets defined

R0/



<flowable:executionListener event=“end” class=“com.wipro.platform.has.process.listener.TaskEndExecutionListener”/>


Hi,

The job is failed ad added to dead letter queue. You can find it there.

Regards
Martin