UpdateSpec.TransactionWithTasks transactionWithTasks =
(UpdateSpec.TransactionWithTasks) transactionSpec;
Collection<Task> tasks = transactionWithTasks.getTasks();
if (tasks.size() > 0) {
byte[] encodedTasks = FanoutTask.encodeTasks(tasks);
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();
} finally {