Workflow class.
Basic Structure
Complete Example
Service Stubs with Tags and Metadata
You can create service stubs with tags and metadata for routing and context:Workflow Properties
Workflows can have properties, but be careful with their usage:Creating Workflow Stubs
Workflows can create stubs for other workflows:Accessing Context
Workflows can access contextual information during execution:Best Practices
Keep workflows focused
Keep workflows focused
Each workflow should handle a single business process. Break complex processes into multiple workflows using sub-workflows.
Use meaningful names
Use meaningful names
Name your workflow interfaces and classes clearly to indicate their purpose:
OrderProcessingWorkflow, notWorkflow1UserOnboardingWorkflow, notUserWF
Initialize service stubs as properties
Initialize service stubs as properties
Create service stubs as class properties so they’re initialized once:
Avoid stateful operations
Avoid stateful operations
Workflows can be replayed, so avoid operations with side effects:
- Don’t generate random numbers
- Don’t call
System.currentTimeMillis() - Don’t make direct HTTP calls
- Use services for all external interactions
Next Steps
Workflow Methods
Learn about available workflow methods
Calling Services
Understand how to call services from workflows
Sub-workflows
Compose workflows from other workflows
Channels
Receive external signals