We are pleased to announce a new release of Automatiko - 0.19.0
0.18.0 release there was only option to map complete data objects to the nodes and from nodes back to data objects. This release introduces options to use expressions to either extract parts of the data objects (like selected fields) or to assemble a new types.
@Workflows
public class MyWorkflows {
public WorkflowBuilder splitAndJoin() {
WorkflowBuilder builder = WorkflowBuilder.newWorkflow("UserTasksProcess", "test workflow with user task")
.dataObject("x", Integer.class)
.dataObject("y", String.class);
builder.start("start here").then()
.user("FirstTask").users(() -> java.util.List.of("john"))
.expressionAsInput("data", String.class, () -> "custom value").outputToDataObject("value", "y").then()
.user("SecondTask").users(() -> java.util.List.of("john", "mary")).dataObjectAsInput("x").then()
.end("done");
return builder;
}
}
Expressions can be used both on inputs and outputs. For outputs there are additional helper methods to
Expression can also be used to assign user nodes to users and groups based on data objects.
Have a look at more details about getting started with Workflow Java DSL in Automatiko documentation.
A common requirement is to be able to process given node multiple times based on collection of items.
This is now really simple by using repeat
method on the node builders. That will make given node
to be executed as many times as items in the collection.
@Workflows
public class MyWorkflows {
public WorkflowBuilder sendMultipleMessagesPerCustomer() {
WorkflowBuilder builder = WorkflowBuilder.newWorkflow("multipleMessages", "Sample workflow with that sends multiple Apache Kafka messages")
.listDataObject("customers", Customer.class)
.start("customers")
.then()
.sendMessage("new message").topic("published").repeat("customers", "item")
.fromDataObject("item")
.then()
.log("log message", "Logged customer")
.then()
.endWithMessage("lastUpdate").topic("published").expressionAsInput(String.class, () -> "completed")
.done();
return builder;
}
}
Above workflow will send new message per each customer that is in the customers
data object.
Repeat is supported for following nodes:
In addition to main workflow path, 0.19.0 comes with possibility to define alternative paths that can be initiated based on events:
Workflow image generation has been improved to provide more aligned images of the workflows that were defined via Java DSL. They now support all constructs of the Java DSL including
Additional example has been added to Automatiko examples that implements user registration use case with Java DSL.
It makes use of following components
It can be found in user-registration-javadsl of Automatiko examples.
A lot of sample workflows defined using Workflow Java DSL can be found in Automatiko examples.
Photographs by Unsplash.