Important
|
This feature is still in Beta. Functionality and documentation are subject to change. Workflows will be more deeply leveraged in the framework in future releases, but the functionality is available for review now - allowing the creation of custom workflows. |
Workflows are used to describe one or more steps in a business process with optional branching outcomes. Progress monitoring is included in the admin tool, as well as functions to pause, retry, and cancel (to name a few).
Broadleaf Workflow Services is inspired by the popular Cadence workflow engine. One of Cadence’s most interesting aspects is the programming model and "fault oblivious" nature of coding workflows in this model.
The Cadence solution is a fault-oblivious stateful programming model that obscures most of the complexities of building scalable distributed applications. In essence, Cadence provides a durable virtual memory that is not linked to a specific process, and preserves the full application state, including function stacks, with local variables across all sorts of host and software failures. This allows you to write code using the full power of a programming language while Cadence takes care of durability, availability, and scalability of the application.
This type of business process modeling is very powerful, as it allows the developer to focus on the business execution aspects while not having to worry about all the system failure possibilities that make distributed software development challenging. Instead, the engine takes on the burden of tracking failure and providing facilities for stateful retry - as one example of remediation.
Unfortunately, this model can be taxing to code against, as rigor must be applied to ensure deterministic progression is not violated in the workflow implementation. This guarantees state can be faithfully reproduced upon workflow replay. Broadleaf Workflow Services is designed to be more forgiving in this regard, allowing for a simpler model while still providing the same benefits of durability, availability, and scalability.
Workflows are described as configuration, rather than code. This is one of the big differences between Cadence and Broadleaf Workflow Services. The latter allows for a more declarative approach to workflow definition, which is easier to understand and maintain. It also removes the need to worry about proper deterministic programming in the workflow, as this aspect is controlled by the engine instead.
Workflow configuration describes one or more steps with optional outcomes, leading to a possible decision tree of execution. This allows for complex workflows to be defined in a simple and understandable way.
Each step in the workflow is coded as an activity, which is a Java construct made available in the Broadleaf codebase.
In addition to basic business logic execution, activities can be coded for advanced functionality, including interruption for timely workflow pause and cancellation, as well as pausing the workflow altogether upon exit. The latter feature opens the door for "human-in-the-loop" workflows, where a human can interact with the process - possibly completing a necessary step - before the workflow is allowed to continue.
Activities can be coded in multiple ways with exceptions in mind. Exceptions may be bubbled, in which case, the workflow is updated with a failure status and becomes available for review and retry - usually via the admin tool. Alternatively, the activity may catch the exception and return a different response driving an alternate path in the workflow configuration.
Workflow Services supports idempotency so that a process responsible for requesting a workflow can be retried without fear of spawning a duplicate workflow.
Workflows are managed in the admin. Workflows can be filtered based on various criteria, including context. Progress can be monitored in the admin view. Workflows can also be configured to allow retry, pause, resume, and cancellation. Execution history is also visualized here.
Persistent logging is available to activity implementations. This allows important information to be exposed to business users in the admin tool - possibly allowing for additional remediation steps to be taken before workflow continuation.
Workflow execution scales horizontally with more replicas of the workflow service (or containing flexpackage). It is set up with high consumption concurrency for command messages via Spring Cloud Stream and a backing message broker.
See WorkflowServices documentation for reference and usage information.