Interface WorkflowManager

All Known Implementing Classes:
SimpleWorkflowManager

public interface WorkflowManager
Provides the outside-in API for locating workflow instances and requesting cancellation from application or administrative code. Use findOne(WorkflowStateQuery) when the query must select at most one instance, or findMany(WorkflowStateQuery) to operate on every matching instance.

Cancellation requests are asynchronous and affect live workflow executions only. For example, to request cancellation of a workflow identified by its workflow ID:


 workflowManager.findOne(WorkflowStateQuery.byWorkflowId(workflowId))
                .requestWorkflowCancellation(null);
 
The returned future completes after the cancellation event is durable and the workflow body has been woken. Use the workflow execution context to initiate cancellation from inside a workflow definition.
Since:
5.4.0
Author:
Simon Zambrovski
  • Method Details

    • findOne

      Finds the single workflow instance matching a query.

      The returned result evaluates the query when WorkflowInstances.Single.singleState() is invoked. That operation completes with null when no instance matches. When more than one instance matches, calling CompletableFuture.join() throws a CompletionException whose cause is a NonUniqueWorkflowInstanceMatchException.

      Use a workflow ID when it uniquely identifies the instance to resolve:

      
       workflowManager.findOne(WorkflowStateQuery.byWorkflowId(workflowId))
                      .singleState()
                      .thenAccept(state -> {
                          if (state != null) {
                              inspect(state);
                          }
                      });
       
      Parameters:
      query - criteria used to select the workflow instance
      Returns:
      lazy result for the single matching workflow instance
    • findMany

      Finds every workflow instance matching a query.
      Parameters:
      query - criteria used to select workflow instances
      Returns:
      lazy handle for the matching workflow instances