FanoutTaskRecord ftRecord = new FanoutTaskRecord(rootJobKey, encodedTasks);
// Store FanoutTaskRecord outside of any transaction, but before
// the FanoutTask is enqueued. If the put succeeds but the
// enqueue fails then the FanoutTaskRecord is orphaned. But
// the Pipeline is still consistent.
dataStore.put(null, ftRecord.toEntity());
FanoutTask fannoutTask = new FanoutTask(ftRecord.getKey(), queueSettings);
taskQueue.enqueue(fannoutTask);
}
}
transaction.commit();