Problem:

Using the Scriptworkflow item enables the user to execute Java code at runtime.
The execution can lead to system freeze and to infinite loops, which will cause ET-Connector to hang or to crash.

Solution:

It’s very important and required to add calls to the

TRANSACTION.isAborted()

function into loops or after resource intensive commands.

The isAborted() function calls internally the system resource manager and handles the aborted state of a transaction.
NOTE: Without this function, the transaction cannot be aborted by the GUI or the server.

Example:

// ————-
// Script to count rows
// ————-

import java.io.*;
import com.sbs.flow.*;

import com.sbs.data.DataNode;
import com.sbs.data.DataNodeDATAStream;
import com.sbs.storage.Transaction;
import com.sbs.utils.StreamTokenizer;

DataNode [] dn = DATA_OUT.selectNodes(“*/DATA”);

if (dn!=null && dn.length>0 && dn[0].hasStreamData()) {
DataNodeDATAStream dnds = dn[0].getStreamData();
dnds.initStream();
try {
StreamTokenizer st = new StreamTokenizer( dnds, “\n”);
int count = 0;
while (st.hasMoreTokens() && !TRANSACTION.isAborted()) {
st.nextToken();
count++;
}
DATA_OUT.addChild(“CountResult”).setTextData(“” + count);
} finally {
dnds.close();
}
}
else {
throw new WorkflowProcessException(“Need stream input”);
}