Skip to content

Commit d5a8e77

Browse files
committed
Update README
1 parent 0a5d753 commit d5a8e77

File tree

1 file changed

+43
-5
lines changed

1 file changed

+43
-5
lines changed

README.md

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,52 @@ The workflow scheduler analyzes dependencies and executes participating flows in
2424

2525
In order for a Spring-Batch flow to participate in a workflow, it must adhere to the following requirements:
2626

27-
* must accept its input only via a `input` job parameter. This parameter must be encoded as a semicolon-separated list of absolute file paths.
27+
* must accept its input only via an `input` or `input.<key>` job parameter. This parameter must be encoded as a semicolon-separated list of absolute file paths.
2828
* must publish an `outputDir` entry to its execution context. This entry must contain the absolute path of the job-wide output directory, and this will be used to resolve all outputs expected by this job node.
2929

30-
## Describe a workflow
31-
32-
__Todo__
30+
## Build a workflow
31+
32+
A workflow is built on top of Spring Batch flows. An example taken from project's tests:
33+
34+
```java
35+
36+
UUID workflowId = UUID.randomUUID();
37+
Workflow workflow = workflowBuilderFactory.get(workflowId)
38+
.job(b -> b.name("splitter")
39+
.flow(splitFileFlow)
40+
.input(Paths.get("/tmp/input/numbers.txt"))
41+
.parameters(p -> p.addLong("numParts", 2L)
42+
.addString("outputPrefix", "part").addString("outputSuffix", ".txt"))
43+
.output("part1.txt", "part2.txt"))
44+
.job(b -> b.name("validator")
45+
.flow(validatorStep)
46+
.input("splitter", "part1.txt")
47+
.input("splitter", "part2.txt"))
48+
.job(b -> b.name("sorter-1")
49+
.flow(sortFileFlow)
50+
.after("validator")
51+
.input("splitter", "part1.txt")
52+
.parameters(p -> p.addString("outputName", "r.txt"))
53+
.output("r.txt"))
54+
.job(b -> b.name("sorter-2")
55+
.flow(sortFileFlow)
56+
.after("validator")
57+
.input("splitter", "part2.txt")
58+
.parameters(p -> p.addString("outputName", "r.txt"))
59+
.output("r.txt"))
60+
.job(b -> b.name("merger")
61+
.flow(mergeFilesFlow)
62+
.input("sorter-1", "r.txt")
63+
.input("sorter-2", "r.txt")
64+
.parameters(p -> p.addString("outputName", "r.txt"))
65+
.output("r.txt"))
66+
.output("merger", "r.txt")
67+
.build();
68+
69+
```
3370

3471
## Execute a workflow
3572

36-
__Todo__
73+
A workflow is executed (started or restarted) by a workflow scheduler (interface `eu.slipo.workflows.service.WorkflowScheduler`). Currently, the only implementation is the
74+
`EventBasedWorkflowScheduler`.
3775

0 commit comments

Comments
 (0)