Workflow interface
Workflow encapsulates the orchestration of activities and child workflows. It can also answer synchronous queries and receive external events (also known as signals).
Samples
Runnable workflow-interface samples:
| Sample | Description | Code |
|---|---|---|
| File processing | Interface with signal and query methods | FileProcessingWorkflow.java |
| Signal and query methods | Workflow interfaces that define signal or query methods | HelloSignal.java · HelloQuery.java |
| Separate interface and implementation | Workflow interface and implementation in separate files | calculation |
A workflow must define an interface class. All of its methods must have one of the following annotations:
- @WorkflowMethod indicates an entry point to a workflow. It contains parameters such as timeouts and a task_list.
Required parameters (such as
executionStartToCloseTimeoutSeconds) that are not specified through the annotation must be provided at runtime. - @SignalMethod indicates a method that reacts to external signals. It must have a
voidreturn type. - @QueryMethod indicates a method that reacts to synchronous query requests.
You can have more than one method with the same annotation (except @WorkflowMethod). For example:
public interface FileProcessingWorkflow {
@WorkflowMethod(executionStartToCloseTimeoutSeconds = 10, taskList = "file-processing")
String processFile(Arguments args);
@QueryMethod(name="history")
List<String> getHistory();
@QueryMethod(name="status")
String getStatus();
@SignalMethod
void retryNow();
@SignalMethod
void abandon();
}
We recommended that you use a single value type argument for workflow methods. In this way, adding new arguments as fields to the value type is a backwards-compatible change.