# Batch Workflow best practice

**URL:** <https://community.temporal.io/t/batch-workflow-best-practice/10863>\
**Category:** Community Support\
**Tags:** java-sdk\
**Created:** [January 31, 2024, 7:50am UTC](https://community.temporal.io/t/batch-workflow-best-practice/10863 "2024-01-31T07:50:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mar-inaa](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/mar-inaa/32/4888_2.png) [@mar-inaa](https://community.temporal.io/u/mar-inaa)\
**Post date:** [January 31, 2024, 7:50am UTC](https://community.temporal.io/t/batch-workflow-best-practice/10863/1 "2024-01-31T07:50:03Z")

</div>

Hi! My service get about 200 000 record from external system and i need to process this one(sub process). At the end i need to create report with detail (problem record). I plan to save this batch in database before start temporal workflow(input for workflow -\>batchId) and get it in workflow.I fund batch example,but i think it is not correct, because i can get non deterministic error(record is not sort,batch size can change).May be i have more better decision?For example get list inside activity?

```auto
  List<SingleRecord> records = recordLoader.getRecords(pageSize, offset);
    // Starts a child per record asynchrnously.
    List<Promise<Void>> results = new ArrayList<>(records.size());
    for (SingleRecord record : records) {
      // Uses human friendly child id.
      String childId = Workflow.getInfo().getWorkflowId() + "/" + record.getId();
      RecordProcessorWorkflow processor =
          Workflow.newChildWorkflowStub(
              RecordProcessorWorkflow.class,
              ChildWorkflowOptions.newBuilder().setWorkflowId(childId).build());
      Promise<Void> result = Async.procedure(processor::processRecord, record);
      results.add(result);
    }
    // Waits for all children to complete.
    Promise.allOf(results).get();

```

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [January 31, 2024, 5:57pm UTC](https://community.temporal.io/t/batch-workflow-best-practice/10863/2 "2024-01-31T17:57:20Z")

</div>

Sorry, did you find a bug in the batch sample? I believe it doesn’t have any problem with determinism.

---

<div class="post-metadata">

**Author:** ![mar-inaa](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/mar-inaa/32/4888_2.png) [@mar-inaa](https://community.temporal.io/u/mar-inaa)\
**Post date:** [February 1, 2024, 6:51am UTC](https://community.temporal.io/t/batch-workflow-best-practice/10863/3 "2024-02-01T06:51:05Z")

</div>

Thanks for answer! In batch sample dataset is always static. In my case -start workflow-crash in itaration cycle-support change dataset(delete one set)-get determinism.

---

<div class="post-metadata">

**Author:** ![maxim](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/maxim/32/8_2.png) [@maxim](https://community.temporal.io/u/maxim)\
**Post date:** [February 1, 2024, 6:31pm UTC](https://community.temporal.io/t/batch-workflow-best-practice/10863/4 "2024-02-01T18:31:16Z")

</div>

The sample will work fine with non static dataset as it iterates with data only through activities. As activity result are always recorded in the event history any crashes do not lead to determinism problems.

---

<div class="post-metadata">

**Author:** ![mar-inaa](https://sea2.discourse-cdn.com/flex016/user_avatar/community.temporal.io/mar-inaa/32/4888_2.png) [@mar-inaa](https://community.temporal.io/u/mar-inaa)\
**Post date:** [February 19, 2024, 1:02pm UTC](https://community.temporal.io/t/batch-workflow-best-practice/10863/5 "2024-02-19T13:02:42Z")

</div>

Thanks!Create process! A create the same ,but forget about sort(
