Skip to content

Activity Decision Node

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

Decision Node

A Decision Node selects outgoing flows according to guards. A token decision evaluates object-flow guards for each token; a control decision evaluates control-flow guards without application data. Both are UML decision nodes, drawn as diamonds. A decision routes along eligible guarded flows; an else flow is the fallback when no guarded flow is selected.

flowchart LR
    start((●)) --> price(Read price)
    price -->|decimal| choose{Decision}
    choose -->|token >= 100| review(Manual review)
    choose -->|else| auto(Auto-approve)
Loading

Mermaid approximation: this diagram shows the model's routing, not a complete UML Activity notation. Rounded boxes represent actions; edge labels identify token types or guards. Mermaid does not provide native Activity node semantics.

Token decision

Specify the token type on AddDecision<TToken>. Each guard receives the candidate token as c.Token.

.AddAction(
    "ReadPrice",
    async c => c.Output(125m),
    node => node.AddFlow<decimal, DecisionNode<decimal>>())
.AddDecision<decimal>(decision => decision
    .AddFlow("ManualReview", flow => flow
        .AddGuard(async c => c.Token >= 100m))
    .AddElseFlow("AutoApprove"))
.AddAction("ManualReview", async c => await review.QueueAsync(c.CancellationToken))
.AddAction("AutoApprove", async c => await approval.ApproveAsync(c.CancellationToken))

The decision forwards matching tokens through the selected object flows. It does not execute application action code itself. If flows need to change the token type, configure an outgoing-flow transformation.

Control decision

Use AddControlDecision when the branch depends on state or another source rather than an incoming token:

.AddControlDecision(decision => decision
    .AddFlow("Approved", flow => flow.AddGuard(async c =>
        await c.Behavior.Values.GetOrDefaultAsync("approved", false)))
    .AddElseFlow("Rejected"))

The default Decision Node option includes ImplicitJoin; configure node options if a different incoming-flow activation rule is required. See Control Flow, Data Flow, and Implicit Fork and Join.

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