Workflow Stubs

Subscribe here to follow Infinitic's development. Please ⭐️ us on Github!

The Infinitic client manages workflows through stubs built from the workflow interface.

Here is an example of workflow interface from our Hello World app:

public interface HelloWorld {
    String greet(@Nullable String name);
interface HelloWorld {
    fun greet(name: String?): String

Using this interface, an Infinitic client can create stubs that behaves syntactically as instances of such workflow. Stubs are used to trigger actions such as:

  • starting a new workflow
  • cancelling running workflows
  • sending a signal to running workflows
  • starting a new method on running workflows

Stub of new workflow

The client has a newWorkflowmethod to create the stub of a new workflow:

HelloWorld helloWorld = client.newWorkflow(HelloWorld.class);
val helloWorld : HelloWorld = client.newWorkflow(

We can also add tags to this strub. Those tags will be attached to workflow instances started with this stub.

Set<String> tags = new HashSet<>();

HelloWorld helloWorld = client.newWorkflow(HelloWorld.class, tags);
val helloWorld : HelloWorld = client.newWorkflow(, tags = setOf("foo", "bar"))

The stub of new workflow can be used to start a new workflow instance. It can be used multiple times to start multiple instances.

Running workflow stub

A workflow is said running, as long as it is neither completed neither canceled.

We can create the stub of a running workflow from its id:

HelloWorld helloworld = client.getWorkflowById(HelloWorld.class, id);
val helloworld: HelloWorld = client.getWorkflowById(, id)

Alternatively, we can create a stub targeting all running workflow having a given tag:

HelloWorld helloworld = client.getWorkflowByTag(HelloWorld.class, "foo");
val helloworld: HelloWorld = client.getWorkflowByTag(, tag = "foo")

The stub of running workflows can be used to apply actions to the targeted workflows:

  • cancelling
  • sending signals
  • starting new methods

Creating a stub has no side effect. It just creates an object that contains the provided info.

Edit this page on GitHub Updated at Sat, Sep 10, 2022