New version 0.13.0!



Hello World Application

This guide will walk you through building a "Hello World" workflow from scratch, covering these steps:

  • Creating a project
  • Writing tasks
  • Writing a workflow
  • Deploying workers
  • Starting a workflow

Our HelloWorld workflow will take a name string as input and return "Hello $name!", utilizing two tasks run on distributed workers:

  • A sayHello task that inputs a name string and outputs "Hello $name"
  • An addEnthusiasm task that inputs a str string and outputs "$str!"


Before we begin, ensure you have installed the following dependencies:

You can either run Redis and Pulsar on their own, or with Docker, you can set up the environment using the provided docker-compose.yml file:

  # Pulsar settings
    image: apachepulsar/pulsar:2.11.2
      - BOOKIE_MEM=" -Xms512m -Xmx512m -XX:MaxDirectMemorySize=1g"
    command: >
      /bin/bash -c "bin/ conf/standalone.conf && bin/pulsar standalone"
      - "pulsardata:/pulsar/data"
      - "pulsarconf:/pulsar/conf"
      - "6650:6650"
      - "8080:8080"
      - "8081:8081"

  # Redis storage for state persistence
    image: redis:6.0-alpine
      - "6379:6379"
      - "redisdata:/data"


Create project

Start by creating a new project:

mkdir hello-world && cd hello-world && gradle init

Configure this project by selecting the following settings (you may see slightly different prompts depending on your version of gradle):

Ensure that the version of Java you select matches what you have installed.

Select type of project to generate:
  1: basic
  2: application
  3: library
  4: Gradle plugin
Enter selection (default: basic) [1..4] 2

Select implementation language:
  1: C++
  2: Groovy
  3: Java
  4: Kotlin
  5: Swift
Enter selection (default: Java) [1..5] 3

Split functionality across multiple subprojects?:
  1: no - only one application project
  2: yes - application and library projects
Enter selection (default: no - only one application project) [1..2] 1

Select build script DSL:
  1: Groovy
  2: Kotlin
Enter selection (default: Kotlin) [1..2] 1

Project name (default: hello-world):
Source package (default:

In our Gradle build file, we'll include:

  • The Maven repository
  • The required dependencies
  • A directive to compile using Java 1.8"

Once you've updated your gradle build file, install the dependencies by running:

./gradlew install

Writing services

Next, create a services directory:

mkdir -p app/src/main/java/hello/world/services

Within this directory, define the service in its own file:

Within the same services directory, next define the HelloWorldServiceImpl, which will contain our tasks:

Writing workflow

Set up a workflows directory:

mkdir -p app/src/main/java/hello/world/workflows

Within it, add the HelloWorldWorkflow interface:

And its HelloWorldWorkflowImpl implementation:

This implementation must extend io.infinitic.workflows.Workflow

Note: the newService function creates a stub from the HelloWorldService interface.

Syntax-wise, this stub functions like an implementation of HelloWorldService. However, instead of executing a method directly, it sends a message to carry out the execution. This is why running a workflow without deploying any workers will result in no action being taken.

Pulsar configuration

Configure Pulsar in the app/infinitic.yml file:

  brokerServiceUrl: pulsar://localhost:6650
  webServiceUrl: http://localhost:8080
  tenant: infinitic
  namespace: dev

Deploying workers

Set up services and workflows, and update values for Redis and Pulsar connections as necessary:

    host: localhost
    port: 6379
    database: 0

  brokerServiceUrl: pulsar://localhost:6650
  tenant: infinitic
  namespace: dev

  - name:

  - name:

Replace the App file with:

Our app is ready to run as a worker:

./gradlew run

We have a working worker listening Pulsar and waiting for instructions:

> Task :run
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See for further details.

The SLF4J output messages appear because our app doesn't have a logger set up yet. To eliminate these messages, we can add a logger of our choice, such as Simple Logger, as a dependency in our Gradle build file.

When making code changes, it's necessary to restart the workers to ensure they incorporate these updates.

Start a workflow

Use a config file with pulsar configuration to instantiate an InfiniticClient. Use this client to create a workflow stub and dispatch the workflow.

Here, we already have the infinitic.yml file that we can reuse:

We can run this directly from our IDE (remembering to possibly adjust the working directory in the Run configuration), or we can add a startWorkflow Gradle task to our build file:

and run it from the command line:

./gradlew startWorkflow --args Infinitic

Where the app/worker is running, we should see:

Hello Infinitic!

Congrats! You have run your first Infinitic workflows.



In case of issues, check:

  • If Pulsar and Redis are running
  • Correctness of infinitic.yml file that
    • should expose correct values to access Pulsar and Redis
    • should have name and class that match interface names and implementation full names respectively of our task and workflows
  • If at least one worker is running

Keep in mind that workers will continue running even if an exception occurs in our tasks or workflows. To observe these exceptions, you need to set up a logger and then review the log file for any errors.

Simple logger

To use SimpleLogger as logger in this app, just add the dependency in our Gradle build file:

and this example file in our resources directory:

# SLF4J's SimpleLogger configuration file
# Simple implementation of Logger that sends all enabled log messages, for all defined loggers, to System.err.

# Uncomment this line to use a log file

# Default logging detail level for all instances of SimpleLogger.
# Must be one of ("trace", "debug", "info", "warn", or "error").
# If not specified, defaults to "info".

# Set to true if you want the current date and time to be included in output messages.
# Default is false, and will output the number of milliseconds elapsed since startup.

# Set to true if you want to output the current thread name.
# Defaults to true.

# Set to true if you want the last component of the name to be included in output messages.
# Defaults to false.

Working repository

If we fail to chase a bug, we still can copy this working repository and look for the differences:

git clone