The simple, stupid rules workflow engine for Java™
- 30/06/2017: The first version of Easy Flows has been released! Go get it and write some flows! See release notes here.
Easy Flows is a workflow engine for Java. It provides simple APIs and building blocks to make it easy to create and run composable workflows.
A unit of work in Easy Flows is represented by the Work
interface. A work flow is represented by the WorkFlow
interface.
Easy Flows provides 4 implementations of the WorkFlow
interface:
Those are the only basic flows you need to know to start creating workflows with Easy Flows. You don't need to learn a complex notation or concepts, just a few natural APIs that are easy to think about.
First let's write some work:
class PrintMessageWork implements Work {
private String message;
public PrintMessageWork(String message) {
this.message = message;
}
public String getName() {
return "print message work";
}
public WorkReport call() {
System.out.println(message);
return new DefaultWorkReport(WorkStatus.COMPLETED);
}
}
This unit of work prints a given message to the standard output. Now let's suppose we want to create the following workflow:
- print "foo" three times
- then print "hello" and "world" in parallel
- then if both "hello" and "world" have been successfully printed to the console, print "ok", otherwise print "nok"
This workflow can be illustrated as follows:
flow1
is aRepeatFlow
ofwork1
which is printing "foo" three timesflow2
is aParallelFlow
ofwork2
andwork3
which respectively print "hello" and "world" in parallelflow3
is aConditionalFlow
. It first executesflow2
(a workflow is also a work), then ifflow2
is completed, it executeswork4
, otherwisework5
which respectively print "ok" and "nok"flow4
is aSequentialFlow
. It executesflow1
thenflow3
in sequence.
With Easy Flows, this workflow can be implemented with the following snippet:
PrintMessageWork work1 = new PrintMessageWork("foo");
PrintMessageWork work2 = new PrintMessageWork("hello");
PrintMessageWork work3 = new PrintMessageWork("world");
PrintMessageWork work4 = new PrintMessageWork("ok");
PrintMessageWork work5 = new PrintMessageWork("nok");
WorkFlow workflow = aNewSequentialFlow() // flow 4
.execute(aNewRepeatFlow() // flow 1
.named("print foo 3 times")
.repeat(work1)
.times(3)
.build())
.then(aNewConditionalFlow() // flow 3
.execute(aNewParallelFlow() // flow 2
.named("print 'hello' and 'world' in parallel")
.execute(work2, work3)
.build())
.when(WorkReportPredicate.COMPLETED)
.then(work4)
.otherwise(work5)
.build())
.build();
WorkFlowEngine workFlowEngine = aNewWorkFlowEngine().build();
WorkReport workReport = workFlowEngine.run(workflow);
This is not a very useful workflow, but just to give you an idea about how to write workflows with Easy Flows. You can find more details about all of this in the wiki.
Easy Flows was created because of the lack of a simple open source workflow engine that can orchestrate Callable
Java objects.
Why every single workflow engine out there is trying to implement BPMN? There is nothing wrong with BPMN, but it is not easy
( 538 pages specification?? ). Same thing for BPEL..
There are currently good workflow engines, but since they try to implement BPMN, they are not easy to use and are often misused. Most of BPMN concepts are not essential to many applications, and building such applications on top of a heavy engine is not efficient.
Easy Flows tries to provide a simple alternative with natural APIs that are easy to think about along with basic flows that most small/medium sized applications would require. If your business process requires a A0 paper to be drawn down, Easy Flows is probably not the right choice for you.
You are welcome to contribute to the project with pull requests on GitHub.
If you found a bug or want to request a feature, please use the issue tracker.
For any further question, you can use the Gitter channel of the project.
Easy Flows is released under the terms of the MIT license:
The MIT License (MIT)
Copyright (c) 2017 Mahmoud Ben Hassine ([email protected])
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.