Skip to content

Quick Start

This guide gets you from zero to a running workflow in under 10 minutes using the fully embedded mode (no Kafka, no database needed).

  • Java 21+
  • Maven 3.8+
  • A Spring Boot 4 application — the simplest is a project whose pom.xml has spring-boot-starter-parent as its parent (step 7 runs it with the Spring Boot Maven plugin)
<dependency>
    <groupId>io.mateu.workflow</groupId>
    <artifactId>workflow-engine</artifactId>
    <version>2.42.1</version>
</dependency>

In src/main/resources/application.properties:

workflow.mode=embedded
workflow.persistence=memory

Create src/main/resources/workflows/hello-world.ec.yaml:

# yaml-language-server: $schema=https://raw.githubusercontent.com/miguelperezcolom/eventconductor/main/modules/workflow-engine/src/main/resources/workflow-definition-schema.json
id: hello-world
name: Hello World
version: 1
steps:
- id: start
type: START
name: Start
- id: greet
type: ACTION
name: Greet the user
preconditionStepId: start
- id: end
type: END
name: Done
preconditionStepId: greet
@WorkflowEmbeddedApplication
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
}

The engine hands every ACTION step to the EmbeddedTaskExecutor bean; declare it in a @Configuration class:

@Configuration
public class WorkerConfig {
@Bean
public EmbeddedTaskExecutor greetWorker(UpdateStepExecutionUseCase updateStepExecution) {
return request -> {
String name = request.variables().stream()
.filter(v -> "name".equals(v.name()))
.map(Variable::value)
.findFirst().orElse("World");
System.out.println("Hello, " + name + "!");
updateStepExecution.handle(new UpdateStepExecutionCommand(
request.taskExecutionId(),
List.of(new Variable("greeting", "Hello, " + name + "!")),
"",
StepExecutionStatus.COMPLETED
));
};
}
}

Something has to start the process — a REST controller, a scheduled job, a message listener. For this guide, an ApplicationRunner starts one as soon as the application is up (the definitions in classpath:/workflows/ are loaded by then):

@Component
public class HelloWorldStarter implements ApplicationRunner {
private final ProcessUpstreamEventUseCase processUpstreamEventUseCase;
public HelloWorldStarter(ProcessUpstreamEventUseCase processUpstreamEventUseCase) {
this.processUpstreamEventUseCase = processUpstreamEventUseCase;
}
@Override
public void run(ApplicationArguments args) {
processUpstreamEventUseCase.handle(new ProcessUpstreamEventCommand(
new ProcessCreationRequested(
"hello-world",
"my-first-process",
List.of(new Variable("name", "Alice"))
)
));
}
}

mvn spring-boot:run needs the Spring Boot Maven plugin: with spring-boot-starter-parent as the parent, declaring org.springframework.boot:spring-boot-maven-plugin under <build><plugins> is enough (without the parent, give the plugin a version and import spring-boot-dependencies).

Terminal window
mvn clean install
mvn spring-boot:run

You should see Hello, Alice! in the logs, and the process will complete automatically.