Workflow Process Flows
Author:
Fluent Commerce
Changed on:
16 Jan 2025
Overview
An overview of workflow process flows, explaining how processes are executed by the workflow framework and offering best practices for workflow design.
Key points
- Workflow processes execute business logic through rulesets within an execution context.
- Processes can be initiated at the Root Entity level or Sub-Entity level.
- Processes may flow across the same entity, down to a sub-entity, or back up to the parent entity.
- Recommended practices include executing rulesets inline, making business logic visible, and avoiding cyclic flows.
Event Execution Flows
For each process (a process is a set of business logic) in the workflow - one or more rulesets should be executed "inline" with the execution context.
- Process flow can be initiated at either the Root Entity level or directly at the Sub-Entity level.
- Within a single thread of execution, a process may flow across the same entity, down to a sub-entity, or back up to the parent or root entity.
Let's look at an example to understand this better.
Example: UPSERT Inventory Use Case
For the purpose of this example, let us assume that an event is fired with details about an Inventory Position that may or may not yet exist.
- The event is fired against the Inventory Catalogue.
- The Inventory Catalogue workflow is then responsible for determining whether the inventory position exists before forwarding the flow appropriately.
- Either way, an Inventory Position update includes either a new or updated Inventory Quantity prior to recalculating the onHand value on the position level again.
This means the flow enters the workflow at the root entity level (InventoryCatalogue) and will traverse to InventoryPosition and then to the InventoryQuantity level before returning to the InventoryPosition level for final calculation persistence.
Recommended Practice
- For each event received in the workflow engine, all rulesets triggered by that event for the same context should be executed "inline." Rather than breaking the flow for a specific set of automated tasks in a process, they should be completed as part of a single transaction.
- Business logic should be visible in the workflow, not hidden within the Rule code. This includes Logical Gates.
- States should be meaningful and used appropriately.
- Use meaningful Ruleset names and Rule names.
- Don't build cyclic flows (loops) into your workflow.
- There is no parallel processing control. Don't Split and Merge within a single event or controlled transaction. Each rule and ruleset is executed in series on a single thread, and each action is applied in the order it was produced.