@Override
  public void failure(Throwable t) {
    if (scheduledFuture != null) {
      scheduledFuture.cancel(true);
    }

    if (isComplete.compareAndSet(false, true)) {
      String msg = String.format("Callback failed for task %s, ssp %s, offset %s.",
          taskName, systemStreamPartition, offset);
      listener.onFailure(this, new SamzaException(msg, t));
    } else {
      String msg = String.format("Task callback failure was invoked after completion for task %s, ssp %s, offset %s.",
          taskName, systemStreamPartition, offset);
      listener.onFailure(this, new IllegalStateException(msg, t));
    }
  }
This class implements {@link TaskCallback}. It triggers the
{@link TaskCallbackListener} with the callback result. If the
callback is called multiple times, it will throw IllegalStateException
to the listener.
samza-core/src/main/java/org/apache/samza/task/TaskCallbackImpl.java