Skip to content

Overview

mikolaj-milewski edited this page Mar 19, 2025 · 4 revisions

Stateflows framework concepts

Stateflows framework is .NET toolkit to implement UML-based, executable Behaviors: Actions, State Machines, and Activities. It aims to help developers in building process-based business applications.

Stateflows concept is based on virtual actor model: each Behavior instance executes independently in reaction to incoming messages (called Events). Way the Behavior is processing Events is determined by its definition, expressed in pure C# code using UML-based State Machine or Activity notation.

Communication

Stateflows provides various ways of communication with Behavior instances, all message-oriented and based on Events that can be of any type:

  • Behavior instances can receive Events sent to them by the clients, they can also send Events to other instances and to themselves,

  • Event implementing IRequest<> interface is a request and Behavior instance which receives it can provide a response to it,

  • Behavior instances also can publish notification Events - clients and other instances can subscribe to them.

State

Each Behavior instance is uniquely addressed and able to keep its own independent state between calls. This state consists of current configuration of State Machine or Activity, but also Context Values which are available for developers implementing Behavior's logic.

Scheduling

Beside Events that are sent to Behavior instances by user code, Stateflows supports automatically send Time Events. This natively introduces scheduling in State Machines and Activities.

Storage

Stateflows architecture is storage-agnostic and state of Behavior instances can be kept using various data storage vendors. Currently two storage providers are available as separate NuGet packages:

Transport

Behavior instances can be communicated with within the process which hosts them, but there are also options to contact them remotely - from other backend processes as well as from frontend applications. Currently one transport provider is implemented as separate NuGet packages:

Extensions

Stateflows framework can be extended in various ways. Following extensions are available as separate NuGet packages:

  • PlantUML for State Machine and Activity visualizations,
  • OneOf to enable State Machine Transition to be triggered by multiple Event types,
  • DistributedLock to ensure Behavior instances consistency in clusted environments,
  • FluentValidation to enable developers to validate incoming Events using FluentValidation library.

Clustering

Stateflows can be used in clustered environments only if there is a way to ensure that each Behavior instance is executing exclusively. This can be achieved by using DistributedLock extension.

Multitenancy

Stateflows can be used in multi-tenant environments, the requirement is to implement integration according to the guideline.

Customers

Stateflows is used by following companies:

Tietoevry

Overview
Installation
Behaviors
   State Machines
       Building blocks
           States
               State
               Composite State
               Orthogonal State
               Final State
           Pseudostates
               Choice
               Junction
               Fork
               Join
           Transitions
               Transition
               Default Transition
               Internal Transition
       Concepts
           Evaluation of Transitions
   Activities
       Building blocks
           Nodes
               Action Node
               Decision Node
               Merge Node
               Initial Node
               Final Node
               Input Node
               Output Node
               Fork Node
               Join Node
               Accept Event Action Node
               Send Event Action Node
               Data Store Node
               Structured Activity Node
               Iterative Activity Node
               Parallel Activity Node
           Flows
               Data Flow
               Control Flow
       Concepts
           Implicit fork and join
   Actions

Clone this wiki locally