if (batchRequests != null) {
Collections.sort(batchRequests);
ListIterator<BatchRequest> iterator = batchRequests.listIterator(batchRequests.size());
String nextJobName = null;
while (iterator.hasPrevious()) {
BatchRequest batchRequest = iterator.previous();
String jobName = getJobName(requestExecution.getId(),
batchRequest.getOrderId());
Integer separationSeconds = requestExecution.getBatch()
.getBatchSettings().getBatchSeparationInSeconds();
// Create Job and store properties to get next batch request details
jobDetail = newJob(BatchRequestJob.class)
.withIdentity(jobName, ExecutionJob.LINEAR_EXECUTION_JOB_GROUP)
.usingJobData(ExecutionJob.NEXT_EXECUTION_JOB_NAME_KEY, nextJobName)
.usingJobData(ExecutionJob.NEXT_EXECUTION_JOB_GROUP_KEY,
ExecutionJob.LINEAR_EXECUTION_JOB_GROUP)
.usingJobData(BatchRequestJob.BATCH_REQUEST_EXECUTION_ID_KEY,
requestExecution.getId())
.usingJobData(BatchRequestJob.BATCH_REQUEST_BATCH_ID_KEY,
batchRequest.getOrderId())
.usingJobData(BatchRequestJob.BATCH_REQUEST_CLUSTER_NAME_KEY,
requestExecution.getClusterName())
.usingJobData(BatchRequestJob.NEXT_EXECUTION_SEPARATION_SECONDS,
separationSeconds != null ? separationSeconds : 0)
.storeDurably()