Patterns of workflow definition

I find there are some anti-patterns of the workflow definition. I have several questions here about what are the good patterns:

  1. only one WorkflowMethod should be defined in the workflow interface or not → I find all samples/java-SDK have only one method function with some signals and queries in one workflow interface, but many functions in the activity interface.

  2. should all branching logic go to activity wrapper so that we can mitigate none-deterministic errors when we need to change the code.

only one WorkflowMethod should be defined in the workflow interface or not

Yes, only one your WorkflowMethod is the entry point for your workflow execution. If you define more than one the Java SDK should raise an IllegalArgumentException with message “Duplicated @WorkflowMethod” when its registering your workflow impl with the worker.

  1. should all branching logic go to activity wrapper so that we can mitigate none-deterministic errors when we need to change the code.

Typically you want to have your control-flow logic defined inside workflow code, see this sample that makes decisions based on activity results.
Workflow code does have to be deterministic, see constraints here.
In the case where you need to make updates, you also can utilize versioning.

1 Like