Skip to content

Activity Action Node

Mikołaj Milewski edited this page Oct 27, 2026 · 1 revision

Action Node

An Action Node performs application work when its incoming flows make it eligible to execute. It is the main executable node in a UML Activity. Incoming object flows provide typed input tokens; the action can produce output tokens and outgoing flows route execution onward.

Define an action

The lambda overload receives an action context and an optional node builder for outgoing flows:

.AddInput(input => input.AddFlow<Request>("Validate"))
.AddAction(
    "Validate",
    async c =>
    {
        var request = c.GetTokensOfType<Request>().Single();
        var validated = await validator.ValidateAsync(request, c.CancellationToken);
        c.Output(validated);
    },
    node => node.AddFlow<ValidatedRequest>("Persist"))
.AddAction(
    "Persist",
    async c => await repository.SaveAsync(
        c.GetTokensOfType<ValidatedRequest>().Single(),
        c.CancellationToken),
    node => node.AddControlFlow<FinalNode>())
.AddFinal()

This fragment receives Request tokens through SendInputAsync. Validate is activated by that input flow; no additional initial control flow is needed for this input-driven path.

Output and OutputRange add object tokens for outgoing flows. GetTokensOfType<T>() reads the input tokens routed to this action. An action can have multiple outgoing control and object flows; use explicit Fork, Decision, or Merge nodes when those routing semantics should be visible in the graph.

Class-based actions

For reusable or dependency-injected logic, define an IActionNode. Constructor parameters can include application services and token interfaces such as IInputTokens<T> and IOutputTokens<T>. The typed class implements ExecuteAsync(CancellationToken); it does not receive a lambda action context parameter.

See Tokens, Flows, and Nodes.

Overview
Installation
Runtimes
   Orleans runtime
Concepts
   Events and Structural Events
   Messaging Patterns
   Validation
   Scheduling
   Observability
Behaviors
   Behavior Values
   Dependency Injection
   Behavioral Groups
   State Machines
       Concepts
           State Identity
           In-State Event Deferrals
           Evaluation of Transitions
           Exception Handling
       Building blocks
           Regions
           States
               State
               Composite State
               Orthogonal State
               Final State
           Pseudostates
               Choice
               Junction
               Fork
               Join
               History
           Transitions
               Transition
               Default Transition
               Internal Transition
   Activities
       Concepts
           Exception Handling
           Implicit Fork and Join
           Tokens
       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
               Publish Event Action Node
               Time Event Action Node
               Data Store Node
               Structured Activity Node
               Iterative Activity Node
               Parallel Activity Node
           Flows
               Data Flow
               Control Flow
   Actions
   Entities
       Fields
       Mutations
       Projections
Extensions
   ClearScript
   FluentValidation
   JSON definitions
   Minimal APIs
   OneOf
   OpenTelemetry
   PlantUML
   Scheduling

Clone this wiki locally