private void setBatchTimer(Batch<K, V, U> batch) {
    final long maxDelay = batch.getMaxBatchDelay().toMillis();
    if (maxDelay != Integer.MAX_VALUE) {
      scheduledFuture = scheduledExecutorService.schedule(() -> {
        lock.lock();
        try {
          processBatch(false);
        } finally {
          lock.unlock();
        }
      }, maxDelay, TimeUnit.MILLISECONDS);
    }
  }
Set a timer to close the batch when the batch is older than the max delay.
samza-core/src/main/java/org/apache/samza/table/batching/BatchProcessor.java