Document count when processing in batches

Discussion created by srinijilla on Jul 24, 2018

We often need of finding Success and Failure count in the process for notification/reporting purposes.

We were following this document How to get the document count and set it as a process property to get the document count.

However, when we are processing in terms of batches with flow control option, we were missing the actual count. It was only retaining the document count of the last batch executed.


So we have created a new Script that takes care of accounting the previous doc count value. Sharing here as it could be handy for anyone needed.


Prior to this scripting step, we will set the Properties to assign a dynamic process property name "DPP_COUNTER_NAME" with a valid name(Say, "Account Success Count")

At the end of process execution, we will have value in Dyn Proc Prop Account Success Count

import java.util.Properties;
import com.boomi.execution.*;
import com.boomi.execution.ExecutionUtil;

for (int i = 0; i < dataContext.getDataCount(); i++) {
    InputStream is = dataContext.getStream(i);
    Properties props = dataContext.getProperties(i);
    dataContext.storeStream(is, props);

logger = ExecutionUtil.getBaseLogger();

try {
    String counterName = ExecutionUtil.getDynamicProcessProperty("DPP_COUNTER_NAME");
    if (counterName == null || counterName.isEmpty()) {
        counterName = "AllCount";
    }" Counter Name " + counterName);
    String countVal = ExecutionUtil.getDynamicProcessProperty(counterName)
    if (countVal == null || countVal.isEmpty()) {
        countVal = 0;
    Integer count = Integer.parseInt(countVal);
    count = count + dataContext.getDataCount();
    ExecutionUtil.setDynamicProcessProperty(counterName, count.toString(), false);
} catch (Exception e) {"Exception **** " + e.getMessage());