Automatiko 0.19.0 released

Enhancements for Workflow Java Domain Specific Language

Posted by Automatiko team on September 22, 2022 · 4 mins read

We are pleased to announce a new release of Automatiko - 0.19.0

Highlights

  • Support for expression as data inputs and outputs
  • Repeat of nodes
  • Standalone paths
  • Improved workflow image generated from workflow Java DSL

Support for expression as data inputs and outputs

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.

Node input as expression workflow Java DSL

  @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

  • append to a list
  • remove from a list

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.

Repeat of nodes

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.

Repeat node workflow Java DSL

  @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:

  • service
  • rest service
  • user
  • sub workflow
  • send message

Standalone paths

In addition to main workflow path, 0.19.0 comes with possibility to define alternative paths that can be initiated based on events:

  • incoming message
  • time interval
Alternative paths can be:
  • interrupting meaning that once such event occoured it will terminate (abort) main flow of the instance.
  • repeatable meaning such event can be received mutliple times as long as the main flow is active.

Improved workflow image generated from workflow Java DSL

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

  • various types of nodes
  • main and alternative paths
  • error handlers
  • messages
Workflow definition image for Java DSL Workflow definition image for Java DSL.

User registration workflow using Java DSL

Additional example has been added to Automatiko examples that implements user registration use case with Java DSL. User registration workflow definition image for Java DSL User registration workflow definition image for Java DSL

It makes use of following components

  • service invocation of local services (classes)
  • rest service calls - Swagger PetStore (GET and POST)
  • error handling on rest calls
  • control logic via split nodes

It can be found in user-registration-javadsl of Automatiko examples.

Sample workflows

A lot of sample workflows defined using Workflow Java DSL can be found in Automatiko examples.

Photographs by Unsplash.