This is a lite workflow engine
lite means it's easy to use, you feel the framework is lite, but the framework is powerful,
for simple case you can use SimpleEngine,
for complex case, you can use TopoEngine.
follow SimpleDemo to check how to play with simple engine,
follow WordsCountDemo to check how to play with complex engine,
and the WordsCount workflow like this:
group 2, group3 and group4 will running in parallel.
+-----------+
| root |
+----+------+
|
|
+----+------+
| group1 |
+-----+-----+
/ | \
/ | \
+-----------+ +----+------+ +-----------+
| group2 | | group3 | | group4 |
+-----------+ +-----------+ +-----------+
\ | /
\ | /
+----+------+
| group5 |
+-----+-----+
the workflow is created using the streaming api, like this
TopologyBuilder builder = new TopologyBuilder();
builder.addTask("root", new Task().setProcessor(new GenerateDataProcessor()));
builder.addTask("group1", new Task().setProcessor(new AppendStringProcessor())).wait("root");
builder.addTask("group2", new Task().setProcessor(new PassdownProcessor())).wait("group1");
builder.addTask("group3", new Task().setProcessor(new PassdownProcessor())).wait("group1");
builder.addTask("group4", new Task().setProcessor(new PassdownWithSleepProcessor())).wait("group1");
builder.addTask("group5", new Task().setProcessor(new CountLengthProcessor())).wait("group2").wait("group3").wait("group4");
also, you can check WordsCountDemoAnno to create the previous workflow with annotation,then code of creating workflow will be like this:
Tuple output=engine.trigger(new TopoContext(new DemoAnnoConfig()), null);
and DemoAnnoConfig is:
@Descriptor({
GenerateDataProcessor.class,
AppendStringProcessor.class,
PassdownProcessor2.class,
PassdownWithSleepProcessor.class,
CountLengthProcessor.class
})
public class DemoAnnoConfig extends AnnoConfig{
}
you can use a workflow diagram plugin to view the workflow diagram based on this annotation
you can check WordsCountDemoWithMultipleDS to create the following style workflow,
+-----------+ +-----------+
| root1 | | root2 |
+----+------+ +----+------+
\ /
\ /
+----+------+
| group1 |
+-----+-----+
/ | \
/ | \
+-----------+ +----+------+ +-----------+
| group2 | | group3 | | group4 |
+-----------+ +-----------+ +-----------+
\ | /
\ | /
+----+------+
| group5 |
+-----+-----+
you can check WordsCountDemoWithMultipleDS2 to create the following one group with multiple tasks workflow,
+--------------+
| root(2 tasks)|
+----+---------+
|
|
+----+------+
| group1 |
+-----+-----+
/ | \
/ | \
+-----------+ +----+------+ +-----------+
| group2 | | group3 | | group4 |
+-----------+ +-----------+ +-----------+
\ | /
\ | /
+----+------+
| group5 |
+-----+-----+
also a more complex one WordsCountDemoAnno2 which do not have a single end node
+-----------+
| root |
+----+------+
|
|
+----+------+
| group1 |
+-----+-----+
/ | \
/ | \
+-----------+ +----+------+ +-----------+
| group2 | | group3 | | group4 |
+-----------+ +-----------+ +-----------+
/ \ |
/ \ |
+-----------+ +----+------+ +-----------+
| group5 | | group6 | | group7 |
+-----------+ +-----------+ +-----------+
\ /
\ /
+-----------+
| group8 |
+----+------+
please contact with Jin Yao for comments/support/improvements or bugs